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
asmparse.py
p_jr
def p_jr(p): """ asm : JR jr_flags COMMA expr | JR jr_flags COMMA pexpr """ p[4] = Expr.makenode(Container('-', p.lineno(3)), p[4], Expr.makenode(Container(MEMORY.org + 2, p.lineno(1)))) p[0] = Asm(p.lineno(1), 'JR %s,N' % p[2], p[4])
python
def p_jr(p): """ asm : JR jr_flags COMMA expr | JR jr_flags COMMA pexpr """ p[4] = Expr.makenode(Container('-', p.lineno(3)), p[4], Expr.makenode(Container(MEMORY.org + 2, p.lineno(1)))) p[0] = Asm(p.lineno(1), 'JR %s,N' % p[2], p[4])
asm : JR jr_flags COMMA expr | JR jr_flags COMMA pexpr
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1174-L1179
boriel/zxbasic
asmparse.py
p_jrjp
def p_jrjp(p): """ asm : JP expr | JR expr | CALL expr | DJNZ expr | JP pexpr | JR pexpr | CALL pexpr | DJNZ pexpr """ if p[1] in ('JR', 'DJNZ'): op = 'N' p[2] = Expr.makenode(Container('-', p.lineno(1)), p[2...
python
def p_jrjp(p): """ asm : JP expr | JR expr | CALL expr | DJNZ expr | JP pexpr | JR pexpr | CALL pexpr | DJNZ pexpr """ if p[1] in ('JR', 'DJNZ'): op = 'N' p[2] = Expr.makenode(Container('-', p.lineno(1)), p[2...
asm : JP expr | JR expr | CALL expr | DJNZ expr | JP pexpr | JR pexpr | CALL pexpr | DJNZ pexpr
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1191-L1207
boriel/zxbasic
asmparse.py
p_rst
def p_rst(p): """ asm : RST expr """ val = p[2].eval() if val not in (0, 8, 16, 24, 32, 40, 48, 56): error(p.lineno(1), 'Invalid RST number %i' % val) p[0] = None return p[0] = Asm(p.lineno(1), 'RST %XH' % val)
python
def p_rst(p): """ asm : RST expr """ val = p[2].eval() if val not in (0, 8, 16, 24, 32, 40, 48, 56): error(p.lineno(1), 'Invalid RST number %i' % val) p[0] = None return p[0] = Asm(p.lineno(1), 'RST %XH' % val)
asm : RST expr
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1210-L1220
boriel/zxbasic
asmparse.py
p_im
def p_im(p): """ asm : IM expr """ val = p[2].eval() if val not in (0, 1, 2): error(p.lineno(1), 'Invalid IM number %i' % val) p[0] = None return p[0] = Asm(p.lineno(1), 'IM %i' % val)
python
def p_im(p): """ asm : IM expr """ val = p[2].eval() if val not in (0, 1, 2): error(p.lineno(1), 'Invalid IM number %i' % val) p[0] = None return p[0] = Asm(p.lineno(1), 'IM %i' % val)
asm : IM expr
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1223-L1232
boriel/zxbasic
asmparse.py
p_expr_div_expr
def p_expr_div_expr(p): """ expr : expr BAND expr | expr BOR expr | expr BXOR expr | expr PLUS expr | expr MINUS expr | expr MUL expr | expr DIV expr | expr MOD expr | expr POW expr | expr LSHIFT exp...
python
def p_expr_div_expr(p): """ expr : expr BAND expr | expr BOR expr | expr BXOR expr | expr PLUS expr | expr MINUS expr | expr MUL expr | expr DIV expr | expr MOD expr | expr POW expr | expr LSHIFT exp...
expr : expr BAND expr | expr BOR expr | expr BXOR expr | expr PLUS expr | expr MINUS expr | expr MUL expr | expr DIV expr | expr MOD expr | expr POW expr | expr LSHIFT expr | expr RSHIFT exp...
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1301-L1347
boriel/zxbasic
asmparse.py
p_expr_int
def p_expr_int(p): """ expr : INTEGER """ p[0] = Expr.makenode(Container(int(p[1]), p.lineno(1)))
python
def p_expr_int(p): """ expr : INTEGER """ p[0] = Expr.makenode(Container(int(p[1]), p.lineno(1)))
expr : INTEGER
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1362-L1365
boriel/zxbasic
asmparse.py
p_expr_label
def p_expr_label(p): """ expr : ID """ p[0] = Expr.makenode(Container(MEMORY.get_label(p[1], p.lineno(1)), p.lineno(1)))
python
def p_expr_label(p): """ expr : ID """ p[0] = Expr.makenode(Container(MEMORY.get_label(p[1], p.lineno(1)), p.lineno(1)))
expr : ID
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1368-L1371
boriel/zxbasic
asmparse.py
p_expr_addr
def p_expr_addr(p): """ expr : ADDR """ # The current instruction address p[0] = Expr.makenode(Container(MEMORY.org, p.lineno(1)))
python
def p_expr_addr(p): """ expr : ADDR """ # The current instruction address p[0] = Expr.makenode(Container(MEMORY.org, p.lineno(1)))
expr : ADDR
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1380-L1384
boriel/zxbasic
asmparse.py
p_preprocessor_line_line
def p_preprocessor_line_line(p): """ preproc_line : _LINE INTEGER """ p.lexer.lineno = int(p[2]) + p.lexer.lineno - p.lineno(2)
python
def p_preprocessor_line_line(p): """ preproc_line : _LINE INTEGER """ p.lexer.lineno = int(p[2]) + p.lexer.lineno - p.lineno(2)
preproc_line : _LINE INTEGER
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1394-L1397
boriel/zxbasic
asmparse.py
p_preprocessor_line_line_file
def p_preprocessor_line_line_file(p): """ preproc_line : _LINE INTEGER STRING """ p.lexer.lineno = int(p[2]) + p.lexer.lineno - p.lineno(3) - 1 gl.FILENAME = p[3]
python
def p_preprocessor_line_line_file(p): """ preproc_line : _LINE INTEGER STRING """ p.lexer.lineno = int(p[2]) + p.lexer.lineno - p.lineno(3) - 1 gl.FILENAME = p[3]
preproc_line : _LINE INTEGER STRING
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1400-L1404
boriel/zxbasic
asmparse.py
assemble
def assemble(input_): """ Assembles input string, and leave the result in the MEMORY global object """ global MEMORY if MEMORY is None: MEMORY = Memory() parser.parse(input_, lexer=LEXER, debug=OPTIONS.Debug.value > 2) if len(MEMORY.scopes): error(MEMORY.scopes[-1], 'Missin...
python
def assemble(input_): """ Assembles input string, and leave the result in the MEMORY global object """ global MEMORY if MEMORY is None: MEMORY = Memory() parser.parse(input_, lexer=LEXER, debug=OPTIONS.Debug.value > 2) if len(MEMORY.scopes): error(MEMORY.scopes[-1], 'Missin...
Assembles input string, and leave the result in the MEMORY global object
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1426-L1439
boriel/zxbasic
asmparse.py
generate_binary
def generate_binary(outputfname, format_, progname='', binary_files=None, headless_binary_files=None): """ Outputs the memory binary to the output filename using one of the given formats: tap, tzx or bin """ global AUTORUN_ADDR org, binary = MEMORY.dump() if gl.has_errors: return ...
python
def generate_binary(outputfname, format_, progname='', binary_files=None, headless_binary_files=None): """ Outputs the memory binary to the output filename using one of the given formats: tap, tzx or bin """ global AUTORUN_ADDR org, binary = MEMORY.dump() if gl.has_errors: return ...
Outputs the memory binary to the output filename using one of the given formats: tap, tzx or bin
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1442-L1504
boriel/zxbasic
asmparse.py
main
def main(argv): """ This is a test and will assemble the file in argv[0] """ init() if OPTIONS.StdErrFileName.value: OPTIONS.stderr.value = open('wt', OPTIONS.StdErrFileName.value) asmlex.FILENAME = OPTIONS.inputFileName.value = argv[0] input_ = open(OPTIONS.inputFileName.value, 'rt')....
python
def main(argv): """ This is a test and will assemble the file in argv[0] """ init() if OPTIONS.StdErrFileName.value: OPTIONS.stderr.value = open('wt', OPTIONS.StdErrFileName.value) asmlex.FILENAME = OPTIONS.inputFileName.value = argv[0] input_ = open(OPTIONS.inputFileName.value, 'rt')....
This is a test and will assemble the file in argv[0]
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1507-L1518
boriel/zxbasic
asmparse.py
Asm.bytes
def bytes(self): """ Returns opcodes """ if self.asm not in ('DEFB', 'DEFS', 'DEFW'): if self.pending: tmp = self.arg # Saves current arg temporarily self.arg = tuple([0] * self.arg_num) result = super(Asm, self).bytes() ...
python
def bytes(self): """ Returns opcodes """ if self.asm not in ('DEFB', 'DEFS', 'DEFW'): if self.pending: tmp = self.arg # Saves current arg temporarily self.arg = tuple([0] * self.arg_num) result = super(Asm, self).bytes() ...
Returns opcodes
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L118-L157
boriel/zxbasic
asmparse.py
Asm.argval
def argval(self): """ Solve args values or raise errors if not defined yet """ if gl.has_errors: return [None] if self.asm in ('DEFB', 'DEFS', 'DEFW'): return tuple([x.eval() if isinstance(x, Expr) else x for x in self.arg]) self.arg = tuple([x i...
python
def argval(self): """ Solve args values or raise errors if not defined yet """ if gl.has_errors: return [None] if self.asm in ('DEFB', 'DEFS', 'DEFW'): return tuple([x.eval() if isinstance(x, Expr) else x for x in self.arg]) self.arg = tuple([x i...
Solve args values or raise errors if not defined yet
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L159-L178
boriel/zxbasic
asmparse.py
Expr.eval
def eval(self): """ Recursively evals the node. Exits with an error if not resolved. """ Expr.ignore = False result = self.try_eval() Expr.ignore = True return result
python
def eval(self): """ Recursively evals the node. Exits with an error if not resolved. """ Expr.ignore = False result = self.try_eval() Expr.ignore = True return result
Recursively evals the node. Exits with an error if not resolved.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L244-L252
boriel/zxbasic
asmparse.py
Expr.try_eval
def try_eval(self): """ Recursively evals the node. Returns None if it is still unresolved. """ item = self.symbol.item if isinstance(item, int): return item if isinstance(item, Label): if item.defined: if isinstance(item.value, E...
python
def try_eval(self): """ Recursively evals the node. Returns None if it is still unresolved. """ item = self.symbol.item if isinstance(item, int): return item if isinstance(item, Label): if item.defined: if isinstance(item.value, E...
Recursively evals the node. Returns None if it is still unresolved.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L254-L297
boriel/zxbasic
asmparse.py
Label.define
def define(self, value, lineno, namespace=None): """ Defines label value. It can be anything. Even an AST """ if self.defined: error(lineno, "label '%s' already defined at line %i" % (self.name, self.lineno)) self.value = value self.lineno = lineno self.names...
python
def define(self, value, lineno, namespace=None): """ Defines label value. It can be anything. Even an AST """ if self.defined: error(lineno, "label '%s' already defined at line %i" % (self.name, self.lineno)) self.value = value self.lineno = lineno self.names...
Defines label value. It can be anything. Even an AST
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L329-L337
boriel/zxbasic
asmparse.py
Label.resolve
def resolve(self, lineno): """ Evaluates label value. Exits with error (unresolved) if value is none """ if not self.defined: error(lineno, "Undeclared label '%s'" % self.name) if isinstance(self.value, Expr): return self.value.eval() return self.value
python
def resolve(self, lineno): """ Evaluates label value. Exits with error (unresolved) if value is none """ if not self.defined: error(lineno, "Undeclared label '%s'" % self.name) if isinstance(self.value, Expr): return self.value.eval() return self.value
Evaluates label value. Exits with error (unresolved) if value is none
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L339-L348
boriel/zxbasic
asmparse.py
Memory.enter_proc
def enter_proc(self, lineno): """ Enters (pushes) a new context """ self.local_labels.append({}) # Add a new context self.scopes.append(lineno) __DEBUG__('Entering scope level %i at line %i' % (len(self.scopes), lineno))
python
def enter_proc(self, lineno): """ Enters (pushes) a new context """ self.local_labels.append({}) # Add a new context self.scopes.append(lineno) __DEBUG__('Entering scope level %i at line %i' % (len(self.scopes), lineno))
Enters (pushes) a new context
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L370-L375
boriel/zxbasic
asmparse.py
Memory.set_org
def set_org(self, value, lineno): """ Sets a new ORG value """ if value < 0 or value > MAX_MEM: error(lineno, "Memory ORG out of range [0 .. 65535]. Current value: %i" % value) self.index = self.ORG = value
python
def set_org(self, value, lineno): """ Sets a new ORG value """ if value < 0 or value > MAX_MEM: error(lineno, "Memory ORG out of range [0 .. 65535]. Current value: %i" % value) self.index = self.ORG = value
Sets a new ORG value
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L377-L383
boriel/zxbasic
asmparse.py
Memory.id_name
def id_name(label, namespace=None): """ Given a name and a namespace, resolves returns the name as namespace + '.' + name. If namespace is none, the current NAMESPACE is used """ if not label.startswith(DOT): if namespace is None: namespace = NAMESPACE...
python
def id_name(label, namespace=None): """ Given a name and a namespace, resolves returns the name as namespace + '.' + name. If namespace is none, the current NAMESPACE is used """ if not label.startswith(DOT): if namespace is None: namespace = NAMESPACE...
Given a name and a namespace, resolves returns the name as namespace + '.' + name. If namespace is none, the current NAMESPACE is used
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L386-L400
boriel/zxbasic
asmparse.py
Memory.__set_byte
def __set_byte(self, byte, lineno): """ Sets a byte at the current location, and increments org in one. Raises an error if org > MAX_MEMORY """ if byte < 0 or byte > 255: error(lineno, 'Invalid byte value %i' % byte) self.memory_bytes[self.org] = byte self.in...
python
def __set_byte(self, byte, lineno): """ Sets a byte at the current location, and increments org in one. Raises an error if org > MAX_MEMORY """ if byte < 0 or byte > 255: error(lineno, 'Invalid byte value %i' % byte) self.memory_bytes[self.org] = byte self.in...
Sets a byte at the current location, and increments org in one. Raises an error if org > MAX_MEMORY
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L408-L416
boriel/zxbasic
asmparse.py
Memory.exit_proc
def exit_proc(self, lineno): """ Exits current procedure. Local labels are transferred to global scope unless they have been marked as local ones. Raises an error if no current local context (stack underflow) """ __DEBUG__('Exiting current scope from lineno %i' % lineno) ...
python
def exit_proc(self, lineno): """ Exits current procedure. Local labels are transferred to global scope unless they have been marked as local ones. Raises an error if no current local context (stack underflow) """ __DEBUG__('Exiting current scope from lineno %i' % lineno) ...
Exits current procedure. Local labels are transferred to global scope unless they have been marked as local ones. Raises an error if no current local context (stack underflow)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L418-L447
boriel/zxbasic
asmparse.py
Memory.add_instruction
def add_instruction(self, instr): """ This will insert an asm instruction at the current memory position in a t-uple as (mnemonic, params). It will also insert the opcodes at the memory_bytes """ if gl.has_errors: return __DEBUG__('%04Xh [%04Xh] ASM: %s' % (...
python
def add_instruction(self, instr): """ This will insert an asm instruction at the current memory position in a t-uple as (mnemonic, params). It will also insert the opcodes at the memory_bytes """ if gl.has_errors: return __DEBUG__('%04Xh [%04Xh] ASM: %s' % (...
This will insert an asm instruction at the current memory position in a t-uple as (mnemonic, params). It will also insert the opcodes at the memory_bytes
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L454-L468
boriel/zxbasic
asmparse.py
Memory.dump
def dump(self): """ Returns a tuple containing code ORG, and a list of OUTPUT """ org = min(self.memory_bytes.keys()) # Org is the lowest one OUTPUT = [] align = [] for i in range(org, max(self.memory_bytes.keys()) + 1): if gl.has_errors: ret...
python
def dump(self): """ Returns a tuple containing code ORG, and a list of OUTPUT """ org = min(self.memory_bytes.keys()) # Org is the lowest one OUTPUT = [] align = [] for i in range(org, max(self.memory_bytes.keys()) + 1): if gl.has_errors: ret...
Returns a tuple containing code ORG, and a list of OUTPUT
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L470-L507
boriel/zxbasic
asmparse.py
Memory.declare_label
def declare_label(self, label, lineno, value=None, local=False, namespace=None): """ Sets a label with the given value or with the current address (org) if no value is passed. Exits with error if label already set, otherwise return the label object """ ex_label, namespac...
python
def declare_label(self, label, lineno, value=None, local=False, namespace=None): """ Sets a label with the given value or with the current address (org) if no value is passed. Exits with error if label already set, otherwise return the label object """ ex_label, namespac...
Sets a label with the given value or with the current address (org) if no value is passed. Exits with error if label already set, otherwise return the label object
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L509-L530
boriel/zxbasic
asmparse.py
Memory.get_label
def get_label(self, label, lineno): """ Returns a label in the current context or in the global one. If the label does not exists, creates a new one and returns it. """ global NAMESPACE ex_label, namespace = Memory.id_name(label) for i in range(len(self.local_labels) - ...
python
def get_label(self, label, lineno): """ Returns a label in the current context or in the global one. If the label does not exists, creates a new one and returns it. """ global NAMESPACE ex_label, namespace = Memory.id_name(label) for i in range(len(self.local_labels) - ...
Returns a label in the current context or in the global one. If the label does not exists, creates a new one and returns it.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L532-L548
boriel/zxbasic
asmparse.py
Memory.set_label
def set_label(self, label, lineno, local=False): """ Sets a label, lineno and local flag in the current scope (even if it exist in previous scopes). If the label exist in the current scope, changes it flags. The resulting label is returned. """ ex_label, namespace = Memo...
python
def set_label(self, label, lineno, local=False): """ Sets a label, lineno and local flag in the current scope (even if it exist in previous scopes). If the label exist in the current scope, changes it flags. The resulting label is returned. """ ex_label, namespace = Memo...
Sets a label, lineno and local flag in the current scope (even if it exist in previous scopes). If the label exist in the current scope, changes it flags. The resulting label is returned.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L550-L570
boriel/zxbasic
asmparse.py
Memory.memory_map
def memory_map(self): """ Returns a (very long) string containing a memory map hex address: label """ return '\n'.join(sorted("%04X: %s" % (x.value, x.name) for x in self.global_labels.values() if x.is_address))
python
def memory_map(self): """ Returns a (very long) string containing a memory map hex address: label """ return '\n'.join(sorted("%04X: %s" % (x.value, x.name) for x in self.global_labels.values() if x.is_address))
Returns a (very long) string containing a memory map hex address: label
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L573-L577
boriel/zxbasic
arch/zx48k/backend/__array.py
_addr
def _addr(value): ''' Common subroutine for emitting array address ''' output = [] try: indirect = False if value[0] == '*': indirect = True value = value[1:] value = int(value) & 0xFFFF if indirect: output.append('ld hl, (%s)' % str(...
python
def _addr(value): ''' Common subroutine for emitting array address ''' output = [] try: indirect = False if value[0] == '*': indirect = True value = value[1:] value = int(value) & 0xFFFF if indirect: output.append('ld hl, (%s)' % str(...
Common subroutine for emitting array address
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__array.py#L20-L56
boriel/zxbasic
arch/zx48k/backend/__array.py
_aload8
def _aload8(ins): ''' Loads an 8 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _addr(ins.quad[2]) output.append('ld a, (hl)') output.append('push af') return output
python
def _aload8(ins): ''' Loads an 8 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _addr(ins.quad[2]) output.append('ld a, (hl)') output.append('push af') return output
Loads an 8 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/__array.py#L69-L78
boriel/zxbasic
arch/zx48k/backend/__array.py
_aload16
def _aload16(ins): ''' Loads a 16 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _addr(ins.quad[2]) output.append('ld e, (hl)') output.append('inc hl') output.append('ld d, (hl)') output.append('ex de, hl') out...
python
def _aload16(ins): ''' Loads a 16 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _addr(ins.quad[2]) output.append('ld e, (hl)') output.append('inc hl') output.append('ld d, (hl)') output.append('ex de, hl') out...
Loads a 16 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/__array.py#L81-L94
boriel/zxbasic
arch/zx48k/backend/__array.py
_aload32
def _aload32(ins): ''' Load a 32 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _addr(ins.quad[2]) output.append('call __ILOAD32') output.append('push de') output.append('push hl') REQUIRES.add('iload32.asm') ...
python
def _aload32(ins): ''' Load a 32 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _addr(ins.quad[2]) output.append('call __ILOAD32') output.append('push de') output.append('push hl') REQUIRES.add('iload32.asm') ...
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/__array.py#L97-L110
boriel/zxbasic
arch/zx48k/backend/__array.py
_aloadf
def _aloadf(ins): ''' Loads a floating point value from a memory address. If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _addr(ins.quad[2]) output.append('call __LOADF') output.extend(_fpush()) REQUIRES.add('iloadf.asm') return output
python
def _aloadf(ins): ''' Loads a floating point value from a memory address. If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _addr(ins.quad[2]) output.append('call __LOADF') output.extend(_fpush()) REQUIRES.add('iloadf.asm') 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/__array.py#L113-L124
boriel/zxbasic
arch/zx48k/backend/__array.py
_aloadstr
def _aloadstr(ins): ''' Loads a string value from a memory address. ''' output = _addr(ins.quad[2]) output.append('call __ILOADSTR') output.append('push hl') REQUIRES.add('loadstr.asm') return output
python
def _aloadstr(ins): ''' Loads a string value from a memory address. ''' output = _addr(ins.quad[2]) output.append('call __ILOADSTR') output.append('push hl') REQUIRES.add('loadstr.asm') return output
Loads a string value from a memory address.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__array.py#L127-L136
boriel/zxbasic
arch/zx48k/backend/__array.py
_astore8
def _astore8(ins): ''' Stores 2º operand content into address of 1st operand. 1st operand is an array element. Dimensions are pushed into the stack. Use '*' for indirect store on 1st operand (A pointer to an array) ''' output = _addr(ins.quad[1]) op = ins.quad[2] indirect = op[0] == '*'...
python
def _astore8(ins): ''' Stores 2º operand content into address of 1st operand. 1st operand is an array element. Dimensions are pushed into the stack. Use '*' for indirect store on 1st operand (A pointer to an array) ''' output = _addr(ins.quad[1]) op = ins.quad[2] indirect = op[0] == '*'...
Stores 2º operand content into address of 1st operand. 1st operand is an array element. Dimensions are pushed into the stack. Use '*' for indirect store on 1st operand (A pointer to an array)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__array.py#L139-L186
boriel/zxbasic
arch/zx48k/backend/__array.py
_astore16
def _astore16(ins): ''' Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x Use '*' for indirect store on 1st operand. ''' output = _addr(ins.quad[1]) op = ins.quad[2] indirect = op[0] == '*' if indirect: op = op[1:] immediate = op[0] == '#' ...
python
def _astore16(ins): ''' Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x Use '*' for indirect store on 1st operand. ''' output = _addr(ins.quad[1]) op = ins.quad[2] indirect = op[0] == '*' if indirect: op = op[1:] immediate = op[0] == '#' ...
Stores 2º 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/__array.py#L189-L243
boriel/zxbasic
arch/zx48k/backend/__array.py
_astore32
def _astore32(ins): ''' Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x ''' output = _addr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False try: value = int(in...
python
def _astore32(ins): ''' Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x ''' output = _addr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False try: value = int(in...
Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__array.py#L246-L279
boriel/zxbasic
arch/zx48k/backend/__array.py
_astoref16
def _astoref16(ins): ''' Stores 2º operand content into address of 1st operand. storef16 a, x => *(&a) = x ''' output = _addr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False if indirect: outp...
python
def _astoref16(ins): ''' Stores 2º operand content into address of 1st operand. storef16 a, x => *(&a) = x ''' output = _addr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False if indirect: outp...
Stores 2º operand content into address of 1st operand. storef16 a, x => *(&a) = x
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__array.py#L282-L306
boriel/zxbasic
arch/zx48k/backend/__array.py
_astoref
def _astoref(ins): ''' Stores a floating point value into a memory address. ''' output = _addr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False if indirect: output.append('push hl') output....
python
def _astoref(ins): ''' Stores a floating point value into a memory address. ''' output = _addr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False if indirect: output.append('push hl') output....
Stores a floating point value into a memory address.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__array.py#L309-L331
boriel/zxbasic
arch/zx48k/backend/__array.py
_astorestr
def _astorestr(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 immediate strings for the 2nd parameter, starting with '#'. ''' output = _addr(ins.quad[1]) op ...
python
def _astorestr(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 immediate strings for the 2nd parameter, starting with '#'. ''' output = _addr(ins.quad[1]) op ...
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 immediate strings for the 2nd parameter, starting with '#'.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__array.py#L334-L398
boriel/zxbasic
symbols/arglist.py
SymbolARGLIST.make_node
def make_node(cls, node, *args): """ This will return a node with an argument_list. """ if node is None: node = cls() assert isinstance(node, SymbolARGUMENT) or isinstance(node, cls) if not isinstance(node, cls): return cls.make_node(None, node, *args) ...
python
def make_node(cls, node, *args): """ This will return a node with an argument_list. """ if node is None: node = cls() assert isinstance(node, SymbolARGUMENT) or isinstance(node, cls) if not isinstance(node, cls): return cls.make_node(None, node, *args) ...
This will return a node with an argument_list.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/arglist.py#L50-L65
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_32bit_oper
def _32bit_oper(op1, op2=None, reversed=False, preserveHL=False): """ Returns pop sequence for 32 bits operands 1st operand in HLDE, 2nd operand remains in the stack Now it does support operands inversion calling __SWAP32. However, if 1st operand is integer (immediate) or indirect, the stack will ...
python
def _32bit_oper(op1, op2=None, reversed=False, preserveHL=False): """ Returns pop sequence for 32 bits operands 1st operand in HLDE, 2nd operand remains in the stack Now it does support operands inversion calling __SWAP32. However, if 1st operand is integer (immediate) or indirect, the stack will ...
Returns pop sequence for 32 bits operands 1st operand in HLDE, 2nd operand remains in the stack Now it does support operands inversion calling __SWAP32. However, if 1st operand is integer (immediate) or indirect, the stack will be rearranged, so it contains a 32 bit pushed parameter value for the ...
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L32-L189
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_add32
def _add32(ins): """ Pops last 2 bytes from the stack and adds them. Then push the result onto the stack. Optimizations: * If any of the operands is ZERO, then do NOTHING: A + 0 = 0 + A = A """ op1, op2 = tuple(ins.quad[2:]) if _int_ops(op1, op2) is not None: o1, o2 = _in...
python
def _add32(ins): """ Pops last 2 bytes from the stack and adds them. Then push the result onto the stack. Optimizations: * If any of the operands is ZERO, then do NOTHING: A + 0 = 0 + A = A """ op1, op2 = tuple(ins.quad[2:]) if _int_ops(op1, op2) is not None: o1, o2 = _in...
Pops last 2 bytes from the stack and adds them. Then push the result onto the stack. Optimizations: * If any of the operands is ZERO, then do NOTHING: A + 0 = 0 + A = A
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L196-L238
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_sub32
def _sub32(ins): """ Pops last 2 dwords from the stack and subtract them. Then push the result onto the stack. NOTE: The operation is TOP[0] = TOP[-1] - TOP[0] If TOP[0] is 0, nothing is done """ op1, op2 = tuple(ins.quad[2:]) if is_int(op2): if int(op2) == 0: # A - 0 = A => Do No...
python
def _sub32(ins): """ Pops last 2 dwords from the stack and subtract them. Then push the result onto the stack. NOTE: The operation is TOP[0] = TOP[-1] - TOP[0] If TOP[0] is 0, nothing is done """ op1, op2 = tuple(ins.quad[2:]) if is_int(op2): if int(op2) == 0: # A - 0 = A => Do No...
Pops last 2 dwords from the stack and subtract them. Then push the result onto the stack. NOTE: The operation is TOP[0] = TOP[-1] - TOP[0] If TOP[0] is 0, nothing is done
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L241-L264
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_mul32
def _mul32(ins): """ Multiplies two last 32bit values on top of the stack and and returns the value on top of the stack Optimizations done: * If any operand is 1, do nothing * If any operand is 0, push 0 """ op1, op2 = tuple(ins.quad[2:]) if _int_ops(op1, op2): op1, op2...
python
def _mul32(ins): """ Multiplies two last 32bit values on top of the stack and and returns the value on top of the stack Optimizations done: * If any operand is 1, do nothing * If any operand is 0, push 0 """ op1, op2 = tuple(ins.quad[2:]) if _int_ops(op1, op2): op1, op2...
Multiplies two last 32bit values on top of the stack and and returns the value on top of the stack Optimizations done: * If any operand is 1, do nothing * If any operand is 0, push 0
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L267-L297
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_ltu32
def _ltu32(ins): """ Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit unsigned version """ op1, op2 = tuple(ins.quad[2:]) rev = op1[0] != 't' and not is_int(op1) and op2[0] == 't...
python
def _ltu32(ins): """ Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit unsigned version """ op1, op2 = tuple(ins.quad[2:]) rev = op1[0] != 't' and not is_int(op1) and op2[0] == 't...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit unsigned version
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L406-L420
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_gtu32
def _gtu32(ins): """ Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit unsigned version """ op1, op2 = tuple(ins.quad[2:]) rev = op1[0] != 't' and not is_int(op1) and op2[0] == 't...
python
def _gtu32(ins): """ Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit unsigned version """ op1, op2 = tuple(ins.quad[2:]) rev = op1[0] != 't' and not is_int(op1) and op2[0] == 't...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand > 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit unsigned version
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L439-L457
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_eq32
def _eq32(ins): """ Compares & pops top 2 operands out of the stack, and checks if the 1st operand == 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit un/signed version """ op1, op2 = tuple(ins.quad[2:]) output = _32bit_oper(op1, op2) output.append('call ...
python
def _eq32(ins): """ Compares & pops top 2 operands out of the stack, and checks if the 1st operand == 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit un/signed version """ op1, op2 = tuple(ins.quad[2:]) output = _32bit_oper(op1, op2) output.append('call ...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand == 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit un/signed version
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L552-L564
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_and32
def _and32(ins): """ Compares & pops top 2 operands out of the stack, and checks if the 1st operand AND (Logical) 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit un/signed version """ op1, op2 = tuple(ins.quad[2:]) if _int_ops(op1, op2): op1, op2 = ...
python
def _and32(ins): """ Compares & pops top 2 operands out of the stack, and checks if the 1st operand AND (Logical) 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit un/signed version """ op1, op2 = tuple(ins.quad[2:]) if _int_ops(op1, op2): op1, op2 = ...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand AND (Logical) 2nd operand (top of the stack). Pushes 0 if False, 1 if True. 32 bit un/signed version
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L646-L674
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_not32
def _not32(ins): """ Negates top (Logical NOT) of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __NOT32') output.append('push af') REQUIRES.add('not32.asm') return output
python
def _not32(ins): """ Negates top (Logical NOT) of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __NOT32') output.append('push af') REQUIRES.add('not32.asm') return output
Negates top (Logical NOT) of the stack (32 bits in DEHL)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L693-L700
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_bnot32
def _bnot32(ins): """ Negates top (Bitwise NOT) of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __BNOT32') output.append('push de') output.append('push hl') REQUIRES.add('bnot32.asm') return output
python
def _bnot32(ins): """ Negates top (Bitwise NOT) of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __BNOT32') output.append('push de') output.append('push hl') REQUIRES.add('bnot32.asm') return output
Negates top (Bitwise NOT) of the stack (32 bits in DEHL)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L703-L711
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_neg32
def _neg32(ins): """ Negates top of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __NEG32') output.append('push de') output.append('push hl') REQUIRES.add('neg32.asm') return output
python
def _neg32(ins): """ Negates top of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __NEG32') output.append('push de') output.append('push hl') REQUIRES.add('neg32.asm') return output
Negates top of the stack (32 bits in DEHL)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L714-L722
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_abs32
def _abs32(ins): """ Absolute value of top of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __ABS32') output.append('push de') output.append('push hl') REQUIRES.add('abs32.asm') return output
python
def _abs32(ins): """ Absolute value of top of the stack (32 bits in DEHL) """ output = _32bit_oper(ins.quad[2]) output.append('call __ABS32') output.append('push de') output.append('push hl') REQUIRES.add('abs32.asm') return output
Absolute value of top of the stack (32 bits in DEHL)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L725-L733
boriel/zxbasic
arch/zx48k/backend/__32bit.py
_shl32
def _shl32(ins): """ Logical Left shift 32bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd operand is 0, do nothing """ op1, op2 = tuple(ins.quad[2:]) if is_int(op2): output = _32bit_oper(op1) if int(op2) == 0: outpu...
python
def _shl32(ins): """ Logical Left shift 32bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd operand is 0, do nothing """ op1, op2 = tuple(ins.quad[2:]) if is_int(op2): output = _32bit_oper(op1) if int(op2) == 0: outpu...
Logical Left shift 32bit unsigned integers. The result is pushed onto the stack. Optimizations: * If 2nd operand is 0, do nothing
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__32bit.py#L826-L868
boriel/zxbasic
arch/zx48k/backend/__float.py
_float_oper
def _float_oper(op1, op2=None): ''' Returns pop sequence for floating point operands 1st operand in A DE BC, 2nd operand remains in the stack Unlike 8bit and 16bit version, this does not supports operands inversion. Since many of the instructions are implemented as functions, they must support this...
python
def _float_oper(op1, op2=None): ''' Returns pop sequence for floating point operands 1st operand in A DE BC, 2nd operand remains in the stack Unlike 8bit and 16bit version, this does not supports operands inversion. Since many of the instructions are implemented as functions, they must support this...
Returns pop sequence for floating point operands 1st operand in A DE BC, 2nd operand remains in the stack Unlike 8bit and 16bit version, this does not supports operands inversion. Since many of the instructions are implemented as functions, they must support this. However, if 1st operand is a numb...
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__float.py#L50-L157
boriel/zxbasic
arch/zx48k/backend/__float.py
_addf
def _addf(ins): ''' Adds 2 float values. The result is pushed onto the stack. ''' op1, op2 = tuple(ins.quad[2:]) if _f_ops(op1, op2) is not None: opa, opb = _f_ops(op1, op2) if opb == 0: # A + 0 => A output = _float_oper(opa) output.extend(_fpush()) ...
python
def _addf(ins): ''' Adds 2 float values. The result is pushed onto the stack. ''' op1, op2 = tuple(ins.quad[2:]) if _f_ops(op1, op2) is not None: opa, opb = _f_ops(op1, op2) if opb == 0: # A + 0 => A output = _float_oper(opa) output.extend(_fpush()) ...
Adds 2 float values. The result is pushed onto the stack.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__float.py#L164-L180
boriel/zxbasic
arch/zx48k/backend/__float.py
_divf
def _divf(ins): ''' Divides 2 float values. The result is pushed onto the stack. ''' op1, op2 = tuple(ins.quad[2:]) if is_float(op2) and float(op2) == 1: # Nothing to do. A / 1 = A output = _float_oper(op1) output.extend(_fpush()) return output output = _float_oper(op1, op...
python
def _divf(ins): ''' Divides 2 float values. The result is pushed onto the stack. ''' op1, op2 = tuple(ins.quad[2:]) if is_float(op2) and float(op2) == 1: # Nothing to do. A / 1 = A output = _float_oper(op1) output.extend(_fpush()) return output output = _float_oper(op1, op...
Divides 2 float values. The result is pushed onto the stack.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__float.py#L219-L233
boriel/zxbasic
arch/zx48k/backend/__float.py
_modf
def _modf(ins): ''' Reminder of div. 2 float values. The result is pushed onto the stack. ''' op1, op2 = tuple(ins.quad[2:]) output = _float_oper(op1, op2) output.append('call __MODF') output.extend(_fpush()) REQUIRES.add('modf.asm') return output
python
def _modf(ins): ''' Reminder of div. 2 float values. The result is pushed onto the stack. ''' op1, op2 = tuple(ins.quad[2:]) output = _float_oper(op1, op2) output.append('call __MODF') output.extend(_fpush()) REQUIRES.add('modf.asm') return output
Reminder of div. 2 float values. The result is pushed onto the stack.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__float.py#L236-L244
boriel/zxbasic
arch/zx48k/backend/__float.py
_ltf
def _ltf(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. Floating Point version ''' op1, op2 = tuple(ins.quad[2:]) output = _float_oper(op1, op2) output.append('call __LT...
python
def _ltf(ins): ''' Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. Floating Point version ''' op1, op2 = tuple(ins.quad[2:]) output = _float_oper(op1, op2) output.append('call __LT...
Compares & pops top 2 operands out of the stack, and checks if the 1st operand < 2nd operand (top of the stack). Pushes 0 if False, 1 if True. Floating Point version
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__float.py#L264-L276
boriel/zxbasic
arch/zx48k/backend/__float.py
_notf
def _notf(ins): ''' Negates top of the stack (48 bits) ''' output = _float_oper(ins.quad[2]) output.append('call __NOTF') output.append('push af') REQUIRES.add('notf.asm') return output
python
def _notf(ins): ''' Negates top of the stack (48 bits) ''' output = _float_oper(ins.quad[2]) output.append('call __NOTF') output.append('push af') REQUIRES.add('notf.asm') return output
Negates top of the stack (48 bits)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__float.py#L399-L406
boriel/zxbasic
arch/zx48k/backend/__float.py
_negf
def _negf(ins): ''' Changes sign of top of the stack (48 bits) ''' output = _float_oper(ins.quad[2]) output.append('call __NEGF') output.extend(_fpush()) REQUIRES.add('negf.asm') return output
python
def _negf(ins): ''' Changes sign of top of the stack (48 bits) ''' output = _float_oper(ins.quad[2]) output.append('call __NEGF') output.extend(_fpush()) REQUIRES.add('negf.asm') return output
Changes sign of top of the stack (48 bits)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__float.py#L409-L416
boriel/zxbasic
arch/zx48k/backend/__float.py
_absf
def _absf(ins): ''' Absolute value of top of the stack (48 bits) ''' output = _float_oper(ins.quad[2]) output.append('res 7, e') # Just resets the sign bit! output.extend(_fpush()) return output
python
def _absf(ins): ''' Absolute value of top of the stack (48 bits) ''' output = _float_oper(ins.quad[2]) output.append('res 7, e') # Just resets the sign bit! output.extend(_fpush()) return output
Absolute value of top of the stack (48 bits)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__float.py#L419-L425
boriel/zxbasic
asmlex.py
get_uniques
def get_uniques(l): """ Returns a list with no repeated elements. """ result = [] for i in l: if i not in result: result.append(i) return result
python
def get_uniques(l): """ Returns a list with no repeated elements. """ result = [] for i in l: if i not in result: result.append(i) return result
Returns a list with no repeated elements.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L161-L170
boriel/zxbasic
asmlex.py
Lexer.t_CHAR
def t_CHAR(self, t): r"'.'" # A single char t.value = ord(t.value[1]) t.type = 'INTEGER' return t
python
def t_CHAR(self, t): r"'.'" # A single char t.value = ord(t.value[1]) t.type = 'INTEGER' return t
r"'.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L205-L210
boriel/zxbasic
asmlex.py
Lexer.t_BIN
def t_BIN(self, t): r'(%[01]+)|([01]+[bB])' # A Binary integer # Note 00B is a 0 binary, but # 00Bh is a 12 in hex. So this pattern must come # after HEXA if t.value[0] == '%': t.value = t.value[1:] # Remove initial % else: t.value = t.value[:-1...
python
def t_BIN(self, t): r'(%[01]+)|([01]+[bB])' # A Binary integer # Note 00B is a 0 binary, but # 00Bh is a 12 in hex. So this pattern must come # after HEXA if t.value[0] == '%': t.value = t.value[1:] # Remove initial % else: t.value = t.value[:-1...
r'(%[01]+)|([01]+[bB])
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L226-L239
boriel/zxbasic
asmlex.py
Lexer.t_INITIAL_ID
def t_INITIAL_ID(self, t): r'[._a-zA-Z][._a-zA-Z0-9]*([ \t]*[:])?' # Any identifier tmp = t.value # Saves original value if tmp[-1] == ':': t.type = 'LABEL' t.value = tmp[:-1].strip() return t t.value = tmp.upper() # Convert it to uppercase, since...
python
def t_INITIAL_ID(self, t): r'[._a-zA-Z][._a-zA-Z0-9]*([ \t]*[:])?' # Any identifier tmp = t.value # Saves original value if tmp[-1] == ':': t.type = 'LABEL' t.value = tmp[:-1].strip() return t t.value = tmp.upper() # Convert it to uppercase, since...
r'[._a-zA-Z][._a-zA-Z0-9]*([ \t]*[:])?
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L246-L278
boriel/zxbasic
asmlex.py
Lexer.t_preproc_ID
def t_preproc_ID(self, t): r'[_a-zA-Z][_a-zA-Z0-9]*' # preprocessor directives t.type = preprocessor.get(t.value.lower(), 'ID') return t
python
def t_preproc_ID(self, t): r'[_a-zA-Z][_a-zA-Z0-9]*' # preprocessor directives t.type = preprocessor.get(t.value.lower(), 'ID') return t
r'[_a-zA-Z][_a-zA-Z0-9]*
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L280-L283
boriel/zxbasic
asmlex.py
Lexer.t_LP
def t_LP(self, t): r'[[(]' if t.value != '[' and OPTIONS.bracket.value: t.type = 'LPP' return t
python
def t_LP(self, t): r'[[(]' if t.value != '[' and OPTIONS.bracket.value: t.type = 'LPP' return t
r'[[(]
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L293-L297
boriel/zxbasic
asmlex.py
Lexer.t_RP
def t_RP(self, t): r'[])]' if t.value != ']' and OPTIONS.bracket.value: t.type = 'RPP' return t
python
def t_RP(self, t): r'[])]' if t.value != ']' and OPTIONS.bracket.value: t.type = 'RPP' return t
r'[])]
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L299-L303
boriel/zxbasic
asmlex.py
Lexer.t_INITIAL_preproc_NEWLINE
def t_INITIAL_preproc_NEWLINE(self, t): r'\r?\n' t.lexer.lineno += 1 t.lexer.begin('INITIAL') return t
python
def t_INITIAL_preproc_NEWLINE(self, t): r'\r?\n' t.lexer.lineno += 1 t.lexer.begin('INITIAL') return t
r'\r?\n
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L371-L375
boriel/zxbasic
asmlex.py
Lexer.t_INITIAL_SHARP
def t_INITIAL_SHARP(self, t): r'\#' if self.find_column(t) == 1: t.lexer.begin('preproc') else: self.t_INITIAL_preproc_error(t)
python
def t_INITIAL_SHARP(self, t): r'\#' if self.find_column(t) == 1: t.lexer.begin('preproc') else: self.t_INITIAL_preproc_error(t)
r'\#
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmlex.py#L377-L383
boriel/zxbasic
asmlex.py
Lexer.input
def input(self, str): """ Defines input string, removing current lexer. """ self.input_data = str self.lex = lex.lex(object=self) self.lex.input(self.input_data)
python
def input(self, str): """ Defines input string, removing current lexer. """ 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/asmlex.py#L402-L407
boriel/zxbasic
symbols/argument.py
SymbolARGUMENT.typecast
def typecast(self, type_): """ Test type casting to the argument expression. On success changes the node value to the new typecast, and returns True. On failure, returns False, and the node value is set to None. """ self.value = SymbolTYPECAST.make_node(type_, self.value, self.li...
python
def typecast(self, type_): """ Test type casting to the argument expression. On success changes the node value to the new typecast, and returns True. On failure, returns False, and the node value is set to None. """ self.value = SymbolTYPECAST.make_node(type_, self.value, self.li...
Test type casting to the argument expression. On success changes the node value to the new typecast, and returns True. On failure, returns False, and the node value is set to None.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/argument.py#L88-L94
boriel/zxbasic
arch/zx48k/backend/__parray.py
_paddr
def _paddr(offset): ''' Generic array address parameter loading. Emmits output code for setting IX at the right location. bytes = Number of bytes to load: 1 => 8 bit value 2 => 16 bit value / string 4 => 32 bit value / f16 value 5 => 40 bit value ''' output = [] ...
python
def _paddr(offset): ''' Generic array address parameter loading. Emmits output code for setting IX at the right location. bytes = Number of bytes to load: 1 => 8 bit value 2 => 16 bit value / string 4 => 32 bit value / f16 value 5 => 40 bit value ''' output = [] ...
Generic array address parameter loading. Emmits output code for setting IX at the right location. bytes = Number of bytes to load: 1 => 8 bit value 2 => 16 bit value / string 4 => 32 bit value / f16 value 5 => 40 bit value
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__parray.py#L18-L50
boriel/zxbasic
arch/zx48k/backend/__parray.py
_paload8
def _paload8(ins): ''' Loads an 8 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _paddr(ins.quad[2]) output.append('ld a, (hl)') output.append('push af') return output
python
def _paload8(ins): ''' Loads an 8 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _paddr(ins.quad[2]) output.append('ld a, (hl)') output.append('push af') return output
Loads an 8 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/__parray.py#L62-L71
boriel/zxbasic
arch/zx48k/backend/__parray.py
_paload16
def _paload16(ins): ''' Loads a 16 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _paddr(ins.quad[2]) output.append('ld e, (hl)') output.append('inc hl') output.append('ld d, (hl)') output.append('ex de, hl') o...
python
def _paload16(ins): ''' Loads a 16 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _paddr(ins.quad[2]) output.append('ld e, (hl)') output.append('inc hl') output.append('ld d, (hl)') output.append('ex de, hl') o...
Loads a 16 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/__parray.py#L74-L87
boriel/zxbasic
arch/zx48k/backend/__parray.py
_paload32
def _paload32(ins): ''' Load a 32 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _paddr(ins.quad[2]) output.append('call __ILOAD32') output.append('push de') output.append('push hl') REQUIRES.add('iload32.asm') ...
python
def _paload32(ins): ''' Load a 32 bit value from a memory address If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _paddr(ins.quad[2]) output.append('call __ILOAD32') output.append('push de') output.append('push hl') REQUIRES.add('iload32.asm') ...
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/__parray.py#L90-L103
boriel/zxbasic
arch/zx48k/backend/__parray.py
_paloadf
def _paloadf(ins): ''' Loads a floating point value from a memory address. If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _paddr(ins.quad[2]) output.append('call __ILOADF') output.extend(_fpush()) REQUIRES.add('iloadf.asm') return output
python
def _paloadf(ins): ''' Loads a floating point value from a memory address. If 2nd arg. start with '*', it is always treated as an indirect value. ''' output = _paddr(ins.quad[2]) output.append('call __ILOADF') output.extend(_fpush()) REQUIRES.add('iloadf.asm') 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/__parray.py#L106-L117
boriel/zxbasic
arch/zx48k/backend/__parray.py
_paloadstr
def _paloadstr(ins): ''' Loads a string value from a memory address. ''' output = _paddr(ins.quad[2]) output.append('call __ILOADSTR') output.append('push hl') REQUIRES.add('loadstr.asm') return output
python
def _paloadstr(ins): ''' Loads a string value from a memory address. ''' output = _paddr(ins.quad[2]) output.append('call __ILOADSTR') output.append('push hl') REQUIRES.add('loadstr.asm') return output
Loads a string value from a memory address.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__parray.py#L120-L129
boriel/zxbasic
arch/zx48k/backend/__parray.py
_pastore8
def _pastore8(ins): ''' Stores 2º operand content into address of 1st operand. 1st operand is an array element. Dimensions are pushed into the stack. Use '*' for indirect store on 1st operand (A pointer to an array) ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*'...
python
def _pastore8(ins): ''' Stores 2º operand content into address of 1st operand. 1st operand is an array element. Dimensions are pushed into the stack. Use '*' for indirect store on 1st operand (A pointer to an array) ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*'...
Stores 2º operand content into address of 1st operand. 1st operand is an array element. Dimensions are pushed into the stack. Use '*' for indirect store on 1st operand (A pointer to an array)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__parray.py#L132-L159
boriel/zxbasic
arch/zx48k/backend/__parray.py
_pastore16
def _pastore16(ins): ''' Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x Use '*' for indirect store on 1st operand. ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: ...
python
def _pastore16(ins): ''' Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x Use '*' for indirect store on 1st operand. ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: ...
Stores 2º 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/__parray.py#L162-L190
boriel/zxbasic
arch/zx48k/backend/__parray.py
_pastore32
def _pastore32(ins): ''' Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False try: value = int(...
python
def _pastore32(ins): ''' Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False try: value = int(...
Stores 2º operand content into address of 1st operand. store16 a, x => *(&a) = x
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__parray.py#L193-L226
boriel/zxbasic
arch/zx48k/backend/__parray.py
_pastoref16
def _pastoref16(ins): ''' Stores 2º operand content into address of 1st operand. storef16 a, x => *(&a) = x ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False try: if indirec...
python
def _pastoref16(ins): ''' Stores 2º operand content into address of 1st operand. storef16 a, x => *(&a) = x ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False try: if indirec...
Stores 2º operand content into address of 1st operand. storef16 a, x => *(&a) = x
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__parray.py#L229-L263
boriel/zxbasic
arch/zx48k/backend/__parray.py
_pastoref
def _pastoref(ins): ''' Stores a floating point value into a memory address. ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False try: if indirect: value = int(value) & ...
python
def _pastoref(ins): ''' Stores a floating point value into a memory address. ''' output = _paddr(ins.quad[1]) value = ins.quad[2] if value[0] == '*': value = value[1:] indirect = True else: indirect = False try: if indirect: value = int(value) & ...
Stores a floating point value into a memory address.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__parray.py#L266-L305
boriel/zxbasic
arch/zx48k/backend/__parray.py
_pastorestr
def _pastorestr(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 '#'. ''' output = _paddr(ins.quad[1]) t...
python
def _pastorestr(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 '#'. ''' output = _paddr(ins.quad[1]) t...
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 '#'.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__parray.py#L308-L354
boriel/zxbasic
asm.py
num2bytes
def num2bytes(x, bytes): """ Returns x converted to a little-endian t-uple of bytes. E.g. num2bytes(255, 4) = (255, 0, 0, 0) """ if not isinstance(x, int): # If it is another "thing", just return ZEROs return tuple([0] * bytes) x = x & ((2 << (bytes * 8)) - 1) # mask the initial value ...
python
def num2bytes(x, bytes): """ Returns x converted to a little-endian t-uple of bytes. E.g. num2bytes(255, 4) = (255, 0, 0, 0) """ if not isinstance(x, int): # If it is another "thing", just return ZEROs return tuple([0] * bytes) x = x & ((2 << (bytes * 8)) - 1) # mask the initial value ...
Returns x converted to a little-endian t-uple of bytes. E.g. num2bytes(255, 4) = (255, 0, 0, 0)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asm.py#L23-L37
boriel/zxbasic
asm.py
AsmInstruction.argval
def argval(self): """ Returns the value of the arg (if any) or None. If the arg. is not an integer, an error be triggered. """ if self.arg is None or any(x is None for x in self.arg): return None for x in self.arg: if not isinstance(x, int): ...
python
def argval(self): """ Returns the value of the arg (if any) or None. If the arg. is not an integer, an error be triggered. """ if self.arg is None or any(x is None for x in self.arg): return None for x in self.arg: if not isinstance(x, int): ...
Returns the value of the arg (if any) or None. If the arg. is not an integer, an error be triggered.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asm.py#L115-L126
boriel/zxbasic
asm.py
AsmInstruction.bytes
def bytes(self): """ Returns a t-uple with instruction bytes (integers) """ result = [] op = self.opcode.split(' ') argi = 0 while op: q = op.pop(0) if q == 'XX': for k in range(self.argbytes[argi] - 1): op.pop...
python
def bytes(self): """ Returns a t-uple with instruction bytes (integers) """ result = [] op = self.opcode.split(' ') argi = 0 while op: q = op.pop(0) if q == 'XX': for k in range(self.argbytes[argi] - 1): op.pop...
Returns a t-uple with instruction bytes (integers)
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asm.py#L128-L150
boriel/zxbasic
api/errmsg.py
syntax_error
def syntax_error(lineno, msg): """ Generic syntax error routine """ if global_.has_errors > OPTIONS.max_syntax_errors.value: msg = 'Too many errors. Giving up!' msg = "%s:%i: %s" % (global_.FILENAME, lineno, msg) msg_output(msg) if global_.has_errors > OPTIONS.max_syntax_errors.value: ...
python
def syntax_error(lineno, msg): """ Generic syntax error routine """ if global_.has_errors > OPTIONS.max_syntax_errors.value: msg = 'Too many errors. Giving up!' msg = "%s:%i: %s" % (global_.FILENAME, lineno, msg) msg_output(msg) if global_.has_errors > OPTIONS.max_syntax_errors.value: ...
Generic syntax error routine
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/errmsg.py#L28-L40
boriel/zxbasic
api/errmsg.py
warning
def warning(lineno, msg): """ Generic warning error routine """ msg = "%s:%i: warning: %s" % (global_.FILENAME, lineno, msg) msg_output(msg) global_.has_warnings += 1
python
def warning(lineno, msg): """ Generic warning error routine """ msg = "%s:%i: warning: %s" % (global_.FILENAME, lineno, msg) msg_output(msg) global_.has_warnings += 1
Generic warning error routine
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/errmsg.py#L43-L48
boriel/zxbasic
api/errmsg.py
warning_implicit_type
def warning_implicit_type(lineno, id_, type_=None): """ Warning: Using default implicit type 'x' """ if OPTIONS.strict.value: syntax_error_undeclared_type(lineno, id_) return if type_ is None: type_ = global_.DEFAULT_TYPE warning(lineno, "Using default implicit type '%s' fo...
python
def warning_implicit_type(lineno, id_, type_=None): """ Warning: Using default implicit type 'x' """ if OPTIONS.strict.value: syntax_error_undeclared_type(lineno, id_) return if type_ is None: type_ = global_.DEFAULT_TYPE warning(lineno, "Using default implicit type '%s' fo...
Warning: Using default implicit type 'x'
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/errmsg.py#L51-L61
boriel/zxbasic
arch/zx48k/optimizer.py
oper
def oper(inst): """ Returns operands of an ASM instruction. Even "indirect" operands, like SP if RET or CALL is used. """ i = inst.strip(' \t\n').split(' ') I = i[0].lower() # Instruction i = ''.join(i[1:]) op = i.split(',') if I in {'call', 'jp', 'jr'} and len(op) > 1: op = op...
python
def oper(inst): """ Returns operands of an ASM instruction. Even "indirect" operands, like SP if RET or CALL is used. """ i = inst.strip(' \t\n').split(' ') I = i[0].lower() # Instruction i = ''.join(i[1:]) op = i.split(',') if I in {'call', 'jp', 'jr'} and len(op) > 1: op = op...
Returns operands of an ASM instruction. Even "indirect" operands, like SP if RET or CALL is used.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L190-L254
boriel/zxbasic
arch/zx48k/optimizer.py
condition
def condition(i): """ Returns the flag this instruction uses or None. E.g. 'c' for Carry, 'nz' for not-zero, etc. That is the condition required for this instruction to execute. For example: ADC A, 0 does NOT have a condition flag (it always execute) whilst RETC does. """ I = inst(i) if...
python
def condition(i): """ Returns the flag this instruction uses or None. E.g. 'c' for Carry, 'nz' for not-zero, etc. That is the condition required for this instruction to execute. For example: ADC A, 0 does NOT have a condition flag (it always execute) whilst RETC does. """ I = inst(i) if...
Returns the flag this instruction uses or None. E.g. 'c' for Carry, 'nz' for not-zero, etc. That is the condition required for this instruction to execute. For example: ADC A, 0 does NOT have a condition flag (it always execute) whilst RETC does.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L262-L283
boriel/zxbasic
arch/zx48k/optimizer.py
single_registers
def single_registers(op): """ Given a list of registers like ['a', 'bc', 'h', 'hl'] returns a set of single registers: ['a', 'b', 'c', 'h', 'l']. Non register parameters, like numbers will be ignored. """ result = set() if isinstance(op, str): op = [op] for x in op: if is_8b...
python
def single_registers(op): """ Given a list of registers like ['a', 'bc', 'h', 'hl'] returns a set of single registers: ['a', 'b', 'c', 'h', 'l']. Non register parameters, like numbers will be ignored. """ result = set() if isinstance(op, str): op = [op] for x in op: if is_8b...
Given a list of registers like ['a', 'bc', 'h', 'hl'] returns a set of single registers: ['a', 'b', 'c', 'h', 'l']. Non register parameters, like numbers will be ignored.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L286-L307
boriel/zxbasic
arch/zx48k/optimizer.py
result
def result(i): """ Returns which 8-bit registers are used by an asm instruction to return a result. """ ins = inst(i) op = oper(i) if ins in ('or', 'and') and op == ['a']: return ['f'] if ins in {'xor', 'or', 'and', 'neg', 'cpl', 'daa', 'rld', 'rrd', 'rra', 'rla', 'rrca', 'rlca'}: ...
python
def result(i): """ Returns which 8-bit registers are used by an asm instruction to return a result. """ ins = inst(i) op = oper(i) if ins in ('or', 'and') and op == ['a']: return ['f'] if ins in {'xor', 'or', 'and', 'neg', 'cpl', 'daa', 'rld', 'rrd', 'rra', 'rla', 'rrca', 'rlca'}: ...
Returns which 8-bit registers are used by an asm instruction to return a result.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L310-L350
boriel/zxbasic
arch/zx48k/optimizer.py
block_partition
def block_partition(block, i): """ Returns two blocks, as a result of partitioning the given one at i-th instruction. """ i += 1 new_block = BasicBlock(block.asm[i:]) block.mem = block.mem[:i] block.asm = block.asm[:i] block.update_labels() new_block.update_labels() new_block.go...
python
def block_partition(block, i): """ Returns two blocks, as a result of partitioning the given one at i-th instruction. """ i += 1 new_block = BasicBlock(block.asm[i:]) block.mem = block.mem[:i] block.asm = block.asm[:i] block.update_labels() new_block.update_labels() new_block.go...
Returns two blocks, as a result of partitioning the given one at i-th instruction.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L2060-L2090
boriel/zxbasic
arch/zx48k/optimizer.py
partition_block
def partition_block(block): """ If a block is not partitionable, returns a list with the same block. Otherwise, returns a list with the resulting blocks, recursively. """ result = [block] if not block.is_partitionable: return result EDP = END_PROGRAM_LABEL + ':' for i in range(len...
python
def partition_block(block): """ If a block is not partitionable, returns a list with the same block. Otherwise, returns a list with the resulting blocks, recursively. """ result = [block] if not block.is_partitionable: return result EDP = END_PROGRAM_LABEL + ':' for i in range(len...
If a block is not partitionable, returns a list with the same block. Otherwise, returns a list with the resulting blocks, recursively.
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L2093-L2154
boriel/zxbasic
arch/zx48k/optimizer.py
get_labels
def get_labels(MEMORY, basic_block): """ Traverses memory, to annotate all the labels in the global LABELS table """ for cell in MEMORY: if cell.is_label: label = cell.inst LABELS[label] = LabelInfo(label, cell.addr, basic_block)
python
def get_labels(MEMORY, basic_block): """ Traverses memory, to annotate all the labels in the global LABELS table """ for cell in MEMORY: if cell.is_label: label = cell.inst LABELS[label] = LabelInfo(label, cell.addr, basic_block)
Traverses memory, to annotate all the labels in the global LABELS table
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L2172-L2179