OpenCores
URL https://opencores.org/ocsvn/ssbcc/ssbcc/trunk

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [macros/] [fetchoffset.py] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 sinclairrf
# Copyright 2014-2015, Sinclair R.F., Inc.
2 3 sinclairrf
 
3 11 sinclairrf
from asmDef import AsmException
4
 
5 3 sinclairrf
def fetchoffset(ad):
6
  """
7
  Built-in macro to copy the value at the specified offset into the specified
8
  variable to the top of the data stack.\n
9
  Usage:
10
    .fetchoffset(variable,ix)
11
  where
12
    variable    is a variable
13
    ix          is the index into the variable\n
14
  The effect is:  T = variable[ix]\n
15
  ( - u_mem )
16
  """
17
 
18
  # Add the macro to the list of recognized macros.
19
  ad.AddMacro('.fetchoffset', 2, [
20
                                   ['','symbol'],
21
                                   ['','singlevalue','symbol']
22
                                 ]);
23
 
24
  # Define the macro functionality.
25
  def emitFunction(ad,fp,argument):
26 5 sinclairrf
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(argument[0]);
27 3 sinclairrf
    offset = ad.Emit_EvalSingleValue(argument[1]);
28 11 sinclairrf
    if addr+offset >= 256:
29
      raise asmDef.AsmException('Unreasonable address+length=0x%02X+0x%02X >= 256 at %s' % (addr,N,argument[0]['loc'],))
30 5 sinclairrf
    ad.EmitPush(fp,addr+offset,ad.Emit_String('%s+%s' % (argument[0]['value'],offset,)),argument[0]['loc']);
31 3 sinclairrf
    ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
32 5 sinclairrf
 
33 3 sinclairrf
  ad.EmitFunction['.fetchoffset'] = emitFunction;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.