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

Subversion Repositories ssbcc

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