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

Subversion Repositories ssbcc

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

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 fetchoffset(ad):
4
  """
5
  Built-in macro to copy the value at the specified offset into the specified
6
  variable to the top of the data stack.\n
7
  Usage:
8
    .fetchoffset(variable,ix)
9
  where
10
    variable    is a variable
11
    ix          is the index into the variable\n
12
  The effect is:  T = variable[ix]\n
13
  ( - u_mem )
14
  """
15
 
16
  # Add the macro to the list of recognized macros.
17
  ad.AddMacro('.fetchoffset', 2, [
18
                                   ['','symbol'],
19
                                   ['','singlevalue','symbol']
20
                                 ]);
21
 
22
  # Define the macro functionality.
23
  def emitFunction(ad,fp,argument):
24 5 sinclairrf
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(argument[0]);
25 3 sinclairrf
    offset = ad.Emit_EvalSingleValue(argument[1]);
26 5 sinclairrf
    ad.EmitPush(fp,addr+offset,ad.Emit_String('%s+%s' % (argument[0]['value'],offset,)),argument[0]['loc']);
27 3 sinclairrf
    ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
28 5 sinclairrf
 
29 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.