Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
59
Добавлен:
14.04.2015
Размер:
2.03 Mб
Скачать

178

Chapter 6. Macro Processing Language

 

 

EVAL Function

The MPL processor function EVAL accepts an expression as an argument and returns the decimal character representation of it's result.

The syntax of the EVAL function is:

%EVAL (expression)

The expression arguments must be a legal expression with already defined macro identifiers, if any.

Source text

%SET

(CNT, 10)

%' define variable CNT'

%SET

(OFS, 20)

%' define variable OFS'

MOV

R15,#%EVAL (%CNT+1)

 

MOV

WR14,#%EVAL (14+15*200)

 

MOV

R13,#%EVAL (-(%CNT + %OFS - 1))

 

MOV

R2,#%EVAL (%OFS LE %CNT)

 

MOV

R7,#%EVAL (%OFS GE %CNT)

 

Output text

MOV R15,#11

MOV WR14,#3014

MOV R13,#-29

MOV R2,#0

MOV R7,#1

6

Keil Software — A51/AX51/A251 Macro Assembler and Utilities

179

 

 

Logical Expressions and String Comparison

The following MPL processor functions compare two balanced-text string arguments and return a logical value based on that comparison. If the function evaluates to TRUE, then it returns a value of 1. If the function evaluates to FALSE, then it returns a value of 0. The list of string comparison functions below shows the syntax and describes the type of comparison made for each. Both arguments to these function may contain macro calls. (These MPL calls are expanded before the comparison is made).

%EQS (arg1,arg2)

True if both arguments are identical

 

%NES (arg1,arg2)

True if arguments are different in any way

 

%LTS (arg1,arg2)

True if first argument has a lower value than second

 

 

 

argument

 

%LES (arg1,arg2)

True if first argument has a lower value then second

 

 

 

argument or if both arguments are identical

 

%GTS (arg1,arg2)

True if first argument has a higher value than second

 

 

 

argument

 

%GES (arg1,arg2)

True if first argument has a higher value than second

 

 

 

argument or if both arguments are identical

 

Example

 

 

 

 

 

6

 

 

 

 

%EQS (A251, A251)

 

0 (FALSE), the space after the comma is part of the

 

 

 

second argument

 

 

 

 

 

LT%S (A251,a251)

 

1 (TRUE), the lower case characters have a higher ASCII

 

 

 

 

value than upper case

 

 

 

 

 

 

%GTS (10,16)

 

0 (FALSE), these macros compare strings not numerical

 

 

 

 

values. ASCII '6' is greater than ASCII '1'

 

 

 

 

 

 

%GES (a251,a251 )

 

0 (FALSE), the space at the end of the second argument

 

 

 

 

makes the second argument greater than the first

 

%*DEFINE (VAR1) (A251)

1 (TRUE) expands to:

 

%*DEFINE (VAR2) (%VAR1)

 

 

%EQS (%VAR1,%VAR2) %EQS(A251,A251)

Соседние файлы в папке HLP