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_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | 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]) | [
"def",
"p_jr",
"(",
"p",
")",
":",
"p",
"[",
"4",
"]",
"=",
"Expr",
".",
"makenode",
"(",
"Container",
"(",
"'-'",
",",
"p",
".",
"lineno",
"(",
"3",
")",
")",
",",
"p",
"[",
"4",
"]",
",",
"Expr",
".",
"makenode",
"(",
"Container",
"(",
"M... | asm : JR jr_flags COMMA expr
| JR jr_flags COMMA pexpr | [
"asm",
":",
"JR",
"jr_flags",
"COMMA",
"expr",
"|",
"JR",
"jr_flags",
"COMMA",
"pexpr"
] | train | 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... | [
"def",
"p_jrjp",
"(",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"in",
"(",
"'JR'",
",",
"'DJNZ'",
")",
":",
"op",
"=",
"'N'",
"p",
"[",
"2",
"]",
"=",
"Expr",
".",
"makenode",
"(",
"Container",
"(",
"'-'",
",",
"p",
".",
"lineno",
"(",
"1",
... | asm : JP expr
| JR expr
| CALL expr
| DJNZ expr
| JP pexpr
| JR pexpr
| CALL pexpr
| DJNZ pexpr | [
"asm",
":",
"JP",
"expr",
"|",
"JR",
"expr",
"|",
"CALL",
"expr",
"|",
"DJNZ",
"expr",
"|",
"JP",
"pexpr",
"|",
"JR",
"pexpr",
"|",
"CALL",
"pexpr",
"|",
"DJNZ",
"pexpr"
] | train | 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) | [
"def",
"p_rst",
"(",
"p",
")",
":",
"val",
"=",
"p",
"[",
"2",
"]",
".",
"eval",
"(",
")",
"if",
"val",
"not",
"in",
"(",
"0",
",",
"8",
",",
"16",
",",
"24",
",",
"32",
",",
"40",
",",
"48",
",",
"56",
")",
":",
"error",
"(",
"p",
".... | asm : RST expr | [
"asm",
":",
"RST",
"expr"
] | train | 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) | [
"def",
"p_im",
"(",
"p",
")",
":",
"val",
"=",
"p",
"[",
"2",
"]",
".",
"eval",
"(",
")",
"if",
"val",
"not",
"in",
"(",
"0",
",",
"1",
",",
"2",
")",
":",
"error",
"(",
"p",
".",
"lineno",
"(",
"1",
")",
",",
"'Invalid IM number %i'",
"%",... | asm : IM expr | [
"asm",
":",
"IM",
"expr"
] | train | 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... | [
"def",
"p_expr_div_expr",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Expr",
".",
"makenode",
"(",
"Container",
"(",
"p",
"[",
"2",
"]",
",",
"p",
".",
"lineno",
"(",
"2",
")",
")",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")"
... | 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... | [
"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"... | train | 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))) | [
"def",
"p_expr_int",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Expr",
".",
"makenode",
"(",
"Container",
"(",
"int",
"(",
"p",
"[",
"1",
"]",
")",
",",
"p",
".",
"lineno",
"(",
"1",
")",
")",
")"
] | expr : INTEGER | [
"expr",
":",
"INTEGER"
] | train | 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))) | [
"def",
"p_expr_label",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Expr",
".",
"makenode",
"(",
"Container",
"(",
"MEMORY",
".",
"get_label",
"(",
"p",
"[",
"1",
"]",
",",
"p",
".",
"lineno",
"(",
"1",
")",
")",
",",
"p",
".",
"lineno",
"("... | expr : ID | [
"expr",
":",
"ID"
] | train | 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))) | [
"def",
"p_expr_addr",
"(",
"p",
")",
":",
"# The current instruction address",
"p",
"[",
"0",
"]",
"=",
"Expr",
".",
"makenode",
"(",
"Container",
"(",
"MEMORY",
".",
"org",
",",
"p",
".",
"lineno",
"(",
"1",
")",
")",
")"
] | expr : ADDR | [
"expr",
":",
"ADDR"
] | train | 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) | [
"def",
"p_preprocessor_line_line",
"(",
"p",
")",
":",
"p",
".",
"lexer",
".",
"lineno",
"=",
"int",
"(",
"p",
"[",
"2",
"]",
")",
"+",
"p",
".",
"lexer",
".",
"lineno",
"-",
"p",
".",
"lineno",
"(",
"2",
")"
] | preproc_line : _LINE INTEGER | [
"preproc_line",
":",
"_LINE",
"INTEGER"
] | train | 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] | [
"def",
"p_preprocessor_line_line_file",
"(",
"p",
")",
":",
"p",
".",
"lexer",
".",
"lineno",
"=",
"int",
"(",
"p",
"[",
"2",
"]",
")",
"+",
"p",
".",
"lexer",
".",
"lineno",
"-",
"p",
".",
"lineno",
"(",
"3",
")",
"-",
"1",
"gl",
".",
"FILENAM... | preproc_line : _LINE INTEGER STRING | [
"preproc_line",
":",
"_LINE",
"INTEGER",
"STRING"
] | train | 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... | [
"def",
"assemble",
"(",
"input_",
")",
":",
"global",
"MEMORY",
"if",
"MEMORY",
"is",
"None",
":",
"MEMORY",
"=",
"Memory",
"(",
")",
"parser",
".",
"parse",
"(",
"input_",
",",
"lexer",
"=",
"LEXER",
",",
"debug",
"=",
"OPTIONS",
".",
"Debug",
".",
... | Assembles input string, and leave the result in the
MEMORY global object | [
"Assembles",
"input",
"string",
"and",
"leave",
"the",
"result",
"in",
"the",
"MEMORY",
"global",
"object"
] | train | 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
... | [
"def",
"generate_binary",
"(",
"outputfname",
",",
"format_",
",",
"progname",
"=",
"''",
",",
"binary_files",
"=",
"None",
",",
"headless_binary_files",
"=",
"None",
")",
":",
"global",
"AUTORUN_ADDR",
"org",
",",
"binary",
"=",
"MEMORY",
".",
"dump",
"(",
... | Outputs the memory binary to the
output filename using one of the given
formats: tap, tzx or bin | [
"Outputs",
"the",
"memory",
"binary",
"to",
"the",
"output",
"filename",
"using",
"one",
"of",
"the",
"given",
"formats",
":",
"tap",
"tzx",
"or",
"bin"
] | train | 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').... | [
"def",
"main",
"(",
"argv",
")",
":",
"init",
"(",
")",
"if",
"OPTIONS",
".",
"StdErrFileName",
".",
"value",
":",
"OPTIONS",
".",
"stderr",
".",
"value",
"=",
"open",
"(",
"'wt'",
",",
"OPTIONS",
".",
"StdErrFileName",
".",
"value",
")",
"asmlex",
"... | This is a test and will assemble the file in argv[0] | [
"This",
"is",
"a",
"test",
"and",
"will",
"assemble",
"the",
"file",
"in",
"argv",
"[",
"0",
"]"
] | train | 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()
... | [
"def",
"bytes",
"(",
"self",
")",
":",
"if",
"self",
".",
"asm",
"not",
"in",
"(",
"'DEFB'",
",",
"'DEFS'",
",",
"'DEFW'",
")",
":",
"if",
"self",
".",
"pending",
":",
"tmp",
"=",
"self",
".",
"arg",
"# Saves current arg temporarily",
"self",
".",
"a... | Returns opcodes | [
"Returns",
"opcodes"
] | train | 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... | [
"def",
"argval",
"(",
"self",
")",
":",
"if",
"gl",
".",
"has_errors",
":",
"return",
"[",
"None",
"]",
"if",
"self",
".",
"asm",
"in",
"(",
"'DEFB'",
",",
"'DEFS'",
",",
"'DEFW'",
")",
":",
"return",
"tuple",
"(",
"[",
"x",
".",
"eval",
"(",
"... | Solve args values or raise errors if not
defined yet | [
"Solve",
"args",
"values",
"or",
"raise",
"errors",
"if",
"not",
"defined",
"yet"
] | train | 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 | [
"def",
"eval",
"(",
"self",
")",
":",
"Expr",
".",
"ignore",
"=",
"False",
"result",
"=",
"self",
".",
"try_eval",
"(",
")",
"Expr",
".",
"ignore",
"=",
"True",
"return",
"result"
] | Recursively evals the node. Exits with an
error if not resolved. | [
"Recursively",
"evals",
"the",
"node",
".",
"Exits",
"with",
"an",
"error",
"if",
"not",
"resolved",
"."
] | train | 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... | [
"def",
"try_eval",
"(",
"self",
")",
":",
"item",
"=",
"self",
".",
"symbol",
".",
"item",
"if",
"isinstance",
"(",
"item",
",",
"int",
")",
":",
"return",
"item",
"if",
"isinstance",
"(",
"item",
",",
"Label",
")",
":",
"if",
"item",
".",
"defined... | Recursively evals the node. Returns None
if it is still unresolved. | [
"Recursively",
"evals",
"the",
"node",
".",
"Returns",
"None",
"if",
"it",
"is",
"still",
"unresolved",
"."
] | train | 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... | [
"def",
"define",
"(",
"self",
",",
"value",
",",
"lineno",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"self",
".",
"defined",
":",
"error",
"(",
"lineno",
",",
"\"label '%s' already defined at line %i\"",
"%",
"(",
"self",
".",
"name",
",",
"self",
"... | Defines label value. It can be anything. Even an AST | [
"Defines",
"label",
"value",
".",
"It",
"can",
"be",
"anything",
".",
"Even",
"an",
"AST"
] | train | 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 | [
"def",
"resolve",
"(",
"self",
",",
"lineno",
")",
":",
"if",
"not",
"self",
".",
"defined",
":",
"error",
"(",
"lineno",
",",
"\"Undeclared label '%s'\"",
"%",
"self",
".",
"name",
")",
"if",
"isinstance",
"(",
"self",
".",
"value",
",",
"Expr",
")",
... | Evaluates label value. Exits with error (unresolved) if value is none | [
"Evaluates",
"label",
"value",
".",
"Exits",
"with",
"error",
"(",
"unresolved",
")",
"if",
"value",
"is",
"none"
] | train | 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)) | [
"def",
"enter_proc",
"(",
"self",
",",
"lineno",
")",
":",
"self",
".",
"local_labels",
".",
"append",
"(",
"{",
"}",
")",
"# Add a new context",
"self",
".",
"scopes",
".",
"append",
"(",
"lineno",
")",
"__DEBUG__",
"(",
"'Entering scope level %i at line %i'"... | Enters (pushes) a new context | [
"Enters",
"(",
"pushes",
")",
"a",
"new",
"context"
] | train | 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 | [
"def",
"set_org",
"(",
"self",
",",
"value",
",",
"lineno",
")",
":",
"if",
"value",
"<",
"0",
"or",
"value",
">",
"MAX_MEM",
":",
"error",
"(",
"lineno",
",",
"\"Memory ORG out of range [0 .. 65535]. Current value: %i\"",
"%",
"value",
")",
"self",
".",
"in... | Sets a new ORG value | [
"Sets",
"a",
"new",
"ORG",
"value"
] | train | 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... | [
"def",
"id_name",
"(",
"label",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"not",
"label",
".",
"startswith",
"(",
"DOT",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"NAMESPACE",
"ex_label",
"=",
"namespace",
"+",
"label",
"# ... | Given a name and a namespace, resolves
returns the name as namespace + '.' + name. If namespace
is none, the current NAMESPACE is used | [
"Given",
"a",
"name",
"and",
"a",
"namespace",
"resolves",
"returns",
"the",
"name",
"as",
"namespace",
"+",
".",
"+",
"name",
".",
"If",
"namespace",
"is",
"none",
"the",
"current",
"NAMESPACE",
"is",
"used"
] | train | 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... | [
"def",
"__set_byte",
"(",
"self",
",",
"byte",
",",
"lineno",
")",
":",
"if",
"byte",
"<",
"0",
"or",
"byte",
">",
"255",
":",
"error",
"(",
"lineno",
",",
"'Invalid byte value %i'",
"%",
"byte",
")",
"self",
".",
"memory_bytes",
"[",
"self",
".",
"o... | Sets a byte at the current location,
and increments org in one. Raises an error if org > MAX_MEMORY | [
"Sets",
"a",
"byte",
"at",
"the",
"current",
"location",
"and",
"increments",
"org",
"in",
"one",
".",
"Raises",
"an",
"error",
"if",
"org",
">",
"MAX_MEMORY"
] | train | 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)
... | [
"def",
"exit_proc",
"(",
"self",
",",
"lineno",
")",
":",
"__DEBUG__",
"(",
"'Exiting current scope from lineno %i'",
"%",
"lineno",
")",
"if",
"len",
"(",
"self",
".",
"local_labels",
")",
"<=",
"1",
":",
"error",
"(",
"lineno",
",",
"'ENDP in global scope (w... | 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) | [
"Exits",
"current",
"procedure",
".",
"Local",
"labels",
"are",
"transferred",
"to",
"global",
"scope",
"unless",
"they",
"have",
"been",
"marked",
"as",
"local",
"ones",
"."
] | train | 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' % (... | [
"def",
"add_instruction",
"(",
"self",
",",
"instr",
")",
":",
"if",
"gl",
".",
"has_errors",
":",
"return",
"__DEBUG__",
"(",
"'%04Xh [%04Xh] ASM: %s'",
"%",
"(",
"self",
".",
"org",
",",
"self",
".",
"org",
"-",
"self",
".",
"ORG",
",",
"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 | [
"This",
"will",
"insert",
"an",
"asm",
"instruction",
"at",
"the",
"current",
"memory",
"position",
"in",
"a",
"t",
"-",
"uple",
"as",
"(",
"mnemonic",
"params",
")",
"."
] | train | 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... | [
"def",
"dump",
"(",
"self",
")",
":",
"org",
"=",
"min",
"(",
"self",
".",
"memory_bytes",
".",
"keys",
"(",
")",
")",
"# Org is the lowest one",
"OUTPUT",
"=",
"[",
"]",
"align",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"org",
",",
"max",
... | Returns a tuple containing code ORG, and a list of OUTPUT | [
"Returns",
"a",
"tuple",
"containing",
"code",
"ORG",
"and",
"a",
"list",
"of",
"OUTPUT"
] | train | 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... | [
"def",
"declare_label",
"(",
"self",
",",
"label",
",",
"lineno",
",",
"value",
"=",
"None",
",",
"local",
"=",
"False",
",",
"namespace",
"=",
"None",
")",
":",
"ex_label",
",",
"namespace",
"=",
"Memory",
".",
"id_name",
"(",
"label",
",",
"namespace... | 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 | [
"Sets",
"a",
"label",
"with",
"the",
"given",
"value",
"or",
"with",
"the",
"current",
"address",
"(",
"org",
")",
"if",
"no",
"value",
"is",
"passed",
"."
] | train | 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) - ... | [
"def",
"get_label",
"(",
"self",
",",
"label",
",",
"lineno",
")",
":",
"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. | [
"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",
"."
] | train | 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... | [
"def",
"set_label",
"(",
"self",
",",
"label",
",",
"lineno",
",",
"local",
"=",
"False",
")",
":",
"ex_label",
",",
"namespace",
"=",
"Memory",
".",
"id_name",
"(",
"label",
")",
"if",
"ex_label",
"in",
"self",
".",
"local_labels",
"[",
"-",
"1",
"]... | 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. | [
"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",
"... | train | 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)) | [
"def",
"memory_map",
"(",
"self",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"sorted",
"(",
"\"%04X: %s\"",
"%",
"(",
"x",
".",
"value",
",",
"x",
".",
"name",
")",
"for",
"x",
"in",
"self",
".",
"global_labels",
".",
"values",
"(",
")",
"if",
... | Returns a (very long) string containing a memory map
hex address: label | [
"Returns",
"a",
"(",
"very",
"long",
")",
"string",
"containing",
"a",
"memory",
"map",
"hex",
"address",
":",
"label"
] | train | 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(... | [
"def",
"_addr",
"(",
"value",
")",
":",
"output",
"=",
"[",
"]",
"try",
":",
"indirect",
"=",
"False",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"indirect",
"=",
"True",
"value",
"=",
"value",
"[",
"1",
":",
"]",
"value",
"=",
"int",
"(",... | Common subroutine for emitting array address | [
"Common",
"subroutine",
"for",
"emitting",
"array",
"address"
] | train | 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 | [
"def",
"_aload8",
"(",
"ins",
")",
":",
"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. | [
"Loads",
"an",
"8",
"bit",
"value",
"from",
"a",
"memory",
"address",
"If",
"2nd",
"arg",
".",
"start",
"with",
"*",
"it",
"is",
"always",
"treated",
"as",
"an",
"indirect",
"value",
"."
] | train | 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... | [
"def",
"_aload16",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'ld e, (hl)'",
")",
"output",
".",
"append",
"(",
"'inc hl'",
")",
"output",
".",
"append",
"(",
"'ld d, (hl)... | Loads a 16 bit value from a memory address
If 2nd arg. start with '*', it is always treated as
an indirect value. | [
"Loads",
"a",
"16",
"bit",
"value",
"from",
"a",
"memory",
"address",
"If",
"2nd",
"arg",
".",
"start",
"with",
"*",
"it",
"is",
"always",
"treated",
"as",
"an",
"indirect",
"value",
"."
] | train | 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')
... | [
"def",
"_aload32",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __ILOAD32'",
")",
"output",
".",
"append",
"(",
"'push de'",
")",
"output",
".",
"append",
"(",
"'push ... | Load a 32 bit value from a memory address
If 2nd arg. start with '*', it is always treated as
an indirect value. | [
"Load",
"a",
"32",
"bit",
"value",
"from",
"a",
"memory",
"address",
"If",
"2nd",
"arg",
".",
"start",
"with",
"*",
"it",
"is",
"always",
"treated",
"as",
"an",
"indirect",
"value",
"."
] | train | 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 | [
"def",
"_aloadf",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __LOADF'",
")",
"output",
".",
"extend",
"(",
"_fpush",
"(",
")",
")",
"REQUIRES",
".",
"add",
"(",
... | Loads a floating point value from a memory address.
If 2nd arg. start with '*', it is always treated as
an indirect value. | [
"Loads",
"a",
"floating",
"point",
"value",
"from",
"a",
"memory",
"address",
".",
"If",
"2nd",
"arg",
".",
"start",
"with",
"*",
"it",
"is",
"always",
"treated",
"as",
"an",
"indirect",
"value",
"."
] | train | 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 | [
"def",
"_aloadstr",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __ILOADSTR'",
")",
"output",
".",
"append",
"(",
"'push hl'",
")",
"REQUIRES",
".",
"add",
"(",
"'load... | Loads a string value from a memory address. | [
"Loads",
"a",
"string",
"value",
"from",
"a",
"memory",
"address",
"."
] | train | 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] == '*'... | [
"def",
"_astore8",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"op",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"indirect",
"=",
"op",
"[",
"0",
"]",
"==",
"'*'",
"if",
"indirect",
":",
"op",
"=",
... | 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) | [
"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",
... | train | 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] == '#'
... | [
"def",
"_astore16",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"op",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"indirect",
"=",
"op",
"[",
"0",
"]",
"==",
"'*'",
"if",
"indirect",
":",
"op",
"=",
... | Stores 2º operand content into address of 1st operand.
store16 a, x => *(&a) = x
Use '*' for indirect store on 1st operand. | [
"Stores",
"2º",
"operand",
"content",
"into",
"address",
"of",
"1st",
"operand",
".",
"store16",
"a",
"x",
"=",
">",
"*",
"(",
"&a",
")",
"=",
"x",
"Use",
"*",
"for",
"indirect",
"store",
"on",
"1st",
"operand",
"."
] | train | 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... | [
"def",
"_astore32",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"value",
"=",
"value",
"[",
"1",
... | Stores 2º operand content into address of 1st operand.
store16 a, x => *(&a) = x | [
"Stores",
"2º",
"operand",
"content",
"into",
"address",
"of",
"1st",
"operand",
".",
"store16",
"a",
"x",
"=",
">",
"*",
"(",
"&a",
")",
"=",
"x"
] | train | 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... | [
"def",
"_astoref16",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"value",
"=",
"value",
"[",
"1",
... | Stores 2º operand content into address of 1st operand.
storef16 a, x => *(&a) = x | [
"Stores",
"2º",
"operand",
"content",
"into",
"address",
"of",
"1st",
"operand",
".",
"storef16",
"a",
"x",
"=",
">",
"*",
"(",
"&a",
")",
"=",
"x"
] | train | 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.... | [
"def",
"_astoref",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"value",
"=",
"value",
"[",
"1",
... | Stores a floating point value into a memory address. | [
"Stores",
"a",
"floating",
"point",
"value",
"into",
"a",
"memory",
"address",
"."
] | train | 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 ... | [
"def",
"_astorestr",
"(",
"ins",
")",
":",
"output",
"=",
"_addr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"op",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"indirect",
"=",
"op",
"[",
"0",
"]",
"==",
"'*'",
"if",
"indirect",
":",
"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 '#'. | [
"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",
"DO... | train | 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)
... | [
"def",
"make_node",
"(",
"cls",
",",
"node",
",",
"*",
"args",
")",
":",
"if",
"node",
"is",
"None",
":",
"node",
"=",
"cls",
"(",
")",
"assert",
"isinstance",
"(",
"node",
",",
"SymbolARGUMENT",
")",
"or",
"isinstance",
"(",
"node",
",",
"cls",
")... | This will return a node with an argument_list. | [
"This",
"will",
"return",
"a",
"node",
"with",
"an",
"argument_list",
"."
] | train | 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 ... | [
"def",
"_32bit_oper",
"(",
"op1",
",",
"op2",
"=",
"None",
",",
"reversed",
"=",
"False",
",",
"preserveHL",
"=",
"False",
")",
":",
"output",
"=",
"[",
"]",
"if",
"op1",
"is",
"not",
"None",
":",
"op1",
"=",
"str",
"(",
"op1",
")",
"if",
"op2",
... | 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
... | [
"Returns",
"pop",
"sequence",
"for",
"32",
"bits",
"operands",
"1st",
"operand",
"in",
"HLDE",
"2nd",
"operand",
"remains",
"in",
"the",
"stack"
] | train | 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... | [
"def",
"_add32",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"if",
"_int_ops",
"(",
"op1",
",",
"op2",
")",
"is",
"not",
"None",
":",
"o1",
",",
"o2",
"=",
"_int_ops",
"(",
"op1",
... | 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 | [
"Pops",
"last",
"2",
"bytes",
"from",
"the",
"stack",
"and",
"adds",
"them",
".",
"Then",
"push",
"the",
"result",
"onto",
"the",
"stack",
"."
] | train | 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... | [
"def",
"_sub32",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"if",
"is_int",
"(",
"op2",
")",
":",
"if",
"int",
"(",
"op2",
")",
"==",
"0",
":",
"# A - 0 = A => Do Nothing",
"output",
... | 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 | [
"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",
"]",
"-",
... | train | 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... | [
"def",
"_mul32",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"if",
"_int_ops",
"(",
"op1",
",",
"op2",
")",
":",
"op1",
",",
"op2",
"=",
"_int_ops",
"(",
"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 | [
"Multiplies",
"two",
"last",
"32bit",
"values",
"on",
"top",
"of",
"the",
"stack",
"and",
"and",
"returns",
"the",
"value",
"on",
"top",
"of",
"the",
"stack"
] | train | 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... | [
"def",
"_ltu32",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"rev",
"=",
"op1",
"[",
"0",
"]",
"!=",
"'t'",
"and",
"not",
"is_int",
"(",
"op1",
")",
"and",
"op2",
"[",
"0",
"]",
... | 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 | [
"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",
"."
] | train | 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... | [
"def",
"_gtu32",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"rev",
"=",
"op1",
"[",
"0",
"]",
"!=",
"'t'",
"and",
"not",
"is_int",
"(",
"op1",
")",
"and",
"op2",
"[",
"0",
"]",
... | 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 | [
"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",
"."
] | train | 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 ... | [
"def",
"_eq32",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"output",
"=",
"_32bit_oper",
"(",
"op1",
",",
"op2",
")",
"output",
".",
"append",
"(",
"'call __EQ32'",
")",
"output",
".",... | 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 | [
"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",
"."
] | train | 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 = ... | [
"def",
"_and32",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"if",
"_int_ops",
"(",
"op1",
",",
"op2",
")",
":",
"op1",
",",
"op2",
"=",
"_int_ops",
"(",
"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 | [
"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",... | train | 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 | [
"def",
"_not32",
"(",
"ins",
")",
":",
"output",
"=",
"_32bit_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __NOT32'",
")",
"output",
".",
"append",
"(",
"'push af'",
")",
"REQUIRES",
".",
"add",
"(",
"'not3... | Negates top (Logical NOT) of the stack (32 bits in DEHL) | [
"Negates",
"top",
"(",
"Logical",
"NOT",
")",
"of",
"the",
"stack",
"(",
"32",
"bits",
"in",
"DEHL",
")"
] | train | 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 | [
"def",
"_bnot32",
"(",
"ins",
")",
":",
"output",
"=",
"_32bit_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __BNOT32'",
")",
"output",
".",
"append",
"(",
"'push de'",
")",
"output",
".",
"append",
"(",
"'p... | Negates top (Bitwise NOT) of the stack (32 bits in DEHL) | [
"Negates",
"top",
"(",
"Bitwise",
"NOT",
")",
"of",
"the",
"stack",
"(",
"32",
"bits",
"in",
"DEHL",
")"
] | train | 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 | [
"def",
"_neg32",
"(",
"ins",
")",
":",
"output",
"=",
"_32bit_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __NEG32'",
")",
"output",
".",
"append",
"(",
"'push de'",
")",
"output",
".",
"append",
"(",
"'pus... | Negates top of the stack (32 bits in DEHL) | [
"Negates",
"top",
"of",
"the",
"stack",
"(",
"32",
"bits",
"in",
"DEHL",
")"
] | train | 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 | [
"def",
"_abs32",
"(",
"ins",
")",
":",
"output",
"=",
"_32bit_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __ABS32'",
")",
"output",
".",
"append",
"(",
"'push de'",
")",
"output",
".",
"append",
"(",
"'pus... | Absolute value of top of the stack (32 bits in DEHL) | [
"Absolute",
"value",
"of",
"top",
"of",
"the",
"stack",
"(",
"32",
"bits",
"in",
"DEHL",
")"
] | train | 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... | [
"def",
"_shl32",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"if",
"is_int",
"(",
"op2",
")",
":",
"output",
"=",
"_32bit_oper",
"(",
"op1",
")",
"if",
"int",
"(",
"op2",
")",
"==",... | Logical Left shift 32bit unsigned integers.
The result is pushed onto the stack.
Optimizations:
* If 2nd operand is 0, do nothing | [
"Logical",
"Left",
"shift",
"32bit",
"unsigned",
"integers",
".",
"The",
"result",
"is",
"pushed",
"onto",
"the",
"stack",
"."
] | train | 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... | [
"def",
"_float_oper",
"(",
"op1",
",",
"op2",
"=",
"None",
")",
":",
"output",
"=",
"[",
"]",
"op",
"=",
"op2",
"if",
"op2",
"is",
"not",
"None",
"else",
"op1",
"indirect",
"=",
"(",
"op",
"[",
"0",
"]",
"==",
"'*'",
")",
"if",
"indirect",
":",... | 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... | [
"Returns",
"pop",
"sequence",
"for",
"floating",
"point",
"operands",
"1st",
"operand",
"in",
"A",
"DE",
"BC",
"2nd",
"operand",
"remains",
"in",
"the",
"stack"
] | train | 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())
... | [
"def",
"_addf",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"if",
"_f_ops",
"(",
"op1",
",",
"op2",
")",
"is",
"not",
"None",
":",
"opa",
",",
"opb",
"=",
"_f_ops",
"(",
"op1",
",... | Adds 2 float values. The result is pushed onto the stack. | [
"Adds",
"2",
"float",
"values",
".",
"The",
"result",
"is",
"pushed",
"onto",
"the",
"stack",
"."
] | train | 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... | [
"def",
"_divf",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"if",
"is_float",
"(",
"op2",
")",
"and",
"float",
"(",
"op2",
")",
"==",
"1",
":",
"# Nothing to do. A / 1 = A",
"output",
"... | Divides 2 float values. The result is pushed onto the stack. | [
"Divides",
"2",
"float",
"values",
".",
"The",
"result",
"is",
"pushed",
"onto",
"the",
"stack",
"."
] | train | 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 | [
"def",
"_modf",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"output",
"=",
"_float_oper",
"(",
"op1",
",",
"op2",
")",
"output",
".",
"append",
"(",
"'call __MODF'",
")",
"output",
".",... | Reminder of div. 2 float values. The result is pushed onto the stack. | [
"Reminder",
"of",
"div",
".",
"2",
"float",
"values",
".",
"The",
"result",
"is",
"pushed",
"onto",
"the",
"stack",
"."
] | train | 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... | [
"def",
"_ltf",
"(",
"ins",
")",
":",
"op1",
",",
"op2",
"=",
"tuple",
"(",
"ins",
".",
"quad",
"[",
"2",
":",
"]",
")",
"output",
"=",
"_float_oper",
"(",
"op1",
",",
"op2",
")",
"output",
".",
"append",
"(",
"'call __LTF'",
")",
"output",
".",
... | 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 | [
"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",
"."
] | train | 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 | [
"def",
"_notf",
"(",
"ins",
")",
":",
"output",
"=",
"_float_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __NOTF'",
")",
"output",
".",
"append",
"(",
"'push af'",
")",
"REQUIRES",
".",
"add",
"(",
"'notf.a... | Negates top of the stack (48 bits) | [
"Negates",
"top",
"of",
"the",
"stack",
"(",
"48",
"bits",
")"
] | train | 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 | [
"def",
"_negf",
"(",
"ins",
")",
":",
"output",
"=",
"_float_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __NEGF'",
")",
"output",
".",
"extend",
"(",
"_fpush",
"(",
")",
")",
"REQUIRES",
".",
"add",
"(",... | Changes sign of top of the stack (48 bits) | [
"Changes",
"sign",
"of",
"top",
"of",
"the",
"stack",
"(",
"48",
"bits",
")"
] | train | 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 | [
"def",
"_absf",
"(",
"ins",
")",
":",
"output",
"=",
"_float_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'res 7, e'",
")",
"# Just resets the sign bit!",
"output",
".",
"extend",
"(",
"_fpush",
"(",
")",
")",
"ret... | Absolute value of top of the stack (48 bits) | [
"Absolute",
"value",
"of",
"top",
"of",
"the",
"stack",
"(",
"48",
"bits",
")"
] | train | 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 | [
"def",
"get_uniques",
"(",
"l",
")",
":",
"result",
"=",
"[",
"]",
"for",
"i",
"in",
"l",
":",
"if",
"i",
"not",
"in",
"result",
":",
"result",
".",
"append",
"(",
"i",
")",
"return",
"result"
] | Returns a list with no repeated elements. | [
"Returns",
"a",
"list",
"with",
"no",
"repeated",
"elements",
"."
] | train | 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 | [
"def",
"t_CHAR",
"(",
"self",
",",
"t",
")",
":",
"# A single char",
"t",
".",
"value",
"=",
"ord",
"(",
"t",
".",
"value",
"[",
"1",
"]",
")",
"t",
".",
"type",
"=",
"'INTEGER'",
"return",
"t"
] | r"'. | [
"r",
"."
] | train | 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... | [
"def",
"t_BIN",
"(",
"self",
",",
"t",
")",
":",
"# 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",
"."... | r'(%[01]+)|([01]+[bB]) | [
"r",
"(",
"%",
"[",
"01",
"]",
"+",
")",
"|",
"(",
"[",
"01",
"]",
"+",
"[",
"bB",
"]",
")"
] | train | 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... | [
"def",
"t_INITIAL_ID",
"(",
"self",
",",
"t",
")",
":",
"# Any identifier",
"tmp",
"=",
"t",
".",
"value",
"# Saves original value",
"if",
"tmp",
"[",
"-",
"1",
"]",
"==",
"':'",
":",
"t",
".",
"type",
"=",
"'LABEL'",
"t",
".",
"value",
"=",
"tmp",
... | r'[._a-zA-Z][._a-zA-Z0-9]*([ \t]*[:])? | [
"r",
"[",
".",
"_a",
"-",
"zA",
"-",
"Z",
"]",
"[",
".",
"_a",
"-",
"zA",
"-",
"Z0",
"-",
"9",
"]",
"*",
"(",
"[",
"\\",
"t",
"]",
"*",
"[",
":",
"]",
")",
"?"
] | train | 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 | [
"def",
"t_preproc_ID",
"(",
"self",
",",
"t",
")",
":",
"# preprocessor directives",
"t",
".",
"type",
"=",
"preprocessor",
".",
"get",
"(",
"t",
".",
"value",
".",
"lower",
"(",
")",
",",
"'ID'",
")",
"return",
"t"
] | r'[_a-zA-Z][_a-zA-Z0-9]* | [
"r",
"[",
"_a",
"-",
"zA",
"-",
"Z",
"]",
"[",
"_a",
"-",
"zA",
"-",
"Z0",
"-",
"9",
"]",
"*"
] | train | 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 | [
"def",
"t_LP",
"(",
"self",
",",
"t",
")",
":",
"if",
"t",
".",
"value",
"!=",
"'['",
"and",
"OPTIONS",
".",
"bracket",
".",
"value",
":",
"t",
".",
"type",
"=",
"'LPP'",
"return",
"t"
] | r'[[(] | [
"r",
"[[",
"(",
"]"
] | train | 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 | [
"def",
"t_RP",
"(",
"self",
",",
"t",
")",
":",
"if",
"t",
".",
"value",
"!=",
"']'",
"and",
"OPTIONS",
".",
"bracket",
".",
"value",
":",
"t",
".",
"type",
"=",
"'RPP'",
"return",
"t"
] | r'[])] | [
"r",
"[]",
")",
"]"
] | train | 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 | [
"def",
"t_INITIAL_preproc_NEWLINE",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"lexer",
".",
"lineno",
"+=",
"1",
"t",
".",
"lexer",
".",
"begin",
"(",
"'INITIAL'",
")",
"return",
"t"
] | r'\r?\n | [
"r",
"\\",
"r?",
"\\",
"n"
] | train | 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) | [
"def",
"t_INITIAL_SHARP",
"(",
"self",
",",
"t",
")",
":",
"if",
"self",
".",
"find_column",
"(",
"t",
")",
"==",
"1",
":",
"t",
".",
"lexer",
".",
"begin",
"(",
"'preproc'",
")",
"else",
":",
"self",
".",
"t_INITIAL_preproc_error",
"(",
"t",
")"
] | r'\# | [
"r",
"\\",
"#"
] | train | 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) | [
"def",
"input",
"(",
"self",
",",
"str",
")",
":",
"self",
".",
"input_data",
"=",
"str",
"self",
".",
"lex",
"=",
"lex",
".",
"lex",
"(",
"object",
"=",
"self",
")",
"self",
".",
"lex",
".",
"input",
"(",
"self",
".",
"input_data",
")"
] | Defines input string, removing current lexer. | [
"Defines",
"input",
"string",
"removing",
"current",
"lexer",
"."
] | train | 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... | [
"def",
"typecast",
"(",
"self",
",",
"type_",
")",
":",
"self",
".",
"value",
"=",
"SymbolTYPECAST",
".",
"make_node",
"(",
"type_",
",",
"self",
".",
"value",
",",
"self",
".",
"lineno",
")",
"return",
"self",
".",
"value",
"is",
"not",
"None"
] | 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. | [
"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",
"i... | train | 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 = []
... | [
"def",
"_paddr",
"(",
"offset",
")",
":",
"output",
"=",
"[",
"]",
"indirect",
"=",
"offset",
"[",
"0",
"]",
"==",
"'*'",
"if",
"indirect",
":",
"offset",
"=",
"offset",
"[",
"1",
":",
"]",
"I",
"=",
"int",
"(",
"offset",
")",
"if",
"I",
">=",
... | 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 | [
"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",
"=... | train | 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 | [
"def",
"_paload8",
"(",
"ins",
")",
":",
"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. | [
"Loads",
"an",
"8",
"bit",
"value",
"from",
"a",
"memory",
"address",
"If",
"2nd",
"arg",
".",
"start",
"with",
"*",
"it",
"is",
"always",
"treated",
"as",
"an",
"indirect",
"value",
"."
] | train | 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... | [
"def",
"_paload16",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'ld e, (hl)'",
")",
"output",
".",
"append",
"(",
"'inc hl'",
")",
"output",
".",
"append",
"(",
"'ld d, (h... | Loads a 16 bit value from a memory address
If 2nd arg. start with '*', it is always treated as
an indirect value. | [
"Loads",
"a",
"16",
"bit",
"value",
"from",
"a",
"memory",
"address",
"If",
"2nd",
"arg",
".",
"start",
"with",
"*",
"it",
"is",
"always",
"treated",
"as",
"an",
"indirect",
"value",
"."
] | train | 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')
... | [
"def",
"_paload32",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __ILOAD32'",
")",
"output",
".",
"append",
"(",
"'push de'",
")",
"output",
".",
"append",
"(",
"'pus... | Load a 32 bit value from a memory address
If 2nd arg. start with '*', it is always treated as
an indirect value. | [
"Load",
"a",
"32",
"bit",
"value",
"from",
"a",
"memory",
"address",
"If",
"2nd",
"arg",
".",
"start",
"with",
"*",
"it",
"is",
"always",
"treated",
"as",
"an",
"indirect",
"value",
"."
] | train | 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 | [
"def",
"_paloadf",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __ILOADF'",
")",
"output",
".",
"extend",
"(",
"_fpush",
"(",
")",
")",
"REQUIRES",
".",
"add",
"(",... | Loads a floating point value from a memory address.
If 2nd arg. start with '*', it is always treated as
an indirect value. | [
"Loads",
"a",
"floating",
"point",
"value",
"from",
"a",
"memory",
"address",
".",
"If",
"2nd",
"arg",
".",
"start",
"with",
"*",
"it",
"is",
"always",
"treated",
"as",
"an",
"indirect",
"value",
"."
] | train | 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 | [
"def",
"_paloadstr",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
")",
"output",
".",
"append",
"(",
"'call __ILOADSTR'",
")",
"output",
".",
"append",
"(",
"'push hl'",
")",
"REQUIRES",
".",
"add",
"(",
"'lo... | Loads a string value from a memory address. | [
"Loads",
"a",
"string",
"value",
"from",
"a",
"memory",
"address",
"."
] | train | 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] == '*'... | [
"def",
"_pastore8",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"value",
"=",
"value",
"[",
"1",
... | 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) | [
"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",
... | train | 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:
... | [
"def",
"_pastore16",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"value",
"=",
"value",
"[",
"1",... | Stores 2º operand content into address of 1st operand.
store16 a, x => *(&a) = x
Use '*' for indirect store on 1st operand. | [
"Stores",
"2º",
"operand",
"content",
"into",
"address",
"of",
"1st",
"operand",
".",
"store16",
"a",
"x",
"=",
">",
"*",
"(",
"&a",
")",
"=",
"x",
"Use",
"*",
"for",
"indirect",
"store",
"on",
"1st",
"operand",
"."
] | train | 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(... | [
"def",
"_pastore32",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"value",
"=",
"value",
"[",
"1",... | Stores 2º operand content into address of 1st operand.
store16 a, x => *(&a) = x | [
"Stores",
"2º",
"operand",
"content",
"into",
"address",
"of",
"1st",
"operand",
".",
"store16",
"a",
"x",
"=",
">",
"*",
"(",
"&a",
")",
"=",
"x"
] | train | 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... | [
"def",
"_pastoref16",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"value",
"=",
"value",
"[",
"1"... | Stores 2º operand content into address of 1st operand.
storef16 a, x => *(&a) = x | [
"Stores",
"2º",
"operand",
"content",
"into",
"address",
"of",
"1st",
"operand",
".",
"storef16",
"a",
"x",
"=",
">",
"*",
"(",
"&a",
")",
"=",
"x"
] | train | 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) & ... | [
"def",
"_pastoref",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"'*'",
":",
"value",
"=",
"value",
"[",
"1",
... | Stores a floating point value into a memory address. | [
"Stores",
"a",
"floating",
"point",
"value",
"into",
"a",
"memory",
"address",
"."
] | train | 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... | [
"def",
"_pastorestr",
"(",
"ins",
")",
":",
"output",
"=",
"_paddr",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"temporal",
"=",
"False",
"value",
"=",
"ins",
".",
"quad",
"[",
"2",
"]",
"indirect",
"=",
"value",
"[",
"0",
"]",
"==",
"'*'",
"... | 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 '#'. | [
"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",
"DO... | train | 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
... | [
"def",
"num2bytes",
"(",
"x",
",",
"bytes",
")",
":",
"if",
"not",
"isinstance",
"(",
"x",
",",
"int",
")",
":",
"# If it is another \"thing\", just return ZEROs",
"return",
"tuple",
"(",
"[",
"0",
"]",
"*",
"bytes",
")",
"x",
"=",
"x",
"&",
"(",
"(",
... | Returns x converted to a little-endian t-uple of bytes.
E.g. num2bytes(255, 4) = (255, 0, 0, 0) | [
"Returns",
"x",
"converted",
"to",
"a",
"little",
"-",
"endian",
"t",
"-",
"uple",
"of",
"bytes",
".",
"E",
".",
"g",
".",
"num2bytes",
"(",
"255",
"4",
")",
"=",
"(",
"255",
"0",
"0",
"0",
")"
] | train | 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):
... | [
"def",
"argval",
"(",
"self",
")",
":",
"if",
"self",
".",
"arg",
"is",
"None",
"or",
"any",
"(",
"x",
"is",
"None",
"for",
"x",
"in",
"self",
".",
"arg",
")",
":",
"return",
"None",
"for",
"x",
"in",
"self",
".",
"arg",
":",
"if",
"not",
"is... | Returns the value of the arg (if any) or None.
If the arg. is not an integer, an error be triggered. | [
"Returns",
"the",
"value",
"of",
"the",
"arg",
"(",
"if",
"any",
")",
"or",
"None",
".",
"If",
"the",
"arg",
".",
"is",
"not",
"an",
"integer",
"an",
"error",
"be",
"triggered",
"."
] | train | 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... | [
"def",
"bytes",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"op",
"=",
"self",
".",
"opcode",
".",
"split",
"(",
"' '",
")",
"argi",
"=",
"0",
"while",
"op",
":",
"q",
"=",
"op",
".",
"pop",
"(",
"0",
")",
"if",
"q",
"==",
"'XX'",
":",
... | Returns a t-uple with instruction bytes (integers) | [
"Returns",
"a",
"t",
"-",
"uple",
"with",
"instruction",
"bytes",
"(",
"integers",
")"
] | train | 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:
... | [
"def",
"syntax_error",
"(",
"lineno",
",",
"msg",
")",
":",
"if",
"global_",
".",
"has_errors",
">",
"OPTIONS",
".",
"max_syntax_errors",
".",
"value",
":",
"msg",
"=",
"'Too many errors. Giving up!'",
"msg",
"=",
"\"%s:%i: %s\"",
"%",
"(",
"global_",
".",
"... | Generic syntax error routine | [
"Generic",
"syntax",
"error",
"routine"
] | train | 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 | [
"def",
"warning",
"(",
"lineno",
",",
"msg",
")",
":",
"msg",
"=",
"\"%s:%i: warning: %s\"",
"%",
"(",
"global_",
".",
"FILENAME",
",",
"lineno",
",",
"msg",
")",
"msg_output",
"(",
"msg",
")",
"global_",
".",
"has_warnings",
"+=",
"1"
] | Generic warning error routine | [
"Generic",
"warning",
"error",
"routine"
] | train | 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... | [
"def",
"warning_implicit_type",
"(",
"lineno",
",",
"id_",
",",
"type_",
"=",
"None",
")",
":",
"if",
"OPTIONS",
".",
"strict",
".",
"value",
":",
"syntax_error_undeclared_type",
"(",
"lineno",
",",
"id_",
")",
"return",
"if",
"type_",
"is",
"None",
":",
... | Warning: Using default implicit type 'x' | [
"Warning",
":",
"Using",
"default",
"implicit",
"type",
"x"
] | train | 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... | [
"def",
"oper",
"(",
"inst",
")",
":",
"i",
"=",
"inst",
".",
"strip",
"(",
"' \\t\\n'",
")",
".",
"split",
"(",
"' '",
")",
"I",
"=",
"i",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"# Instruction",
"i",
"=",
"''",
".",
"join",
"(",
"i",
"[",
"... | Returns operands of an ASM instruction.
Even "indirect" operands, like SP if RET or CALL is used. | [
"Returns",
"operands",
"of",
"an",
"ASM",
"instruction",
".",
"Even",
"indirect",
"operands",
"like",
"SP",
"if",
"RET",
"or",
"CALL",
"is",
"used",
"."
] | train | 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... | [
"def",
"condition",
"(",
"i",
")",
":",
"I",
"=",
"inst",
"(",
"i",
")",
"if",
"I",
"not",
"in",
"{",
"'call'",
",",
"'jp'",
",",
"'jr'",
",",
"'ret'",
"}",
":",
"return",
"None",
"# This instruction always execute",
"if",
"I",
"==",
"'ret'",
":",
... | 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. | [
"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... | train | 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... | [
"def",
"single_registers",
"(",
"op",
")",
":",
"result",
"=",
"set",
"(",
")",
"if",
"isinstance",
"(",
"op",
",",
"str",
")",
":",
"op",
"=",
"[",
"op",
"]",
"for",
"x",
"in",
"op",
":",
"if",
"is_8bit_register",
"(",
"x",
")",
":",
"result",
... | 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. | [
"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",
"ign... | train | 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'}:
... | [
"def",
"result",
"(",
"i",
")",
":",
"ins",
"=",
"inst",
"(",
"i",
")",
"op",
"=",
"oper",
"(",
"i",
")",
"if",
"ins",
"in",
"(",
"'or'",
",",
"'and'",
")",
"and",
"op",
"==",
"[",
"'a'",
"]",
":",
"return",
"[",
"'f'",
"]",
"if",
"ins",
... | Returns which 8-bit registers are used by an asm
instruction to return a result. | [
"Returns",
"which",
"8",
"-",
"bit",
"registers",
"are",
"used",
"by",
"an",
"asm",
"instruction",
"to",
"return",
"a",
"result",
"."
] | train | 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... | [
"def",
"block_partition",
"(",
"block",
",",
"i",
")",
":",
"i",
"+=",
"1",
"new_block",
"=",
"BasicBlock",
"(",
"block",
".",
"asm",
"[",
"i",
":",
"]",
")",
"block",
".",
"mem",
"=",
"block",
".",
"mem",
"[",
":",
"i",
"]",
"block",
".",
"asm... | Returns two blocks, as a result of partitioning the given one at
i-th instruction. | [
"Returns",
"two",
"blocks",
"as",
"a",
"result",
"of",
"partitioning",
"the",
"given",
"one",
"at",
"i",
"-",
"th",
"instruction",
"."
] | train | 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... | [
"def",
"partition_block",
"(",
"block",
")",
":",
"result",
"=",
"[",
"block",
"]",
"if",
"not",
"block",
".",
"is_partitionable",
":",
"return",
"result",
"EDP",
"=",
"END_PROGRAM_LABEL",
"+",
"':'",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"block",
... | If a block is not partitionable, returns a list with the same block.
Otherwise, returns a list with the resulting blocks, recursively. | [
"If",
"a",
"block",
"is",
"not",
"partitionable",
"returns",
"a",
"list",
"with",
"the",
"same",
"block",
".",
"Otherwise",
"returns",
"a",
"list",
"with",
"the",
"resulting",
"blocks",
"recursively",
"."
] | train | 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) | [
"def",
"get_labels",
"(",
"MEMORY",
",",
"basic_block",
")",
":",
"for",
"cell",
"in",
"MEMORY",
":",
"if",
"cell",
".",
"is_label",
":",
"label",
"=",
"cell",
".",
"inst",
"LABELS",
"[",
"label",
"]",
"=",
"LabelInfo",
"(",
"label",
",",
"cell",
"."... | Traverses memory, to annotate all the labels in the global
LABELS table | [
"Traverses",
"memory",
"to",
"annotate",
"all",
"the",
"labels",
"in",
"the",
"global",
"LABELS",
"table"
] | train | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L2172-L2179 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.