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

Subversion Repositories ssbcc

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

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 5 sinclairrf
from asmDef import AsmException
4
 
5 3 sinclairrf
def storevector(ad):
6
  """
7
  Built-in macro to move multiple bytes from the data stack to memory.  The MSB
8
  (top of the data stack) is store at the specified memory location with
9
  subsequent bytes stored at subsequent memory locations.\n
10
  Usage:
11
    .storevector(variable,N)
12
  where
13
    variable    is the name of a variable
14
    N           is the constant number of bytes to transfer\n
15
  The effect is:  variable[0]=u_MSB, ..., variable[N-1]=u_LSB\n
16
  ( u_LSB ... u_MSB - )
17
  """
18
 
19
  def length(ad,argument):
20 5 sinclairrf
    N = ad.Emit_IntegerValue(argument[1]);
21
    return N+2;
22 3 sinclairrf
 
23
  # Add the macro to the list of recognized macros.
24
  ad.AddMacro('.storevector', length, [
25
                                        ['','symbol'],
26
                                        ['','singlevalue','symbol'],
27
                                      ]);
28
 
29
  # Define the macro functionality.
30
  def emitFunction(ad,fp,argument):
31 5 sinclairrf
    (addr,ixBank,bankName) = ad.Emit_GetAddrAndBank(argument[0]);
32
    N = ad.Emit_IntegerValue(argument[1]);
33
    if addr+N > 256:
34
      raise asmDef.AsmException('Unreasonable address+length=0x%02X+0x%02X > 256 at %s' % (addr,N,argument[0]['loc'],));
35 3 sinclairrf
    ad.EmitPush(fp,addr,argument[0]['value']);
36
    for dummy in range(N):
37
      ad.EmitOpcode(fp,ad.specialInstructions['store+'] | ixBank,'store+ '+bankName);
38 5 sinclairrf
    ad.EmitOpcode(fp,ad.InstructionOpcode('drop'),'drop -- .storevector(%s,%s)' % (argument[0]['value'],argument[1]['value'],) );
39
 
40 3 sinclairrf
  ad.EmitFunction['.storevector'] = emitFunction;

powered by: WebSVN 2.1.0

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