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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [macros/] [9x8/] [pushByte.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 pushByte(ad):
4
  """
5
  User-defined macro to push a 32 bit value onto the data stack so that the LSB
6
  is deepest in the data stack and the MSB is at the top of the data stack.
7
  Usage:
8
    .pushByte(v,ix)
9
  where
10
    v           is a multi-byte value, a constant, or an evaluated expression
11
    ix          is the index to the byte to push (ix=0 ==> push the LSB, ...)\n
12
  The effect is to push "(v/2**ix) % 0x10" onto the data stack.\n
13
  ( - u_byte )
14
  """
15
 
16
  # Add the macro to the list of recognized macros.
17
  ad.AddMacro('.pushByte', 1, [
18
                                ['','singlevalue','symbol'],
19
                                ['','singlevalue','symbol'],
20
                              ]);
21
 
22
  # Define the macro functionality.
23
  def emitFunction(ad,fp,argument):
24
    v  = ad.Emit_IntegerValue(argument[0]);
25
    ix = ad.Emit_IntegerValue(argument[1]);
26
    if ix < 0:
27
      raise asmDef.AsmException('ix must be non-negative in .pushByte at %s' % argument[1]['loc']);
28
    v = int(v/2**ix) % 0x100;
29
    printValue = argument[0]['value'] if type(argument[0]['value']) == str else '0x%X' % argument[0]['value'];
30
    printIx    = argument[1]['value'] if type(argument[1]['value']) == str else '0x%X' % argument[1]['value'];
31
    ad.EmitPush(fp,v,'.pushByte(%s,%s)' % (printValue,printIx,));
32
  ad.EmitFunction['.pushByte'] = emitFunction;

powered by: WebSVN 2.1.0

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