repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
boriel/zxbasic
arch/zx48k/backend/__init__.py
_varx
def _varx(ins): """ Defines a memory space with a default CONSTANT expression 1st parameter is the var name 2nd parameter is the type-size (u8 or i8 for byte, u16 or i16 for word, etc) 3rd parameter is the list of expressions. All of them will be converted to the type required. """ outpu...
python
def _varx(ins): """ Defines a memory space with a default CONSTANT expression 1st parameter is the var name 2nd parameter is the type-size (u8 or i8 for byte, u16 or i16 for word, etc) 3rd parameter is the list of expressions. All of them will be converted to the type required. """ outpu...
Defines a memory space with a default CONSTANT expression 1st parameter is the var name 2nd parameter is the type-size (u8 or i8 for byte, u16 or i16 for word, etc) 3rd parameter is the list of expressions. All of them will be converted to the type required.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L497-L524
boriel/zxbasic
arch/zx48k/backend/__init__.py
_vard
def _vard(ins): """ Defines a memory space with a default set of bytes/words in hexadecimal (starting with a number) or literals (starting with #). Numeric values with more than 2 digits represents a WORD (2 bytes) value. E.g. '01' => 0, '001' => 1, 0 bytes Literal values starts with # (1 byte) or #...
python
def _vard(ins): """ Defines a memory space with a default set of bytes/words in hexadecimal (starting with a number) or literals (starting with #). Numeric values with more than 2 digits represents a WORD (2 bytes) value. E.g. '01' => 0, '001' => 1, 0 bytes Literal values starts with # (1 byte) or #...
Defines a memory space with a default set of bytes/words in hexadecimal (starting with a number) or literals (starting with #). Numeric values with more than 2 digits represents a WORD (2 bytes) value. E.g. '01' => 0, '001' => 1, 0 bytes Literal values starts with # (1 byte) or ## (2 bytes) E.g. '#l...
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L527-L555
boriel/zxbasic
arch/zx48k/backend/__init__.py
_lvarx
def _lvarx(ins): """ Defines a local variable. 1st param is offset of the local variable. 2nd param is the type a list of bytes in hexadecimal. """ output = [] l = eval(ins.quad[3]) # List of bytes to push label = tmp_label() offset = int(ins.quad[1]) tmp = list(ins.quad) tmp[1] = ...
python
def _lvarx(ins): """ Defines a local variable. 1st param is offset of the local variable. 2nd param is the type a list of bytes in hexadecimal. """ output = [] l = eval(ins.quad[3]) # List of bytes to push label = tmp_label() offset = int(ins.quad[1]) tmp = list(ins.quad) tmp[1] = ...
Defines a local variable. 1st param is offset of the local variable. 2nd param is the type a list of bytes in hexadecimal.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L558-L581
boriel/zxbasic
arch/zx48k/backend/__init__.py
_lvard
def _lvard(ins): """ Defines a local variable. 1st param is offset of the local variable. 2nd param is a list of bytes in hexadecimal. """ output = [] l = eval(ins.quad[2]) # List of bytes to push label = tmp_label() offset = int(ins.quad[1]) tmp = list(ins.quad) tmp[1] = label ...
python
def _lvard(ins): """ Defines a local variable. 1st param is offset of the local variable. 2nd param is a list of bytes in hexadecimal. """ output = [] l = eval(ins.quad[2]) # List of bytes to push label = tmp_label() offset = int(ins.quad[1]) tmp = list(ins.quad) tmp[1] = label ...
Defines a local variable. 1st param is offset of the local variable. 2nd param is a list of bytes in hexadecimal.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L584-L607
boriel/zxbasic
arch/zx48k/backend/__init__.py
_out
def _out(ins): """ Translates OUT to asm. """ output = _8bit_oper(ins.quad[2]) output.extend(_16bit_oper(ins.quad[1])) output.append('ld b, h') output.append('ld c, l') output.append('out (c), a') return output
python
def _out(ins): """ Translates OUT to asm. """ output = _8bit_oper(ins.quad[2]) output.extend(_16bit_oper(ins.quad[1])) output.append('ld b, h') output.append('ld c, l') output.append('out (c), a') return output
Translates OUT to asm.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L610-L619
boriel/zxbasic
arch/zx48k/backend/__init__.py
_in
def _in(ins): """ Translates IN to asm. """ output = _16bit_oper(ins.quad[1]) output.append('ld b, h') output.append('ld c, l') output.append('in a, (c)') output.append('push af') return output
python
def _in(ins): """ Translates IN to asm. """ output = _16bit_oper(ins.quad[1]) output.append('ld b, h') output.append('ld c, l') output.append('in a, (c)') output.append('push af') return output
Translates IN to asm.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L622-L631
boriel/zxbasic
arch/zx48k/backend/__init__.py
_load32
def _load32(ins): """ Load a 32 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. """ output = _32bit_oper(ins.quad[2]) output.append('push de') output.append('push hl') return output
python
def _load32(ins): """ Load a 32 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. """ output = _32bit_oper(ins.quad[2]) output.append('push de') output.append('push hl') return output
Load a 32 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L654-L662
boriel/zxbasic
arch/zx48k/backend/__init__.py
_loadf16
def _loadf16(ins): """ Load a 32 bit (16.16) fixed point value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. """ output = _f16_oper(ins.quad[2]) output.append('push de') output.append('push hl') return output
python
def _loadf16(ins): """ Load a 32 bit (16.16) fixed point value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. """ output = _f16_oper(ins.quad[2]) output.append('push de') output.append('push hl') return output
Load a 32 bit (16.16) fixed point value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L665-L673
boriel/zxbasic
arch/zx48k/backend/__init__.py
_loadf
def _loadf(ins): """ Loads a floating point value from a memory address. If 2nd arg. start with '*', it is always treated as an indirect value. """ output = _float_oper(ins.quad[2]) output.extend(_fpush()) return output
python
def _loadf(ins): """ Loads a floating point value from a memory address. If 2nd arg. start with '*', it is always treated as an indirect value. """ output = _float_oper(ins.quad[2]) output.extend(_fpush()) return output
Loads a floating point value from a memory address. If 2nd arg. start with '*', it is always treated as an indirect value.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L676-L683
boriel/zxbasic
arch/zx48k/backend/__init__.py
_loadstr
def _loadstr(ins): """ Loads a string value from a memory address. """ temporal, output = _str_oper(ins.quad[2], no_exaf=True) if not temporal: output.append('call __LOADSTR') REQUIRES.add('loadstr.asm') output.append('push hl') return output
python
def _loadstr(ins): """ Loads a string value from a memory address. """ temporal, output = _str_oper(ins.quad[2], no_exaf=True) if not temporal: output.append('call __LOADSTR') REQUIRES.add('loadstr.asm') output.append('push hl') return output
Loads a string value from a memory address.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L686-L696
boriel/zxbasic
arch/zx48k/backend/__init__.py
_store8
def _store8(ins): """ Stores 2nd operand content into address of 1st operand. store8 a, x => a = x Use '*' for indirect store on 1st operand. """ output = _8bit_oper(ins.quad[2]) op = ins.quad[1] indirect = op[0] == '*' if indirect: op = op[1:] immediate = op[0] == '#' ...
python
def _store8(ins): """ Stores 2nd operand content into address of 1st operand. store8 a, x => a = x Use '*' for indirect store on 1st operand. """ output = _8bit_oper(ins.quad[2]) op = ins.quad[1] indirect = op[0] == '*' if indirect: op = op[1:] immediate = op[0] == '#' ...
Stores 2nd operand content into address of 1st operand. store8 a, x => a = x Use '*' for indirect store on 1st operand.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L699-L749
boriel/zxbasic
arch/zx48k/backend/__init__.py
_store16
def _store16(ins): """ Stores 2nd operand content into address of 1st operand. store16 a, x => *(&a) = x Use '*' for indirect store on 1st operand. """ output = [] output = _16bit_oper(ins.quad[2]) try: value = ins.quad[1] indirect = False if value[0] == '*': ...
python
def _store16(ins): """ Stores 2nd operand content into address of 1st operand. store16 a, x => *(&a) = x Use '*' for indirect store on 1st operand. """ output = [] output = _16bit_oper(ins.quad[2]) try: value = ins.quad[1] indirect = False if value[0] == '*': ...
Stores 2nd operand content into address of 1st operand. store16 a, x => *(&a) = x Use '*' for indirect store on 1st operand.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L752-L811
boriel/zxbasic
arch/zx48k/backend/__init__.py
_store32
def _store32(ins): """ Stores 2nd operand content into address of 1st operand. store16 a, x => *(&a) = x """ op = ins.quad[1] indirect = op[0] == '*' if indirect: op = op[1:] immediate = op[0] == '#' # Might make no sense here? if immediate: op = op[1:] if is_int...
python
def _store32(ins): """ Stores 2nd operand content into address of 1st operand. store16 a, x => *(&a) = x """ op = ins.quad[1] indirect = op[0] == '*' if indirect: op = op[1:] immediate = op[0] == '#' # Might make no sense here? if immediate: op = op[1:] if is_int...
Stores 2nd operand content into address of 1st operand. store16 a, x => *(&a) = x
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L814-L858
boriel/zxbasic
arch/zx48k/backend/__init__.py
_storef16
def _storef16(ins): """ Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x """ value = ins.quad[2] if is_float(value): val = float(ins.quad[2]) # Immediate? (de, hl) = f16(val) q = list(ins.quad) q[2] = (de << 16) | hl ins.quad ...
python
def _storef16(ins): """ Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x """ value = ins.quad[2] if is_float(value): val = float(ins.quad[2]) # Immediate? (de, hl) = f16(val) q = list(ins.quad) q[2] = (de << 16) | hl ins.quad ...
Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L861-L873
boriel/zxbasic
arch/zx48k/backend/__init__.py
_storef
def _storef(ins): """ Stores a floating point value into a memory address. """ output = _float_oper(ins.quad[2]) op = ins.quad[1] indirect = op[0] == '*' if indirect: op = op[1:] immediate = op[0] == '#' # Might make no sense here? if immediate: op = op[1:] if is...
python
def _storef(ins): """ Stores a floating point value into a memory address. """ output = _float_oper(ins.quad[2]) op = ins.quad[1] indirect = op[0] == '*' if indirect: op = op[1:] immediate = op[0] == '#' # Might make no sense here? if immediate: op = op[1:] if is...
Stores a floating point value into a memory address.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L876-L910
boriel/zxbasic
arch/zx48k/backend/__init__.py
_storestr
def _storestr(ins): """ Stores a string value into a memory address. It copies content of 2nd operand (string), into 1st, reallocating dynamic memory for the 1st str. These instruction DOES ALLOW inmediate strings for the 2nd parameter, starting with '#'. Must prepend '#' (immediate sigil) to 1st o...
python
def _storestr(ins): """ Stores a string value into a memory address. It copies content of 2nd operand (string), into 1st, reallocating dynamic memory for the 1st str. These instruction DOES ALLOW inmediate strings for the 2nd parameter, starting with '#'. Must prepend '#' (immediate sigil) to 1st o...
Stores a string value into a memory address. It copies content of 2nd operand (string), into 1st, reallocating dynamic memory for the 1st str. These instruction DOES ALLOW inmediate strings for the 2nd parameter, starting with '#'. Must prepend '#' (immediate sigil) to 1st operand, as we need the &...
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L913-L943
boriel/zxbasic
arch/zx48k/backend/__init__.py
_cast
def _cast(ins): """ Convert data from typeA to typeB (only numeric data types) """ # Signed and unsigned types are the same in the Z80 tA = ins.quad[2] # From TypeA tB = ins.quad[3] # To TypeB YY_TYPES[tA] # Type sizes xsB = sB = YY_TYPES[tB] # Type sizes output = [] if tA in (...
python
def _cast(ins): """ Convert data from typeA to typeB (only numeric data types) """ # Signed and unsigned types are the same in the Z80 tA = ins.quad[2] # From TypeA tB = ins.quad[3] # To TypeB YY_TYPES[tA] # Type sizes xsB = sB = YY_TYPES[tB] # Type sizes output = [] if tA in (...
Convert data from typeA to typeB (only numeric data types)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L946-L995
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jzerof
def _jzerof(ins): """ Jumps if top of the stack (40bit, float) is 0 to arg(1) """ value = ins.quad[1] if is_float(value): if float(value) == 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _float_oper(value) output.append('l...
python
def _jzerof(ins): """ Jumps if top of the stack (40bit, float) is 0 to arg(1) """ value = ins.quad[1] if is_float(value): if float(value) == 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _float_oper(value) output.append('l...
Jumps if top of the stack (40bit, float) is 0 to arg(1)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1078-L1095
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jzerostr
def _jzerostr(ins): """ Jumps if top of the stack contains a NULL pointer or its len is Zero """ output = [] disposable = False # True if string must be freed from memory if ins.quad[1][0] == '_': # Variable? output.append('ld hl, (%s)' % ins.quad[1][0]) else: output.a...
python
def _jzerostr(ins): """ Jumps if top of the stack contains a NULL pointer or its len is Zero """ output = [] disposable = False # True if string must be freed from memory if ins.quad[1][0] == '_': # Variable? output.append('ld hl, (%s)' % ins.quad[1][0]) else: output.a...
Jumps if top of the stack contains a NULL pointer or its len is Zero
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1098-L1124
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jnzero16
def _jnzero16(ins): """ Jumps if top of the stack (16bit) is != 0 to arg(1) """ value = ins.quad[1] if is_int(value): if int(value) != 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _16bit_oper(value) output.append('ld a, h...
python
def _jnzero16(ins): """ Jumps if top of the stack (16bit) is != 0 to arg(1) """ value = ins.quad[1] if is_int(value): if int(value) != 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _16bit_oper(value) output.append('ld a, h...
Jumps if top of the stack (16bit) is != 0 to arg(1)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1143-L1157
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jnzero32
def _jnzero32(ins): """ Jumps if top of the stack (32bit) is !=0 to arg(1) """ value = ins.quad[1] if is_int(value): if int(value) != 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _32bit_oper(value) output.append('ld a, h'...
python
def _jnzero32(ins): """ Jumps if top of the stack (32bit) is !=0 to arg(1) """ value = ins.quad[1] if is_int(value): if int(value) != 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _32bit_oper(value) output.append('ld a, h'...
Jumps if top of the stack (32bit) is !=0 to arg(1)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1160-L1176
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jnzerof16
def _jnzerof16(ins): """ Jumps if top of the stack (32bit) is !=0 to arg(1) Fixed Point (16.16 bit) values. """ value = ins.quad[1] if is_float(value): if float(value) != 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _f16_...
python
def _jnzerof16(ins): """ Jumps if top of the stack (32bit) is !=0 to arg(1) Fixed Point (16.16 bit) values. """ value = ins.quad[1] if is_float(value): if float(value) != 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _f16_...
Jumps if top of the stack (32bit) is !=0 to arg(1) Fixed Point (16.16 bit) values.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1179-L1196
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jgezerou8
def _jgezerou8(ins): """ Jumps if top of the stack (8bit) is >= 0 to arg(1) Always TRUE for unsigned """ output = [] value = ins.quad[1] if not is_int(value): output = _8bit_oper(value) output.append('jp %s' % str(ins.quad[2])) return output
python
def _jgezerou8(ins): """ Jumps if top of the stack (8bit) is >= 0 to arg(1) Always TRUE for unsigned """ output = [] value = ins.quad[1] if not is_int(value): output = _8bit_oper(value) output.append('jp %s' % str(ins.quad[2])) return output
Jumps if top of the stack (8bit) is >= 0 to arg(1) Always TRUE for unsigned
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1250-L1260
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jgezeroi8
def _jgezeroi8(ins): """ Jumps if top of the stack (8bit) is >= 0 to arg(1) """ value = ins.quad[1] if is_int(value): if int(value) >= 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _8bit_oper(value) output.append('add a, a...
python
def _jgezeroi8(ins): """ Jumps if top of the stack (8bit) is >= 0 to arg(1) """ value = ins.quad[1] if is_int(value): if int(value) >= 0: return ['jp %s' % str(ins.quad[2])] # Always true else: return [] output = _8bit_oper(value) output.append('add a, a...
Jumps if top of the stack (8bit) is >= 0 to arg(1)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1263-L1276
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jgezerou16
def _jgezerou16(ins): """ Jumps if top of the stack (16bit) is >= 0 to arg(1) Always TRUE for unsigned """ output = [] value = ins.quad[1] if not is_int(value): output = _16bit_oper(value) output.append('jp %s' % str(ins.quad[2])) return output
python
def _jgezerou16(ins): """ Jumps if top of the stack (16bit) is >= 0 to arg(1) Always TRUE for unsigned """ output = [] value = ins.quad[1] if not is_int(value): output = _16bit_oper(value) output.append('jp %s' % str(ins.quad[2])) return output
Jumps if top of the stack (16bit) is >= 0 to arg(1) Always TRUE for unsigned
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1279-L1289
boriel/zxbasic
arch/zx48k/backend/__init__.py
_jgezerou32
def _jgezerou32(ins): """ Jumps if top of the stack (23bit) is >= 0 to arg(1) Always TRUE for unsigned """ output = [] value = ins.quad[1] if not is_int(value): output = _32bit_oper(value) output.append('jp %s' % str(ins.quad[2])) return output
python
def _jgezerou32(ins): """ Jumps if top of the stack (23bit) is >= 0 to arg(1) Always TRUE for unsigned """ output = [] value = ins.quad[1] if not is_int(value): output = _32bit_oper(value) output.append('jp %s' % str(ins.quad[2])) return output
Jumps if top of the stack (23bit) is >= 0 to arg(1) Always TRUE for unsigned
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1308-L1318
boriel/zxbasic
arch/zx48k/backend/__init__.py
_ret8
def _ret8(ins): """ Returns from a procedure / function an 8bits value """ output = _8bit_oper(ins.quad[1]) output.append('#pragma opt require a') output.append('jp %s' % str(ins.quad[2])) return output
python
def _ret8(ins): """ Returns from a procedure / function an 8bits value """ output = _8bit_oper(ins.quad[1]) output.append('#pragma opt require a') output.append('jp %s' % str(ins.quad[2])) return output
Returns from a procedure / function an 8bits value
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1374-L1380
boriel/zxbasic
arch/zx48k/backend/__init__.py
_ret16
def _ret16(ins): """ Returns from a procedure / function a 16bits value """ output = _16bit_oper(ins.quad[1]) output.append('#pragma opt require hl') output.append('jp %s' % str(ins.quad[2])) return output
python
def _ret16(ins): """ Returns from a procedure / function a 16bits value """ output = _16bit_oper(ins.quad[1]) output.append('#pragma opt require hl') output.append('jp %s' % str(ins.quad[2])) return output
Returns from a procedure / function a 16bits value
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1383-L1389
boriel/zxbasic
arch/zx48k/backend/__init__.py
_ret32
def _ret32(ins): """ Returns from a procedure / function a 32bits value (even Fixed point) """ output = _32bit_oper(ins.quad[1]) output.append('#pragma opt require hl,de') output.append('jp %s' % str(ins.quad[2])) return output
python
def _ret32(ins): """ Returns from a procedure / function a 32bits value (even Fixed point) """ output = _32bit_oper(ins.quad[1]) output.append('#pragma opt require hl,de') output.append('jp %s' % str(ins.quad[2])) return output
Returns from a procedure / function a 32bits value (even Fixed point)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1392-L1398
boriel/zxbasic
arch/zx48k/backend/__init__.py
_retf16
def _retf16(ins): """ Returns from a procedure / function a Fixed Point (32bits) value """ output = _f16_oper(ins.quad[1]) output.append('#pragma opt require hl,de') output.append('jp %s' % str(ins.quad[2])) return output
python
def _retf16(ins): """ Returns from a procedure / function a Fixed Point (32bits) value """ output = _f16_oper(ins.quad[1]) output.append('#pragma opt require hl,de') output.append('jp %s' % str(ins.quad[2])) return output
Returns from a procedure / function a Fixed Point (32bits) value
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1401-L1407
boriel/zxbasic
arch/zx48k/backend/__init__.py
_retf
def _retf(ins): """ Returns from a procedure / function a Floating Point (40bits) value """ output = _float_oper(ins.quad[1]) output.append('#pragma opt require a,bc,de') output.append('jp %s' % str(ins.quad[2])) return output
python
def _retf(ins): """ Returns from a procedure / function a Floating Point (40bits) value """ output = _float_oper(ins.quad[1]) output.append('#pragma opt require a,bc,de') output.append('jp %s' % str(ins.quad[2])) return output
Returns from a procedure / function a Floating Point (40bits) value
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1410-L1416
boriel/zxbasic
arch/zx48k/backend/__init__.py
_retstr
def _retstr(ins): """ Returns from a procedure / function a string pointer (16bits) value """ tmp, output = _str_oper(ins.quad[1], no_exaf=True) if not tmp: output.append('call __LOADSTR') REQUIRES.add('loadstr.asm') output.append('#pragma opt require hl') output.append('jp %s'...
python
def _retstr(ins): """ Returns from a procedure / function a string pointer (16bits) value """ tmp, output = _str_oper(ins.quad[1], no_exaf=True) if not tmp: output.append('call __LOADSTR') REQUIRES.add('loadstr.asm') output.append('#pragma opt require hl') output.append('jp %s'...
Returns from a procedure / function a string pointer (16bits) value
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1419-L1430
boriel/zxbasic
arch/zx48k/backend/__init__.py
_call
def _call(ins): """ Calls a function XXXX (or address XXXX) 2nd parameter contains size of the returning result if any, and will be pushed onto the stack. """ output = [] output.append('call %s' % str(ins.quad[1])) try: val = int(ins.quad[2]) if val == 1: output....
python
def _call(ins): """ Calls a function XXXX (or address XXXX) 2nd parameter contains size of the returning result if any, and will be pushed onto the stack. """ output = [] output.append('call %s' % str(ins.quad[1])) try: val = int(ins.quad[2]) if val == 1: output....
Calls a function XXXX (or address XXXX) 2nd parameter contains size of the returning result if any, and will be pushed onto the stack.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1433-L1457
boriel/zxbasic
arch/zx48k/backend/__init__.py
_leave
def _leave(ins): """ Return from a function popping N bytes from the stack Use '__fastcall__' as 1st parameter, to just return """ global FLAG_use_function_exit output = [] if ins.quad[1] == '__fastcall__': output.append('ret') return output nbytes = int(ins.quad[1]) # Nu...
python
def _leave(ins): """ Return from a function popping N bytes from the stack Use '__fastcall__' as 1st parameter, to just return """ global FLAG_use_function_exit output = [] if ins.quad[1] == '__fastcall__': output.append('ret') return output nbytes = int(ins.quad[1]) # Nu...
Return from a function popping N bytes from the stack Use '__fastcall__' as 1st parameter, to just return
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1460-L1524
boriel/zxbasic
arch/zx48k/backend/__init__.py
_enter
def _enter(ins): """ Enter function sequence for doing a function start ins.quad[1] contains size (in bytes) of local variables Use '__fastcall__' as 1st parameter to prepare a fastcall function (no local variables). """ output = [] if ins.quad[1] == '__fastcall__': retu...
python
def _enter(ins): """ Enter function sequence for doing a function start ins.quad[1] contains size (in bytes) of local variables Use '__fastcall__' as 1st parameter to prepare a fastcall function (no local variables). """ output = [] if ins.quad[1] == '__fastcall__': retu...
Enter function sequence for doing a function start ins.quad[1] contains size (in bytes) of local variables Use '__fastcall__' as 1st parameter to prepare a fastcall function (no local variables).
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1527-L1563
boriel/zxbasic
arch/zx48k/backend/__init__.py
_param32
def _param32(ins): """ Pushes 32bit param into the stack """ output = _32bit_oper(ins.quad[1]) output.append('push de') output.append('push hl') return output
python
def _param32(ins): """ Pushes 32bit param into the stack """ output = _32bit_oper(ins.quad[1]) output.append('push de') output.append('push hl') return output
Pushes 32bit param into the stack
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1582-L1588
boriel/zxbasic
arch/zx48k/backend/__init__.py
_paramf16
def _paramf16(ins): """ Pushes 32bit fixed point param into the stack """ output = _f16_oper(ins.quad[1]) output.append('push de') output.append('push hl') return output
python
def _paramf16(ins): """ Pushes 32bit fixed point param into the stack """ output = _f16_oper(ins.quad[1]) output.append('push de') output.append('push hl') return output
Pushes 32bit fixed point param into the stack
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1591-L1597
boriel/zxbasic
arch/zx48k/backend/__init__.py
_paramf
def _paramf(ins): """ Pushes 40bit (float) param into the stack """ output = _float_oper(ins.quad[1]) output.extend(_fpush()) return output
python
def _paramf(ins): """ Pushes 40bit (float) param into the stack """ output = _float_oper(ins.quad[1]) output.extend(_fpush()) return output
Pushes 40bit (float) param into the stack
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1600-L1605
boriel/zxbasic
arch/zx48k/backend/__init__.py
_paramstr
def _paramstr(ins): """ Pushes an 16 bit unsigned value, which points to a string. For indirect values, it will push the pointer to the pointer :-) """ (tmp, output) = _str_oper(ins.quad[1]) output.pop() # Remove a register flag (useless here) tmp = ins.quad[1][0] in ('#', '_') # Determine...
python
def _paramstr(ins): """ Pushes an 16 bit unsigned value, which points to a string. For indirect values, it will push the pointer to the pointer :-) """ (tmp, output) = _str_oper(ins.quad[1]) output.pop() # Remove a register flag (useless here) tmp = ins.quad[1][0] in ('#', '_') # Determine...
Pushes an 16 bit unsigned value, which points to a string. For indirect values, it will push the pointer to the pointer :-)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1608-L1622
boriel/zxbasic
arch/zx48k/backend/__init__.py
_memcopy
def _memcopy(ins): """ Copies a block of memory from param 2 addr to param 1 addr. """ output = _16bit_oper(ins.quad[3]) output.append('ld b, h') output.append('ld c, l') output.extend(_16bit_oper(ins.quad[1], ins.quad[2], reversed=True)) output.append('ldir') # *** return output
python
def _memcopy(ins): """ Copies a block of memory from param 2 addr to param 1 addr. """ output = _16bit_oper(ins.quad[3]) output.append('ld b, h') output.append('ld c, l') output.extend(_16bit_oper(ins.quad[1], ins.quad[2], reversed=True)) output.append('ldir') # *** return output
Copies a block of memory from param 2 addr to param 1 addr.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1681-L1691
boriel/zxbasic
arch/zx48k/backend/__init__.py
_inline
def _inline(ins): """ Inline code """ tmp = [x.strip(' \t\r\n') for x in ins.quad[1].split('\n')] # Split lines i = 0 while i < len(tmp): if not tmp[i] or tmp[i][0] == ';': # a comment or empty string? tmp.pop(i) continue if tmp[i][0] == '#': # A preproce...
python
def _inline(ins): """ Inline code """ tmp = [x.strip(' \t\r\n') for x in ins.quad[1].split('\n')] # Split lines i = 0 while i < len(tmp): if not tmp[i] or tmp[i][0] == ';': # a comment or empty string? tmp.pop(i) continue if tmp[i][0] == '#': # A preproce...
Inline code
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1694-L1733
boriel/zxbasic
arch/zx48k/backend/__init__.py
convertToBool
def convertToBool(): """ Convert a byte value to boolean (0 or 1) if the global flag strictBool is True """ if not OPTIONS.strictBool.value: return [] REQUIRES.add('strictbool.asm') result = [] result.append('pop af') result.append('call __NORMALIZE_BOOLEAN') result.append(...
python
def convertToBool(): """ Convert a byte value to boolean (0 or 1) if the global flag strictBool is True """ if not OPTIONS.strictBool.value: return [] REQUIRES.add('strictbool.asm') result = [] result.append('pop af') result.append('call __NORMALIZE_BOOLEAN') result.append(...
Convert a byte value to boolean (0 or 1) if the global flag strictBool is True
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L2193-L2207
boriel/zxbasic
arch/zx48k/backend/__init__.py
emit_end
def emit_end(MEMORY=None): """ This special ending autoinitializes required inits (mainly alloc.asm) and changes the MEMORY initial address if it is ORG XXXX to ORG XXXX + heap size """ output = [] output.extend(AT_END) if REQUIRES.intersection(MEMINITS) or '__MEM_INIT' in INITS: ou...
python
def emit_end(MEMORY=None): """ This special ending autoinitializes required inits (mainly alloc.asm) and changes the MEMORY initial address if it is ORG XXXX to ORG XXXX + heap size """ output = [] output.extend(AT_END) if REQUIRES.intersection(MEMINITS) or '__MEM_INIT' in INITS: ou...
This special ending autoinitializes required inits (mainly alloc.asm) and changes the MEMORY initial address if it is ORG XXXX to ORG XXXX + heap size
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L2210-L2232
boriel/zxbasic
arch/zx48k/backend/__init__.py
emit
def emit(mem): """ Begin converting each quad instruction to asm by iterating over the "mem" array, and called its associated function. Each function returns an array of ASM instructions which will be appended to the 'output' array """ def output_join(output, new_chunk): """ Extends...
python
def emit(mem): """ Begin converting each quad instruction to asm by iterating over the "mem" array, and called its associated function. Each function returns an array of ASM instructions which will be appended to the 'output' array """ def output_join(output, new_chunk): """ Extends...
Begin converting each quad instruction to asm by iterating over the "mem" array, and called its associated function. Each function returns an array of ASM instructions which will be appended to the 'output' array
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L2351-L2779
boriel/zxbasic
zxbpplex.py
Lexer.t_asm_CONTINUE
def t_asm_CONTINUE(self, t): r'[\\_]\r?\n' t.lexer.lineno += 1 t.value = t.value[1:] return t
python
def t_asm_CONTINUE(self, t): r'[\\_]\r?\n' t.lexer.lineno += 1 t.value = t.value[1:] return t
r'[\\_]\r?\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L89-L93
boriel/zxbasic
zxbpplex.py
Lexer.t_asmcomment_NEWLINE
def t_asmcomment_NEWLINE(self, t): r'\r?\n' # New line => remove whatever state in top of the stack and replace it with INITIAL t.lexer.lineno += 1 t.lexer.pop_state() return t
python
def t_asmcomment_NEWLINE(self, t): r'\r?\n' # New line => remove whatever state in top of the stack and replace it with INITIAL t.lexer.lineno += 1 t.lexer.pop_state() return t
r'\r?\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L102-L107
boriel/zxbasic
zxbpplex.py
Lexer.t_prepro_define_defargs_defargsopt_defexpr_pragma_if_NEWLINE
def t_prepro_define_defargs_defargsopt_defexpr_pragma_if_NEWLINE(self, t): r'\r?\n' t.lexer.lineno += 1 t.lexer.pop_state() return t
python
def t_prepro_define_defargs_defargsopt_defexpr_pragma_if_NEWLINE(self, t): r'\r?\n' t.lexer.lineno += 1 t.lexer.pop_state() return t
r'\r?\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L137-L141
boriel/zxbasic
zxbpplex.py
Lexer.t_singlecomment_NEWLINE
def t_singlecomment_NEWLINE(self, t): r'\r?\n' t.lexer.pop_state() # Back to initial t.lexer.lineno += 1 return t
python
def t_singlecomment_NEWLINE(self, t): r'\r?\n' t.lexer.pop_state() # Back to initial t.lexer.lineno += 1 return t
r'\r?\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L152-L156
boriel/zxbasic
zxbpplex.py
Lexer.t_comment_endBlock
def t_comment_endBlock(self, t): r"'/" self.__COMMENT_LEVEL -= 1 if not self.__COMMENT_LEVEL: t.lexer.begin('INITIAL')
python
def t_comment_endBlock(self, t): r"'/" self.__COMMENT_LEVEL -= 1 if not self.__COMMENT_LEVEL: t.lexer.begin('INITIAL')
r"'/
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L173-L177
boriel/zxbasic
zxbpplex.py
Lexer.t_msg_STRING
def t_msg_STRING(self, t): r'.*\n' t.lexer.lineno += 1 t.lexer.begin('INITIAL') t.value = t.value.strip() # remove newline an spaces return t
python
def t_msg_STRING(self, t): r'.*\n' t.lexer.lineno += 1 t.lexer.begin('INITIAL') t.value = t.value.strip() # remove newline an spaces return t
r'.*\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L179-L184
boriel/zxbasic
zxbpplex.py
Lexer.t_defexpr_CONTINUE
def t_defexpr_CONTINUE(self, t): r'[\\_]\r?\n' t.lexer.lineno += 1 t.value = t.value[1:] return t
python
def t_defexpr_CONTINUE(self, t): r'[\\_]\r?\n' t.lexer.lineno += 1 t.value = t.value[1:] return t
r'[\\_]\r?\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L191-L195
boriel/zxbasic
zxbpplex.py
Lexer.t_prepro_ID
def t_prepro_ID(self, t): r'[_a-zA-Z][_a-zA-Z0-9]*' # preprocessor directives t.type = reserved_directives.get(t.value.lower(), 'ID') states_ = { 'DEFINE': 'define', 'PRAGMA': 'pragma', 'IF': 'if', 'ERROR': 'msg', 'WARNING': 'msg' ...
python
def t_prepro_ID(self, t): r'[_a-zA-Z][_a-zA-Z0-9]*' # preprocessor directives t.type = reserved_directives.get(t.value.lower(), 'ID') states_ = { 'DEFINE': 'define', 'PRAGMA': 'pragma', 'IF': 'if', 'ERROR': 'msg', 'WARNING': 'msg' ...
r'[_a-zA-Z][_a-zA-Z0-9]*
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L224-L241
boriel/zxbasic
zxbpplex.py
Lexer.t_pragma_ID
def t_pragma_ID(self, t): r'[_a-zA-Z][_a-zA-Z0-9]*' # pragma directives if t.value.upper() in ('PUSH', 'POP'): t.type = t.value.upper() return t
python
def t_pragma_ID(self, t): r'[_a-zA-Z][_a-zA-Z0-9]*' # pragma directives if t.value.upper() in ('PUSH', 'POP'): t.type = t.value.upper() return t
r'[_a-zA-Z][_a-zA-Z0-9]*
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L259-L263
boriel/zxbasic
zxbpplex.py
Lexer.t_INITIAL_asm_sharp
def t_INITIAL_asm_sharp(self, t): r'[ \t]*\#' # Only matches if at beginning of line and "#" if self.find_column(t) == 1: t.lexer.push_state('prepro') # Start preprocessor self.expectingDirective = True
python
def t_INITIAL_asm_sharp(self, t): r'[ \t]*\#' # Only matches if at beginning of line and "#" if self.find_column(t) == 1: t.lexer.push_state('prepro') # Start preprocessor self.expectingDirective = True
r'[ \t]*\#
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L329-L333
boriel/zxbasic
zxbpplex.py
Lexer.put_current_line
def put_current_line(self, prefix='', suffix=''): """ Returns line and file for include / end of include sequences. """ return '%s#line %i "%s"%s' % (prefix, self.lex.lineno, self.filestack[-1][0], suffix)
python
def put_current_line(self, prefix='', suffix=''): """ Returns line and file for include / end of include sequences. """ return '%s#line %i "%s"%s' % (prefix, self.lex.lineno, self.filestack[-1][0], suffix)
Returns line and file for include / end of include sequences.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L385-L388
boriel/zxbasic
zxbpplex.py
Lexer.include_end
def include_end(self): """ Performs and end of include. """ self.lex = self.filestack[-1][2] self.input_data = self.filestack[-1][3] self.filestack.pop() if not self.filestack: # End of input? return self.filestack[-1][1] += 1 # Increment line coun...
python
def include_end(self): """ Performs and end of include. """ self.lex = self.filestack[-1][2] self.input_data = self.filestack[-1][3] self.filestack.pop() if not self.filestack: # End of input? return self.filestack[-1][1] += 1 # Increment line coun...
Performs and end of include.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L419-L437
boriel/zxbasic
zxbpplex.py
Lexer.input
def input(self, str, filename=''): """ Defines input string, removing current lexer. """ self.filestack.append([filename, 1, self.lex, self.input_data]) self.input_data = str self.lex = lex.lex(object=self) self.lex.input(self.input_data)
python
def input(self, str, filename=''): """ Defines input string, removing current lexer. """ self.filestack.append([filename, 1, self.lex, self.input_data]) self.input_data = str self.lex = lex.lex(object=self) self.lex.input(self.input_data)
Defines input string, removing current lexer.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L439-L446
boriel/zxbasic
zxbpplex.py
Lexer.token
def token(self): """ Returns a token from the current input. If tok is None from the current input, it means we are at end of current input (e.g. at end of include file). If so, closes the current input and discards it; then pops the previous input and lexer from the input stack,...
python
def token(self): """ Returns a token from the current input. If tok is None from the current input, it means we are at end of current input (e.g. at end of include file). If so, closes the current input and discards it; then pops the previous input and lexer from the input stack,...
Returns a token from the current input. If tok is None from the current input, it means we are at end of current input (e.g. at end of include file). If so, closes the current input and discards it; then pops the previous input and lexer from the input stack, and gets another token. ...
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L448-L476
boriel/zxbasic
zxbpplex.py
Lexer.find_column
def find_column(self, token): """ Compute column: - token is a token instance """ i = token.lexpos while i > 0: if self.input_data[i - 1] == '\n': break i -= 1 column = token.lexpos - i + 1 return column
python
def find_column(self, token): """ Compute column: - token is a token instance """ i = token.lexpos while i > 0: if self.input_data[i - 1] == '\n': break i -= 1 column = token.lexpos - i + 1 return column
Compute column: - token is a token instance
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbpplex.py#L478-L489
boriel/zxbasic
arch/zx48k/beep.py
getDEHL
def getDEHL(duration, pitch): """Converts duration,pitch to a pair of unsigned 16 bit integers, to be loaded in DE,HL, following the ROM listing. Returns a t-uple with the DE, HL values. """ intPitch = int(pitch) fractPitch = pitch - intPitch # Gets fractional part tmp = 1 + 0.0577622606 * ...
python
def getDEHL(duration, pitch): """Converts duration,pitch to a pair of unsigned 16 bit integers, to be loaded in DE,HL, following the ROM listing. Returns a t-uple with the DE, HL values. """ intPitch = int(pitch) fractPitch = pitch - intPitch # Gets fractional part tmp = 1 + 0.0577622606 * ...
Converts duration,pitch to a pair of unsigned 16 bit integers, to be loaded in DE,HL, following the ROM listing. Returns a t-uple with the DE, HL values.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/beep.py#L36-L60
boriel/zxbasic
symbols/block.py
SymbolBLOCK.make_node
def make_node(cls, *args): """ Creates a chain of code blocks. """ new_args = [] args = [x for x in args if not is_null(x)] for x in args: assert isinstance(x, Symbol) if x.token == 'BLOCK': new_args.extend(SymbolBLOCK.make_node(*x.childre...
python
def make_node(cls, *args): """ Creates a chain of code blocks. """ new_args = [] args = [x for x in args if not is_null(x)] for x in args: assert isinstance(x, Symbol) if x.token == 'BLOCK': new_args.extend(SymbolBLOCK.make_node(*x.childre...
Creates a chain of code blocks.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/block.py#L23-L37
boriel/zxbasic
zxblex.py
t_MACROS
def t_MACROS(t): r'__[a-zA-Z]+__' if t.value in macros: t.type = t.value return t syntax_error(t.lexer.lineno, "unknown macro '%s'" % t.value)
python
def t_MACROS(t): r'__[a-zA-Z]+__' if t.value in macros: t.type = t.value return t syntax_error(t.lexer.lineno, "unknown macro '%s'" % t.value)
r'__[a-zA-Z]+__
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L245-L252
boriel/zxbasic
zxblex.py
t_string_NGRAPH
def t_string_NGRAPH(t): r"\\[ '.:][ '.:]" global __STRING P = {' ': 0, "'": 2, '.': 8, ':': 10} N = {' ': 0, "'": 1, '.': 4, ':': 5} __STRING += chr(128 + P[t.value[1]] + N[t.value[2]])
python
def t_string_NGRAPH(t): r"\\[ '.:][ '.:]" global __STRING P = {' ': 0, "'": 2, '.': 8, ':': 10} N = {' ': 0, "'": 1, '.': 4, ':': 5} __STRING += chr(128 + P[t.value[1]] + N[t.value[2]])
r"\\[ '.:][ '.:]
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L274-L281
boriel/zxbasic
zxblex.py
t_string_STRC
def t_string_STRC(t): r'"' global __STRING t.lexer.begin('INITIAL') t.value = __STRING __STRING = '' return t
python
def t_string_STRC(t): r'"' global __STRING t.lexer.begin('INITIAL') t.value = __STRING __STRING = '' return t
r'"
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L363-L371
boriel/zxbasic
zxblex.py
t_asm
def t_asm(t): r'\b[aA][sS][mM]\b' global ASM, ASMLINENO, IN_STATE t.lexer.begin('asm') ASM = '' ASMLINENO = t.lexer.lineno IN_STATE = True
python
def t_asm(t): r'\b[aA][sS][mM]\b' global ASM, ASMLINENO, IN_STATE t.lexer.begin('asm') ASM = '' ASMLINENO = t.lexer.lineno IN_STATE = True
r'\b[aA][sS][mM]\b
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L381-L389
boriel/zxbasic
zxblex.py
t_asm_ASM
def t_asm_ASM(t): r'\b[eE][nN][dD][ \t]+[aA][sS][mM]\b' global IN_STATE t.lexer.begin('INITIAL') t.value = ASM t.lineno = ASMLINENO - 1 IN_STATE = False return t
python
def t_asm_ASM(t): r'\b[eE][nN][dD][ \t]+[aA][sS][mM]\b' global IN_STATE t.lexer.begin('INITIAL') t.value = ASM t.lineno = ASMLINENO - 1 IN_STATE = False return t
r'\b[eE][nN][dD][ \t]+[aA][sS][mM]\b
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L392-L402
boriel/zxbasic
zxblex.py
t_EmptyRem
def t_EmptyRem(t): r"([']|[Rr][Ee][Mm])\r?\n" t.lexer.begin('INITIAL') t.lexer.lineno += 1 t.value = '\n' t.type = 'NEWLINE' return t
python
def t_EmptyRem(t): r"([']|[Rr][Ee][Mm])\r?\n" t.lexer.begin('INITIAL') t.lexer.lineno += 1 t.value = '\n' t.type = 'NEWLINE' return t
r"([']|[Rr][Ee][Mm])\r?\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L437-L445
boriel/zxbasic
zxblex.py
t_preproc_ID
def t_preproc_ID(t): r'[_A-Za-z]+' t.value = t.value.strip() t.type = preprocessor.get(t.value.lower(), 'ID') return t
python
def t_preproc_ID(t): r'[_A-Za-z]+' t.value = t.value.strip() t.type = preprocessor.get(t.value.lower(), 'ID') return t
r'[_A-Za-z]+
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L448-L453
boriel/zxbasic
zxblex.py
t_ID
def t_ID(t): r'[a-zA-Z][a-zA-Z0-9]*[$%]?' t.type = reserved.get(t.value.lower(), 'ID') callables = { api.constants.CLASS.array: 'ARRAY_ID', } if t.type != 'ID': t.value = t.type else: entry = api.global_.SYMBOL_TABLE.get_entry(t.value) if api.global_.SYMBOL_TABLE is not ...
python
def t_ID(t): r'[a-zA-Z][a-zA-Z0-9]*[$%]?' t.type = reserved.get(t.value.lower(), 'ID') callables = { api.constants.CLASS.array: 'ARRAY_ID', } if t.type != 'ID': t.value = t.type else: entry = api.global_.SYMBOL_TABLE.get_entry(t.value) if api.global_.SYMBOL_TABLE is not ...
r'[a-zA-Z][a-zA-Z0-9]*[$%]?
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L495-L513
boriel/zxbasic
zxblex.py
t_HEXA
def t_HEXA(t): r'([0-9][0-9a-fA-F]*[hH])|(\$[0-9a-fA-F]+)|(0x[0-9a-fA-F]+)' if t.value[0] == '$': t.value = t.value[1:] # Remove initial '$' elif t.value[:2] == '0x': t.value = t.value[2:] # Remove initial '0x' else: t.value = t.value[:-1] # Remove last 'h' t.value = int(...
python
def t_HEXA(t): r'([0-9][0-9a-fA-F]*[hH])|(\$[0-9a-fA-F]+)|(0x[0-9a-fA-F]+)' if t.value[0] == '$': t.value = t.value[1:] # Remove initial '$' elif t.value[:2] == '0x': t.value = t.value[2:] # Remove initial '0x' else: t.value = t.value[:-1] # Remove last 'h' t.value = int(...
r'([0-9][0-9a-fA-F]*[hH])|(\$[0-9a-fA-F]+)|(0x[0-9a-fA-F]+)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L516-L528
boriel/zxbasic
zxblex.py
t_OCTAL
def t_OCTAL(t): r'[0-7]+[oO]' t.value = t.value[:-1] t.type = 'NUMBER' t.value = int(t.value, 8) return t
python
def t_OCTAL(t): r'[0-7]+[oO]' t.value = t.value[:-1] t.type = 'NUMBER' t.value = int(t.value, 8) return t
r'[0-7]+[oO]
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L531-L537
boriel/zxbasic
zxblex.py
t_bin_NUMBER
def t_bin_NUMBER(t): r'[01]+' # A binary integer t.value = int(t.value, 2) t.lexer.begin('INITIAL') return t
python
def t_bin_NUMBER(t): r'[01]+' # A binary integer t.value = int(t.value, 2) t.lexer.begin('INITIAL') return t
r'[01]+
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L557-L562
boriel/zxbasic
zxblex.py
t_NUMBER
def t_NUMBER(t): # This pattern must come AFTER t_HEXA and t_BIN r'(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][-+]?[0-9]+)?' t.text = t.value t.value = float(t.value) if t.value == int(t.value) and is_label(t): t.value = int(t.value) t.type = 'LABEL' return t
python
def t_NUMBER(t): # This pattern must come AFTER t_HEXA and t_BIN r'(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][-+]?[0-9]+)?' t.text = t.value t.value = float(t.value) if t.value == int(t.value) and is_label(t): t.value = int(t.value) t.type = 'LABEL' return t
r'(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][-+]?[0-9]+)?
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L565-L575
boriel/zxbasic
zxblex.py
t_bin_ZERO
def t_bin_ZERO(t): r'[^01]' t.lexer.begin('INITIAL') t.type = 'NUMBER' t.value = 0 t.lexer.lexpos -= 1 return t
python
def t_bin_ZERO(t): r'[^01]' t.lexer.begin('INITIAL') t.type = 'NUMBER' t.value = 0 t.lexer.lexpos -= 1 return t
r'[^01]
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L592-L598
boriel/zxbasic
zxblex.py
t_INITIAL_bin_NEWLINE
def t_INITIAL_bin_NEWLINE(t): r'\r?\n' global LABELS_ALLOWED t.lexer.lineno += 1 t.value = '\n' LABELS_ALLOWED = True return t
python
def t_INITIAL_bin_NEWLINE(t): r'\r?\n' global LABELS_ALLOWED t.lexer.lineno += 1 t.value = '\n' LABELS_ALLOWED = True return t
r'\r?\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L602-L609
boriel/zxbasic
zxblex.py
find_column
def find_column(token): """ Compute column: input is the input text string token is a token instance """ i = token.lexpos input = token.lexer.lexdata while i > 0: if input[i - 1] == '\n': break i -= 1 column = token.lexpos - i + 1 return...
python
def find_column(token): """ Compute column: input is the input text string token is a token instance """ i = token.lexpos input = token.lexer.lexdata while i > 0: if input[i - 1] == '\n': break i -= 1 column = token.lexpos - i + 1 return...
Compute column: input is the input text string token is a token instance
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L625-L640
boriel/zxbasic
zxblex.py
is_label
def is_label(token): """ Return whether the token is a label (an integer number or id at the beginning of a line. To do so, we compute find_column() and moves back to the beginning of the line if previous chars are spaces or tabs. If column 0 is reached, it's a label. """ if not LABELS_ALLO...
python
def is_label(token): """ Return whether the token is a label (an integer number or id at the beginning of a line. To do so, we compute find_column() and moves back to the beginning of the line if previous chars are spaces or tabs. If column 0 is reached, it's a label. """ if not LABELS_ALLO...
Return whether the token is a label (an integer number or id at the beginning of a line. To do so, we compute find_column() and moves back to the beginning of the line if previous chars are spaces or tabs. If column 0 is reached, it's a label.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxblex.py#L643-L670
boriel/zxbasic
symbols/number.py
_get_val
def _get_val(other): """ Given a Number, a Numeric Constant or a python number return its value """ assert isinstance(other, (numbers.Number, SymbolNUMBER, SymbolCONST)) if isinstance(other, SymbolNUMBER): return other.value if isinstance(other, SymbolCONST): return other.expr.value...
python
def _get_val(other): """ Given a Number, a Numeric Constant or a python number return its value """ assert isinstance(other, (numbers.Number, SymbolNUMBER, SymbolCONST)) if isinstance(other, SymbolNUMBER): return other.value if isinstance(other, SymbolCONST): return other.expr.value...
Given a Number, a Numeric Constant or a python number return its value
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/number.py#L21-L31
boriel/zxbasic
prepro/id_.py
ID.__dumptable
def __dumptable(self, table): """ Dumps table on screen for debugging purposes """ for x in table.table.keys(): sys.stdout.write("{0}\t<--- {1} {2}".format(x, table[x], type(table[x]))) if isinstance(table[x], ID): sys.stdout(" {0}".format(table[x]...
python
def __dumptable(self, table): """ Dumps table on screen for debugging purposes """ for x in table.table.keys(): sys.stdout.write("{0}\t<--- {1} {2}".format(x, table[x], type(table[x]))) if isinstance(table[x], ID): sys.stdout(" {0}".format(table[x]...
Dumps table on screen for debugging purposes
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/prepro/id_.py#L44-L52
boriel/zxbasic
api/optimize.py
OptimizerVisitor.visit_RETURN
def visit_RETURN(self, node): """ Visits only children[1], since children[0] points to the current function being returned from (if any), and might cause infinite recursion. """ if len(node.children) == 2: node.children[1] = (yield ToVisit(node.children[1])) y...
python
def visit_RETURN(self, node): """ Visits only children[1], since children[0] points to the current function being returned from (if any), and might cause infinite recursion. """ if len(node.children) == 2: node.children[1] = (yield ToVisit(node.children[1])) y...
Visits only children[1], since children[0] points to the current function being returned from (if any), and might cause infinite recursion.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/optimize.py#L160-L167
boriel/zxbasic
symbols/vararray.py
SymbolVARARRAY.count
def count(self): """ Total number of array cells """ return functools.reduce(lambda x, y: x * y, (x.count for x in self.bounds))
python
def count(self): """ Total number of array cells """ return functools.reduce(lambda x, y: x * y, (x.count for x in self.bounds))
Total number of array cells
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/vararray.py#L38-L41
boriel/zxbasic
symbols/vararray.py
SymbolVARARRAY.memsize
def memsize(self): """ Total array cell + indexes size """ return self.size + 1 + TYPE.size(gl.BOUND_TYPE) * len(self.bounds)
python
def memsize(self): """ Total array cell + indexes size """ return self.size + 1 + TYPE.size(gl.BOUND_TYPE) * len(self.bounds)
Total array cell + indexes size
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/vararray.py#L48-L51
boriel/zxbasic
symbols/typecast.py
SymbolTYPECAST.make_node
def make_node(cls, new_type, node, lineno): """ Creates a node containing the type cast of the given one. If new_type == node.type, then nothing is done, and the same node is returned. Returns None on failure (and calls syntax_error) """ assert isinstance(new_typ...
python
def make_node(cls, new_type, node, lineno): """ Creates a node containing the type cast of the given one. If new_type == node.type, then nothing is done, and the same node is returned. Returns None on failure (and calls syntax_error) """ assert isinstance(new_typ...
Creates a node containing the type cast of the given one. If new_type == node.type, then nothing is done, and the same node is returned. Returns None on failure (and calls syntax_error)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/typecast.py#L44-L102
boriel/zxbasic
asmparse.py
normalize_namespace
def normalize_namespace(namespace): """ Given a namespace (e.g. '.' or 'mynamespace'), returns it in normalized form. That is: - always prefixed with a dot - no trailing dots - any double dots are converted to single dot (..my..namespace => .my.namespace) - one or more dots (e.g....
python
def normalize_namespace(namespace): """ Given a namespace (e.g. '.' or 'mynamespace'), returns it in normalized form. That is: - always prefixed with a dot - no trailing dots - any double dots are converted to single dot (..my..namespace => .my.namespace) - one or more dots (e.g....
Given a namespace (e.g. '.' or 'mynamespace'), returns it in normalized form. That is: - always prefixed with a dot - no trailing dots - any double dots are converted to single dot (..my..namespace => .my.namespace) - one or more dots (e.g. '.', '..', '...') are converted to '.' (Glo...
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L55-L64
boriel/zxbasic
asmparse.py
init
def init(): """ Initializes this module """ global ORG global LEXER global MEMORY global INITS global AUTORUN_ADDR global NAMESPACE ORG = 0 # Origin of CODE INITS = [] MEMORY = None # Memory for instructions (Will be initialized with a Memory() instance) AUTORUN_ADDR =...
python
def init(): """ Initializes this module """ global ORG global LEXER global MEMORY global INITS global AUTORUN_ADDR global NAMESPACE ORG = 0 # Origin of CODE INITS = [] MEMORY = None # Memory for instructions (Will be initialized with a Memory() instance) AUTORUN_ADDR =...
Initializes this module
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L67-L83
boriel/zxbasic
asmparse.py
p_program
def p_program(p): """ program : line """ if p[1] is not None: [MEMORY.add_instruction(x) for x in p[1] if isinstance(x, Asm)]
python
def p_program(p): """ program : line """ if p[1] is not None: [MEMORY.add_instruction(x) for x in p[1] if isinstance(x, Asm)]
program : line
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L601-L605
boriel/zxbasic
asmparse.py
p_program_line
def p_program_line(p): """ program : program line """ if p[2] is not None: [MEMORY.add_instruction(x) for x in p[2] if isinstance(x, Asm)]
python
def p_program_line(p): """ program : program line """ if p[2] is not None: [MEMORY.add_instruction(x) for x in p[2] if isinstance(x, Asm)]
program : program line
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L608-L612
boriel/zxbasic
asmparse.py
p_def_label
def p_def_label(p): """ line : ID EQU expr NEWLINE | ID EQU pexpr NEWLINE """ p[0] = None __DEBUG__("Declaring '%s%s' in %i" % (NAMESPACE, p[1], p.lineno(1))) MEMORY.declare_label(p[1], p.lineno(1), p[3])
python
def p_def_label(p): """ line : ID EQU expr NEWLINE | ID EQU pexpr NEWLINE """ p[0] = None __DEBUG__("Declaring '%s%s' in %i" % (NAMESPACE, p[1], p.lineno(1))) MEMORY.declare_label(p[1], p.lineno(1), p[3])
line : ID EQU expr NEWLINE | ID EQU pexpr NEWLINE
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L615-L621
boriel/zxbasic
asmparse.py
p_line_label_asm
def p_line_label_asm(p): """ line : LABEL asms NEWLINE """ p[0] = p[2] __DEBUG__("Declaring '%s%s' (value %04Xh) in %i" % (NAMESPACE, p[1], MEMORY.org, p.lineno(1))) MEMORY.declare_label(p[1], p.lineno(1))
python
def p_line_label_asm(p): """ line : LABEL asms NEWLINE """ p[0] = p[2] __DEBUG__("Declaring '%s%s' (value %04Xh) in %i" % (NAMESPACE, p[1], MEMORY.org, p.lineno(1))) MEMORY.declare_label(p[1], p.lineno(1))
line : LABEL asms NEWLINE
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L624-L629
boriel/zxbasic
asmparse.py
p_asm_ld8
def p_asm_ld8(p): """ asm : LD reg8 COMMA reg8_hl | LD reg8_hl COMMA reg8 | LD reg8 COMMA reg8 | LD SP COMMA HL | LD SP COMMA reg16i | LD A COMMA reg8 | LD reg8 COMMA A | LD reg8_hl COMMA A | LD A COMMA reg8_hl ...
python
def p_asm_ld8(p): """ asm : LD reg8 COMMA reg8_hl | LD reg8_hl COMMA reg8 | LD reg8 COMMA reg8 | LD SP COMMA HL | LD SP COMMA reg16i | LD A COMMA reg8 | LD reg8 COMMA A | LD reg8_hl COMMA A | LD A COMMA reg8_hl ...
asm : LD reg8 COMMA reg8_hl | LD reg8_hl COMMA reg8 | LD reg8 COMMA reg8 | LD SP COMMA HL | LD SP COMMA reg16i | LD A COMMA reg8 | LD reg8 COMMA A | LD reg8_hl COMMA A | LD A COMMA reg8_hl | LD A COMMA A ...
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L657-L682
boriel/zxbasic
asmparse.py
p_LOCAL
def p_LOCAL(p): """ asm : LOCAL id_list """ p[0] = None for label, line in p[2]: __DEBUG__("Setting label '%s' as local at line %i" % (label, line)) MEMORY.set_label(label, line, local=True)
python
def p_LOCAL(p): """ asm : LOCAL id_list """ p[0] = None for label, line in p[2]: __DEBUG__("Setting label '%s' as local at line %i" % (label, line)) MEMORY.set_label(label, line, local=True)
asm : LOCAL id_list
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L708-L715
boriel/zxbasic
asmparse.py
p_DEFS
def p_DEFS(p): # Define bytes """ asm : DEFS number_list """ if len(p[2]) > 2: error(p.lineno(1), "too many arguments for DEFS") if len(p[2]) < 2: num = Expr.makenode(Container(0, p.lineno(1))) # Defaults to 0 p[2] = p[2] + (num,) p[0] = Asm(p.lineno(1), 'DEFS', p[2])
python
def p_DEFS(p): # Define bytes """ asm : DEFS number_list """ if len(p[2]) > 2: error(p.lineno(1), "too many arguments for DEFS") if len(p[2]) < 2: num = Expr.makenode(Container(0, p.lineno(1))) # Defaults to 0 p[2] = p[2] + (num,) p[0] = Asm(p.lineno(1), 'DEFS', p[2])
asm : DEFS number_list
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L737-L747
boriel/zxbasic
asmparse.py
p_ind8_I
def p_ind8_I(p): """ reg8_I : LP IX PLUS expr RP | LP IX MINUS expr RP | LP IY PLUS expr RP | LP IY MINUS expr RP | LP IX PLUS pexpr RP | LP IX MINUS pexpr RP | LP IY PLUS pexpr RP | LP IY MINUS pexpr RP ...
python
def p_ind8_I(p): """ reg8_I : LP IX PLUS expr RP | LP IX MINUS expr RP | LP IY PLUS expr RP | LP IY MINUS expr RP | LP IX PLUS pexpr RP | LP IX MINUS pexpr RP | LP IY PLUS pexpr RP | LP IY MINUS pexpr RP ...
reg8_I : LP IX PLUS expr RP | LP IX MINUS expr RP | LP IY PLUS expr RP | LP IY MINUS expr RP | LP IX PLUS pexpr RP | LP IX MINUS pexpr RP | LP IY PLUS pexpr RP | LP IY MINUS pexpr RP
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L790-L804
boriel/zxbasic
asmparse.py
p_namespace
def p_namespace(p): """ asm : NAMESPACE ID """ global NAMESPACE NAMESPACE = normalize_namespace(p[2]) __DEBUG__('Setting namespace to ' + (NAMESPACE.rstrip(DOT) or DOT), level=1)
python
def p_namespace(p): """ asm : NAMESPACE ID """ global NAMESPACE NAMESPACE = normalize_namespace(p[2]) __DEBUG__('Setting namespace to ' + (NAMESPACE.rstrip(DOT) or DOT), level=1)
asm : NAMESPACE ID
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L826-L832
boriel/zxbasic
asmparse.py
p_align
def p_align(p): """ asm : ALIGN expr | ALIGN pexpr """ align = p[2].eval() if align < 2: error(p.lineno(1), "ALIGN value must be greater than 1") return MEMORY.set_org(MEMORY.org + (align - MEMORY.org % align) % align, p.lineno(1))
python
def p_align(p): """ asm : ALIGN expr | ALIGN pexpr """ align = p[2].eval() if align < 2: error(p.lineno(1), "ALIGN value must be greater than 1") return MEMORY.set_org(MEMORY.org + (align - MEMORY.org % align) % align, p.lineno(1))
asm : ALIGN expr | ALIGN pexpr
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L835-L844
boriel/zxbasic
asmparse.py
p_incbin
def p_incbin(p): """ asm : INCBIN STRING """ try: fname = zxbpp.search_filename(p[2], p.lineno(2), local_first=True) if not fname: p[0] = None return with api.utils.open_file(fname, 'rb') as f: filecontent = f.read() except IOError: err...
python
def p_incbin(p): """ asm : INCBIN STRING """ try: fname = zxbpp.search_filename(p[2], p.lineno(2), local_first=True) if not fname: p[0] = None return with api.utils.open_file(fname, 'rb') as f: filecontent = f.read() except IOError: err...
asm : INCBIN STRING
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L847-L862
boriel/zxbasic
asmparse.py
p_LD_reg_val
def p_LD_reg_val(p): """ asm : LD reg8 COMMA expr | LD reg8 COMMA pexpr | LD reg16 COMMA expr | LD reg8_hl COMMA expr | LD A COMMA expr | LD SP COMMA expr | LD reg8i COMMA expr """ s = 'LD %s,N' % p[2] if p[2] in REGS16: s +...
python
def p_LD_reg_val(p): """ asm : LD reg8 COMMA expr | LD reg8 COMMA pexpr | LD reg16 COMMA expr | LD reg8_hl COMMA expr | LD A COMMA expr | LD SP COMMA expr | LD reg8i COMMA expr """ s = 'LD %s,N' % p[2] if p[2] in REGS16: s +...
asm : LD reg8 COMMA expr | LD reg8 COMMA pexpr | LD reg16 COMMA expr | LD reg8_hl COMMA expr | LD A COMMA expr | LD SP COMMA expr | LD reg8i COMMA expr
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L886-L899
boriel/zxbasic
asmparse.py
p_JP_hl
def p_JP_hl(p): """ asm : JP reg8_hl | JP LP reg16i RP """ s = 'JP ' if p[2] == '(HL)': s += p[2] else: s += '(%s)' % p[3] p[0] = Asm(p.lineno(1), s)
python
def p_JP_hl(p): """ asm : JP reg8_hl | JP LP reg16i RP """ s = 'JP ' if p[2] == '(HL)': s += p[2] else: s += '(%s)' % p[3] p[0] = Asm(p.lineno(1), s)
asm : JP reg8_hl | JP LP reg16i RP
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L908-L918
boriel/zxbasic
asmparse.py
p_BIT
def p_BIT(p): """ asm : bitop expr COMMA A | bitop pexpr COMMA A | bitop expr COMMA reg8 | bitop pexpr COMMA reg8 | bitop expr COMMA reg8_hl | bitop pexpr COMMA reg8_hl """ bit = p[2].eval() if bit < 0 or bit > 7: error(p.lineno(3), 'In...
python
def p_BIT(p): """ asm : bitop expr COMMA A | bitop pexpr COMMA A | bitop expr COMMA reg8 | bitop pexpr COMMA reg8 | bitop expr COMMA reg8_hl | bitop pexpr COMMA reg8_hl """ bit = p[2].eval() if bit < 0 or bit > 7: error(p.lineno(3), 'In...
asm : bitop expr COMMA A | bitop pexpr COMMA A | bitop expr COMMA reg8 | bitop pexpr COMMA reg8 | bitop expr COMMA reg8_hl | bitop pexpr COMMA reg8_hl
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1045-L1059
boriel/zxbasic
asmparse.py
p_BIT_ix
def p_BIT_ix(p): """ asm : bitop expr COMMA reg8_I | bitop pexpr COMMA reg8_I """ bit = p[2].eval() if bit < 0 or bit > 7: error(p.lineno(3), 'Invalid bit position %i. Must be in [0..7]' % bit) p[0] = None return p[0] = Asm(p.lineno(3), '%s %i,%s' % (p[1], bit, p...
python
def p_BIT_ix(p): """ asm : bitop expr COMMA reg8_I | bitop pexpr COMMA reg8_I """ bit = p[2].eval() if bit < 0 or bit > 7: error(p.lineno(3), 'Invalid bit position %i. Must be in [0..7]' % bit) p[0] = None return p[0] = Asm(p.lineno(3), '%s %i,%s' % (p[1], bit, p...
asm : bitop expr COMMA reg8_I | bitop pexpr COMMA reg8_I
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1062-L1072