Epson S5U1C63000A Computer Accessories User Manual


 
CHAPTER 4: ASSEMBLER
60 EPSON S5U1C63000A MANUAL
(S1C63 FAMILY ASSEMBLER PACKAGE)
Precautions
Minus numbers -1 to -32768 are handled as 0xffff to 0x8000.
The assembler handles expressions as 16-bit data. Pay attention to the data size when using it as 4-bit
immediate data, especially when it has a minus value.
Example:
ld %a,-2+1 ... NG. It will be expanded as "ld a,0xffff".
ld %a,(-2+1)&0xf ... OK. It will be expanded as "ld a,0xf".
Expressions are calculated with a sign (like a signed short in C language).
Pay attention to the calculation results of the >>, / and % operators using hexadecimal numbers.
Example:
.set NUM1 0xfffe/2 ... -2/2 = -1 (0xffff)
The / and % operators can only be used within the range of +32767 to -32768.
.set NUM2 0xfffe>>1 ... -2>>1 = -1 (0xffff)
Mask as (0xfffe>>1)&0x7fff.
When using an expression in a #define statement, it will be expanded as is. Pay attention when a
number is defined using the #define pseudo-instruction.
Example:
#define NUM1 1+1
ld %a,NUM1*2 ... This will be expanded as "ld %a, 1+1*2" (=3).
#define NUM2 (1+1)
ld %a,NUM2*2 ... This will be expanded as "ld %a, (1+1)*2" (=4).
Do not insert a space or a tab between an operator and a term.
4.5.9 Location Counter Symbol "$"
The address of each instruction code is set in the 16-bit location counter when a statement is assembled. It
can be referred using a symbol "$" as well as labels. "$" indicates the current location, thus it can be used
for relative branch operation. The operators can be used with this symbol similar to labels.
Example: jr $ ... Jumps to this address (means endless loop).
jr $+2 ... Jumps to two words after this address.
jr $-10 ... Jumps to 10 words before this address.
jr $+16+(16*(BLK>16)) ... Operators and defined symbols can be used.
Precaution
When the address referred to relatively with "$" is in another section, it should be noted if the in-
tended section resides at the addressed place, because if the section is relocatable, the absolute
address is not fixed until the linking is completed.
4.5.10 Optimization Branch Instructions for Old Preprocessor
The old version of the S1C63 preprocessor has optimization branch instructions for optimizing the
extension code. Since this function is supported by the linker in the current version, they are expanded
without an extension code in the assembler. The relative distance to the label does not affect this expan-
sion.
Optimization Branch Instruction Mnemonic after Expansion
xjr LABEL jr LABEL
xjrc LABEL jrc LABEL
xjrnc LABEL jrnc LABEL
xjrz LABEL jrz LABEL
xjrnz LABEL jrnz LABEL
xcalr LABEL calr LABEL