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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [macros/] [storevector.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 storevector(ad):
4
  """
5
  Built-in macro to move multiple bytes from the data stack to memory.  The MSB
6
  (top of the data stack) is store at the specified memory location with
7
  subsequent bytes stored at subsequent memory locations.\n
8
  Usage:
9
    .storevector(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:  variable[0]=u_MSB, ..., variable[N-1]=u_LSB\n
14
  ( u_LSB ... u_MSB - )
15
  """
16
 
17
  def length(ad,argument):
18
    return int(argument[1]['value']) + 2;
19
 
20
  # Add the macro to the list of recognized macros.
21
  ad.AddMacro('.storevector', length, [
22
                                        ['','symbol'],
23
                                        ['','singlevalue','symbol'],
24
                                      ]);
25
 
26
  # Define the macro functionality.
27
  def emitFunction(ad,fp,argument):
28
    variableName = argument[0]['value'];
29
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(variableName);
30
    N = int(argument[1]['value']);
31
    ad.EmitPush(fp,addr,argument[0]['value']);
32
    for dummy in range(N):
33
      ad.EmitOpcode(fp,ad.specialInstructions['store+'] | ixBank,'store+ '+bankName);
34
    ad.EmitOpcode(fp,ad.InstructionOpcode('drop'),'drop -- .storevector(%s,%d)' % (variableName,N,) );
35
  ad.EmitFunction['.storevector'] = emitFunction;

powered by: WebSVN 2.1.0

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