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

Subversion Repositories ssbcc

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

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 5 sinclairrf
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(argument[0]);
29 3 sinclairrf
    offset = ad.Emit_EvalSingleValue(argument[1]);
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['store'] | ixBank,'store '+bankName);
32
    ad.EmitOptArg(fp,argument[2]);
33 5 sinclairrf
 
34 3 sinclairrf
  ad.EmitFunction['.storeoffset'] = emitFunction;

powered by: WebSVN 2.1.0

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