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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [macros/] [inport.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
def inport(ad):
4
  """
5
  Built-in macro to read the specified input port and save the value on the
6
  top of the data stack.\n
7
  Usage:
8
    .inport(I_name)
9
  where
10
    I_name      is the name of the input port.\n
11
  The effect is:  T = <value from the specified input port>\n
12
  ( - u )
13
  """
14
 
15
  # Add the macro to the list of recognized macros.
16
  ad.AddMacro('.inport', 2, [ ['','symbol'] ]);
17
 
18
  # Define the macro functionality.
19
  def emitFunction(ad,fp,argument):
20
    if not ad.IsInport(argument[0]['value']):
21
      raise asmDef.AsmException('Symbol "%s is not an input port at %s' % (argument[0]['value'],argument[0]['loc']));
22
    name = argument[0]['value'];
23
    ad.EmitPush(fp,ad.InportAddress(name) & 0xFF,name);
24
    ad.EmitOpcode(fp,ad.InstructionOpcode('inport'),'inport');
25 5 sinclairrf
 
26 3 sinclairrf
  ad.EmitFunction['.inport'] = emitFunction;

powered by: WebSVN 2.1.0

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