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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [macros/] [9x8/] [push32.py] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 sinclairrf
# Copyright 2014, Sinclair R.F., Inc.
2
 
3
def push32(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
    .push32(v)
9
  where
10
    v           is a 32-bit value, a constant, or an evaluated expression\n
11
  The effect is to push v%0x100, int(v/2**8)%0x100, int(v/2**16)%0x100, and
12
  int(v/2**24)%0x100 onto the data stack.\n
13
  ( - u_LSB u u u_MSB )
14
  """
15
 
16
  # Add the macro to the list of recognized macros.
17
  ad.AddMacro('.push32', 4, [ ['','singlevalue','symbol'] ]);
18
 
19
  # Define the macro functionality.
20
  def emitFunction(ad,fp,argument):
21
    argument = argument[0];
22 4 sinclairrf
    v = ad.Emit_IntegerValue(argument);
23
    if not (-2**31 <= v < 2**32):
24
      raise asmDef.AsmException('Argument "%s" should be a 32-bit integer at %s' % (argument['value'],argument['loc'],));
25
    printString = argument['value'] if type(argument['value']) == str else '0x%04X' % (v % 2**32);
26
    for ix in range(4-1):
27
      ad.EmitPush(fp,v%0x100,'');
28
      v >>= 8;
29
    ad.EmitPush(fp,v%0x100,'.push32(%s)' % printString);
30
 
31 3 sinclairrf
  ad.EmitFunction['.push32'] = emitFunction;

powered by: WebSVN 2.1.0

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