Line 900... |
Line 900... |
"""
|
"""
|
name = self.emitLabelList + name;
|
name = self.emitLabelList + name;
|
self.emitLabelList = '';
|
self.emitLabelList = '';
|
return name;
|
return name;
|
|
|
|
def Emit_IntegerValue(self,token):
|
|
"""
|
|
Return the integer value associated with a constant or a numeric expression.
|
|
"""
|
|
if token['type'] == 'value':
|
|
v = token['value'];
|
|
elif token['type'] == 'symbol':
|
|
name = token['value'];
|
|
if not self.IsSymbol(name):
|
|
raise asmDef.AsmException('Symbol "%s" not recognized at %s' % (token['value'],token['loc'],));
|
|
ix = self.symbols['list'].index(name);
|
|
v = self.symbols['body'][ix];
|
|
if len(v) != 1:
|
|
raise asmDef.AsmException('Argument can only be one value at %s' % token['loc']);
|
|
v = v[0];
|
|
else:
|
|
raise asmDef.AsmException('Argument "%s" of type "%s" not recognized at %s' % (token['value'],token['type'],token['loc'],));
|
|
if type(v) != int:
|
|
raise Exception('Program Bug -- value should be an "int"');
|
|
return v;
|
|
|
#
|
#
|
# Utilities to write single instructions to the metacode file.
|
# Utilities to write single instructions to the metacode file.
|
#
|
#
|
# Note: Other than the program header and the function names, these
|
# Note: Other than the program header and the function names, these
|
# utilities write the function bodies.
|
# utilities write the function bodies.
|
Line 1270... |
Line 1291... |
]);
|
]);
|
self.AddMacro('.jumpc', 3, [
|
self.AddMacro('.jumpc', 3, [
|
['','symbol'],
|
['','symbol'],
|
['drop','instruction','singlemacro','singlevalue','symbol']
|
['drop','instruction','singlemacro','singlevalue','symbol']
|
]);
|
]);
|
self.AddMacro('.return', 2, [ ['nop','instruction','singlevalue','symbol'] ]);
|
self.AddMacro('.return', 2, [ ['nop','instruction','singlemacro','singlevalue','symbol'] ]);
|
self.AddMacro('.store', 1, [ ['','symbol'] ]);
|
self.AddMacro('.store', 1, [ ['','symbol'] ]);
|
self.AddMacro('.store+', 1, [ ['','symbol'] ]);
|
self.AddMacro('.store+', 1, [ ['','symbol'] ]);
|
self.AddMacro('.store-', 1, [ ['','symbol'] ]);
|
self.AddMacro('.store-', 1, [ ['','symbol'] ]);
|
|
|
# User-defined macros in ./macros that are "built in" to the assembler.
|
# User-defined macros in ./macros that are "built in" to the assembler.
|