Line 1... |
Line 1... |
# Copyright 2014, Sinclair R.F., Inc.
|
# Copyright 2014, Sinclair R.F., Inc.
|
|
|
|
from asmDef import AsmException
|
|
|
def fetchvector(ad):
|
def fetchvector(ad):
|
"""
|
"""
|
Built-in macro to move multiple bytes from memory to the data stack. The byte
|
Built-in macro to move multiple bytes from memory to the data stack. The byte
|
at the specified memory address is stored at the top of the data stack with
|
at the specified memory address is stored at the top of the data stack with
|
subsequent bytes store below it.\n
|
subsequent bytes store below it.\n
|
Line 14... |
Line 16... |
onto the data stack.\n
|
onto the data stack.\n
|
( - u_LSB ... u_MSB )
|
( - u_LSB ... u_MSB )
|
"""
|
"""
|
|
|
def length(ad,argument):
|
def length(ad,argument):
|
return int(argument[1]['value']) + 1;
|
N = ad.Emit_IntegerValue(argument[1]);
|
|
if not (N > 0):
|
|
raise asmDef.AsmException('Vector length must be positive at %s' % argument[1]['loc']);
|
|
return N+1;
|
|
|
# Add the macro to the list of recognized macros.
|
# Add the macro to the list of recognized macros.
|
ad.AddMacro('.fetchvector', length, [
|
ad.AddMacro('.fetchvector', length, [
|
['','symbol'],
|
['','symbol'],
|
['','singlevalue','symbol']
|
['','singlevalue','symbol']
|
Line 26... |
Line 31... |
|
|
# Define the macro functionality.
|
# Define the macro functionality.
|
def emitFunction(ad,fp,argument):
|
def emitFunction(ad,fp,argument):
|
variableName = argument[0]['value'];
|
variableName = argument[0]['value'];
|
(addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(variableName);
|
(addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(variableName);
|
N = int(argument[1]['value']);
|
N = ad.Emit_IntegerValue(argument[1]);
|
ad.EmitPush(fp,addr+N-1,'%s+%d' % (variableName,N-1));
|
offsetString = '%s-1' % argument[1]['value'] if type(argument[0]['value']) == str else '%d-1' % N;
|
|
ad.EmitPush(fp,addr+N-1,'%s+%s' % (variableName,offsetString));
|
for dummy in range(N-1):
|
for dummy in range(N-1):
|
ad.EmitOpcode(fp,ad.specialInstructions['fetch-'] | ixBank,'fetch- '+bankName);
|
ad.EmitOpcode(fp,ad.specialInstructions['fetch-'] | ixBank,'fetch- '+bankName);
|
ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
|
ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
|
|
|
ad.EmitFunction['.fetchvector'] = emitFunction;
|
ad.EmitFunction['.fetchvector'] = emitFunction;
|
|
|
No newline at end of file
|
No newline at end of file
|