Keil Logo

A51: Getting Defined Value From the Command Line


Information in this article applies to:

  • C51 All Versions

QUESTION

Using the A51 Assembler, I need to define a value via the command line. Is this possible?

ANSWER

No. The symbols you define on the command are defined with the SET keyword and it is not possible to use these as values for a DB or DW.

You may, however, use the #define directive and #include directive to define and include values from a C-style header file. For example, the following include file (ARGS.INC):

#define value 123

may be included in an assembly file.

#include "args.inc"

cseg at 30h

junk:   db      value

end

The resulting listing file shows the assembler output:

                       1     ;#include "args.inc"
                +1     2
                       3
                       4
----                   5     cseg at 30h
                       6
0030 7B                7     junk:   db      123
                       8
                       9     end

Another solution is to use multiple $IF statements to create constants that may be used in your assembler programs. For example:

$IF (VALUE = 230)
CURRENT_BOARD SET 230
$ELSEIF (VALUE = 220)
CURRENT_BOARD SET 220
$ELSEIF (VALUE = 212)
CURRENT_BOARD SET 212
$ELSE
__ERROR__ "Unrecognized value for VALUE in A51 command line."
CURRENT_BOARD SET 0
$ENDIF

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.