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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [macros/] [storeoffset.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 storeoffset(ad):
4
  """
5
  Built-in macro to store the top of the data stack at the specified offset
6
  into the specified variable.\n
7
  Usage:
8
    <v> .storeoffset(variable,ix[,op])
9
  where:
10
    <v>         is the value to be stored
11
    variable    is the name of the variable
12
    ix          is the index into the variable
13
    op          is an optional instruction to override the default "drop"
14
                instruction at the end of the instruction sequence\n
15
  The effect is:  variable[ix] = v\n
16
  ( v - )
17
  """
18
 
19
  # Add the macro to the list of recognized macros.
20
  ad.AddMacro('.storeoffset', 3, [
21
                                   ['','symbol'],
22
                                   ['','singlevalue','symbol'],
23
                                   ['drop','instruction','singlemacro','singlevalue','symbol']
24
                                 ]);
25
 
26
  # Define the macro functionality.
27
  def emitFunction(ad,fp,argument):
28
    variableName = argument[0]['value'];
29
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(variableName);
30
    offset = ad.Emit_EvalSingleValue(argument[1]);
31
    ad.EmitPush(fp,addr+offset,ad.Emit_String('%s+%s' % (variableName,offset,)),argument[0]['loc']);
32
    ad.EmitOpcode(fp,ad.specialInstructions['store'] | ixBank,'store '+bankName);
33
    ad.EmitOptArg(fp,argument[2]);
34
  ad.EmitFunction['.storeoffset'] = emitFunction;

powered by: WebSVN 2.1.0

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