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

Subversion Repositories ssbcc

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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