URL
https://opencores.org/ocsvn/ssbcc/ssbcc/trunk
[/] [ssbcc/] [trunk/] [core/] [9x8/] [macros/] [fetchindexed.py] - Blame information for rev 3
Go to most recent revision |
Details |
Compare with Previous |
View Log
| Line No. |
Rev |
Author |
Line |
| 1 |
3 |
sinclairrf |
# Copyright 2014, Sinclair R.F., Inc.
|
| 2 |
|
|
|
| 3 |
|
|
def fetchindexed(ad):
|
| 4 |
|
|
"""
|
| 5 |
|
|
Built-in macro to the N'th byte from a variable where N is specified by the
|
| 6 |
|
|
top of the data stack.\n
|
| 7 |
|
|
Usage:
|
| 8 |
|
|
<N> .fetchindexed(variable)
|
| 9 |
|
|
where
|
| 10 |
|
|
<N> represents a value of the top of the data stack
|
| 11 |
|
|
variable is a variable\n
|
| 12 |
|
|
The effect is: T = variable[n]\n
|
| 13 |
|
|
( u_offset - u_mem )
|
| 14 |
|
|
"""
|
| 15 |
|
|
|
| 16 |
|
|
# Add the macro to the list of recognized macros.
|
| 17 |
|
|
ad.AddMacro('.fetchindexed', 3, [ ['','symbol'] ]);
|
| 18 |
|
|
|
| 19 |
|
|
# Define the macro functionality.
|
| 20 |
|
|
def emitFunction(ad,fp,argument):
|
| 21 |
|
|
variableName = argument[0]['value'];
|
| 22 |
|
|
(addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(variableName);
|
| 23 |
|
|
ad.EmitPush(fp,addr,ad.Emit_String(variableName),argument[0]['loc']);
|
| 24 |
|
|
ad.EmitOpcode(fp,ad.InstructionOpcode('+'),'+');
|
| 25 |
|
|
ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
|
| 26 |
|
|
ad.EmitFunction['.fetchindexed'] = emitFunction;
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.