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

Subversion Repositories ssbcc

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

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 fetchvector(ad):
4
  """
5
  Built-in macro to move multiple bytes from memory to the data stack.  The byte
6
  at the specified memory address is stored at the top of the data stack with
7
  subsequent bytes store below it.\n
8
  Usage:
9
    .fetchvector(variable,N)
10
  where
11
    variable    is the name of a variable
12
    N           is the constant number of bytes to transfer\n
13
  The effect is to push the values u_LSB=variable[N-1], ..., u_msb=variable[0]
14
  onto the data stack.\n
15
  ( - u_LSB ... u_MSB )
16
  """
17
 
18
  def length(ad,argument):
19
    return int(argument[1]['value']) + 1;
20
 
21
  # Add the macro to the list of recognized macros.
22
  ad.AddMacro('.fetchvector', length, [
23
                                        ['','symbol'],
24
                                        ['','singlevalue','symbol']
25
                                      ]);
26
 
27
  # Define the macro functionality.
28
  def emitFunction(ad,fp,argument):
29
    variableName = argument[0]['value'];
30
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(variableName);
31
    N = int(argument[1]['value']);
32
    ad.EmitPush(fp,addr+N-1,'%s+%d' % (variableName,N-1));
33
    for dummy in range(N-1):
34
      ad.EmitOpcode(fp,ad.specialInstructions['fetch-'] | ixBank,'fetch- '+bankName);
35
    ad.EmitOpcode(fp,ad.specialInstructions['fetch'] | ixBank,'fetch '+bankName);
36
  ad.EmitFunction['.fetchvector'] = emitFunction;

powered by: WebSVN 2.1.0

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