Line 1... |
Line 1... |
# Copyright 2014, Sinclair R.F., Inc.
|
# Copyright 2014, Sinclair R.F., Inc.
|
|
|
def pushByte(ad):
|
def pushByte(ad):
|
"""
|
"""
|
User-defined macro to push a 32 bit value onto the data stack so that the LSB
|
User-defined macro to push a specific byte of a multi-byte onto the data
|
is deepest in the data stack and the MSB is at the top of the data stack.
|
stack.\n
|
Usage:
|
Usage:
|
.pushByte(v,ix)
|
.pushByte(v,ix)
|
where
|
where
|
v is a multi-byte value, a constant, or an evaluated expression
|
v is a multi-byte value, a constant, or an evaluated expression
|
ix is the index to the byte to push (ix=0 ==> push the LSB, ...)\n
|
ix is the index to the byte to push (ix=0 ==> push the LSB, ...)\n
|
The effect is to push "(v/2**ix) % 0x10" onto the data stack.\n
|
The effect is to push "(v/256**ix) % 0x100" onto the data stack.\n
|
( - u_byte )
|
( - u_byte )
|
"""
|
"""
|
|
|
# Add the macro to the list of recognized macros.
|
# Add the macro to the list of recognized macros.
|
ad.AddMacro('.pushByte', 1, [
|
ad.AddMacro('.pushByte', 1, [
|
Line 23... |
Line 23... |
def emitFunction(ad,fp,argument):
|
def emitFunction(ad,fp,argument):
|
v = ad.Emit_IntegerValue(argument[0]);
|
v = ad.Emit_IntegerValue(argument[0]);
|
ix = ad.Emit_IntegerValue(argument[1]);
|
ix = ad.Emit_IntegerValue(argument[1]);
|
if ix < 0:
|
if ix < 0:
|
raise asmDef.AsmException('ix must be non-negative in .pushByte at %s' % argument[1]['loc']);
|
raise asmDef.AsmException('ix must be non-negative in .pushByte at %s' % argument[1]['loc']);
|
v = int(v/2**ix) % 0x100;
|
v = int(v/256**ix) % 0x100;
|
printValue = argument[0]['value'] if type(argument[0]['value']) == str else '0x%X' % argument[0]['value'];
|
printValue = argument[0]['value'] if type(argument[0]['value']) == str else '0x%X' % argument[0]['value'];
|
printIx = argument[1]['value'] if type(argument[1]['value']) == str else '0x%X' % argument[1]['value'];
|
printIx = argument[1]['value'] if type(argument[1]['value']) == str else '0x%X' % argument[1]['value'];
|
ad.EmitPush(fp,v,'.pushByte(%s,%s)' % (printValue,printIx,));
|
ad.EmitPush(fp,v,'.pushByte(%s,%s)' % (printValue,printIx,));
|
|
|
ad.EmitFunction['.pushByte'] = emitFunction;
|
ad.EmitFunction['.pushByte'] = emitFunction;
|