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

Subversion Repositories ssbcc

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

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 fetchindexed(ad):
4
  """
5
  Built-in macro to the N'th byte from a variable where N is specified by the
6
  top of the data stack.\n
7
  Usage:
8
    <N> .fetchindexed(variable)
9
  where
10
    <N>         represents a value of the top of the data stack
11
    variable    is a variable\n
12
  The effect is:  T = variable[n]\n
13
  ( u_offset - u_mem )
14
  """
15
 
16
  # Add the macro to the list of recognized macros.
17
  ad.AddMacro('.fetchindexed', 3, [ ['','symbol'] ]);
18
 
19
  # Define the macro functionality.
20
  def emitFunction(ad,fp,argument):
21 5 sinclairrf
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(argument[0]);
22
    ad.EmitPush(fp,addr,ad.Emit_String(argument[0]['value']),argument[0]['loc']);
23 3 sinclairrf
    ad.EmitOpcode(fp,ad.InstructionOpcode('+'),'+');
24
    ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
25 5 sinclairrf
 
26 3 sinclairrf
  ad.EmitFunction['.fetchindexed'] = emitFunction;

powered by: WebSVN 2.1.0

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