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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [macros/] [storeindexed.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 storeindexed(ad):
4
  """
5
  Built-in macro to store the next-to-top of the data stack at the
6
  offset into variable specified by the top of the data stack.\n
7
  Usage:
8
    <v> <ix> .storeindexed(variable[,op])
9
  where:
10
    <v>         is the value to be stored from the next-to-top of the data
11
                stack
12
    <ix>        is the index into the variable
13
    variable    is the name of the variable
14
    op          is an optional instruction to override the default "drop"
15
                instruction at the end of the instruction sequence\n
16
  The effect is:  variable[ix] = v\n
17
  ( u_value u_ix - )
18
  """
19
 
20
  # Add the macro to the list of recognized macros.
21
  ad.AddMacro('.storeindexed', 4, [
22
                                    ['','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
    ad.EmitPush(fp,addr,ad.Emit_String(argument[0]['value']),argument[0]['loc']);
30 3 sinclairrf
    ad.EmitOpcode(fp,ad.InstructionOpcode('+'),'+');
31
    ad.EmitOpcode(fp,ad.specialInstructions['store'] | ixBank,'store '+bankName);
32
    ad.EmitOptArg(fp,argument[1]);
33 5 sinclairrf
 
34 3 sinclairrf
  ad.EmitFunction['.storeindexed'] = emitFunction;

powered by: WebSVN 2.1.0

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