Line 1... |
Line 1... |
# Copyright 2014, Sinclair R.F., Inc.
|
# Copyright 2014, Sinclair R.F., Inc.
|
|
|
|
from asmDef import AsmException
|
|
|
def storevector(ad):
|
def storevector(ad):
|
"""
|
"""
|
Built-in macro to move multiple bytes from the data stack to memory. The MSB
|
Built-in macro to move multiple bytes from the data stack to memory. The MSB
|
(top of the data stack) is store at the specified memory location with
|
(top of the data stack) is store at the specified memory location with
|
subsequent bytes stored at subsequent memory locations.\n
|
subsequent bytes stored at subsequent memory locations.\n
|
Line 13... |
Line 15... |
The effect is: variable[0]=u_MSB, ..., variable[N-1]=u_LSB\n
|
The effect is: variable[0]=u_MSB, ..., variable[N-1]=u_LSB\n
|
( u_LSB ... u_MSB - )
|
( u_LSB ... u_MSB - )
|
"""
|
"""
|
|
|
def length(ad,argument):
|
def length(ad,argument):
|
return int(argument[1]['value']) + 2;
|
N = ad.Emit_IntegerValue(argument[1]);
|
|
return N+2;
|
|
|
# Add the macro to the list of recognized macros.
|
# Add the macro to the list of recognized macros.
|
ad.AddMacro('.storevector', length, [
|
ad.AddMacro('.storevector', length, [
|
['','symbol'],
|
['','symbol'],
|
['','singlevalue','symbol'],
|
['','singlevalue','symbol'],
|
]);
|
]);
|
|
|
# Define the macro functionality.
|
# Define the macro functionality.
|
def emitFunction(ad,fp,argument):
|
def emitFunction(ad,fp,argument):
|
variableName = argument[0]['value'];
|
(addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(argument[0]);
|
(addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(variableName);
|
N = ad.Emit_IntegerValue(argument[1]);
|
N = int(argument[1]['value']);
|
if addr+N > 256:
|
|
raise asmDef.AsmException('Unreasonable address+length=0x%02X+0x%02X > 256 at %s' % (addr,N,argument[0]['loc'],));
|
ad.EmitPush(fp,addr,argument[0]['value']);
|
ad.EmitPush(fp,addr,argument[0]['value']);
|
for dummy in range(N):
|
for dummy in range(N):
|
ad.EmitOpcode(fp,ad.specialInstructions['store+'] | ixBank,'store+ '+bankName);
|
ad.EmitOpcode(fp,ad.specialInstructions['store+'] | ixBank,'store+ '+bankName);
|
ad.EmitOpcode(fp,ad.InstructionOpcode('drop'),'drop -- .storevector(%s,%d)' % (variableName,N,) );
|
ad.EmitOpcode(fp,ad.InstructionOpcode('drop'),'drop -- .storevector(%s,%s)' % (argument[0]['value'],argument[1]['value'],) );
|
|
|
ad.EmitFunction['.storevector'] = emitFunction;
|
ad.EmitFunction['.storevector'] = emitFunction;
|
|
|
No newline at end of file
|
No newline at end of file
|