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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [macros/] [fetchoffset.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 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
    name = argument[0]['value'];
25
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(name);
26
    offset = ad.Emit_EvalSingleValue(argument[1]);
27
    ad.EmitPush(fp,addr+offset,ad.Emit_String('%s+%s' % (name,offset,)),argument[0]['loc']);
28
    ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
29
  ad.EmitFunction['.fetchoffset'] = emitFunction;

powered by: WebSVN 2.1.0

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