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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [macros/] [fetchindexed.py] - Rev 3

Go to most recent revision | Compare with Previous | Blame | View Log

# Copyright 2014, Sinclair R.F., Inc.
 
def fetchindexed(ad):
  """
  Built-in macro to the N'th byte from a variable where N is specified by the
  top of the data stack.\n
  Usage:
    <N> .fetchindexed(variable)
  where
    <N>         represents a value of the top of the data stack
    variable    is a variable\n
  The effect is:  T = variable[n]\n
  ( u_offset - u_mem )
  """
 
  # Add the macro to the list of recognized macros.
  ad.AddMacro('.fetchindexed', 3, [ ['','symbol'] ]);
 
  # Define the macro functionality.
  def emitFunction(ad,fp,argument):
    variableName = argument[0]['value'];
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(variableName);
    ad.EmitPush(fp,addr,ad.Emit_String(variableName),argument[0]['loc']);
    ad.EmitOpcode(fp,ad.InstructionOpcode('+'),'+');
    ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
  ad.EmitFunction['.fetchindexed'] = emitFunction;
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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