CHAPTER 4: ASSEMBLER

Relational operators

Examples

==

Equal

SW==0

!=

Not equal

SW!=0

<

Less than

ABC<5

<=

Less than or equal

ABC<=5

>

Greater than

ABC>5

>=

Greater than or equal

ABC>=5

&&

AND

ABC&&0xf

OR

ABC0b1010

The relational operator returns 1 if the expression is true, otherwise it returns 0.

Priority

The operators have the priority shown below. If there are two or more operators with the same priority in an expression, the assembler calculates the expression from the left.

1.

( )

High priority

2.

+ (plus sign), - (minus sign), ~

3.^H, ^L

4.*, /, % (%%)

5.+ (addition), - (subtraction)

6.<<, >>

7.==, !=, <, <=, >, >=

8.&

9.^

10.

11. &&

12.

Low priority

Examples

#defnum

BLK_HEADER_SIZE 4

 

#defnum

BLK_START

0x30+BLK_HEADER_SIZE*2

#defnum

BLK_END

 

BLK_START+4*2

 

#macro

ADD_X

ADDR

 

 

ldb

%ext,(ADDR*2)^H

... Can be used in macros.

 

add

%x,(ADDR*2)^L

 

#endm

 

 

 

 

 

ldb

%ext,BLK_START^H

; %x=BLK_START

 

ldb

%xl, BLK_START^L

 

 

ld

[%x],0b11&0x110

 

 

ldb

%ext, ~BLK_END^H

; cmp %x, BLK_END

 

cmp

%x,

BLK_END^L

 

 

ADD_X

(0x1200+0x34)*2

; %x+=0x1234*2

S5U1C63000A MANUAL

EPSON

59

(S1C63 FAMILY ASSEMBLER PACKAGE)