|
|||||||||||||||||||||||||||||||||||||||||||||||||
|
Technical Support On-Line Manuals C166 User's Guide |
OperatorsOperatorsThe following operators are supported by the extended inline assembler:
The access to a high or low word of parameters or local symbols of the data types long, unsigned long, far *, huge *, or xhuge * the WORD0 and WORD2 operators must be used. C166 stores far *, huge *, or xhuge * pointers and long values with low word first, then high word. This word order is also true for long values that are assigned to CPU registers and implies that R(n) is low word and R(n+1) is high word.
The example below shows how to access long values in __asm blocks:
int XpAddUp (int n, int xhuge *pTab) {
__asm {
mov r2,word0 pTab ; get SOF part of xhuge ptr
mov r3,word2 pTab ; get SEG part of xhuge ptr
cmp n,#0 ; count zero ?
jmp cc_sle,stop ; stop if so.
mov r4,#0x0000 ; clear result
lM: exts r3,#1
add r4,[r2] ; add data
add r2,#sizeof (n) ; xptrL + 2
addc r3,#0x00 ; xptrH + 1 + Cy
sub n,#1
jmp cc_nz,lM ; loop if not eot
ret ; return result in R4
}
stop:
return (0);
}
This example generates the following code:
; FUNCTION XpAddUp (BEGIN RMASK = @0x4010)
;---- Variable 'pTab' assigned to Register 'R9/R10' ----
;---- Variable 'n' assigned to Register 'R8' ----
004E F029 mov r2,word0 pTab ; get SOF part of xhuge ptr
0050 F03A mov r3,word2 pTab ; get SEG part of xhuge ptr
0052 4880 cmp n,#0 ; count zero ?
0054 BD08 jmp cc_sle,stop ; stop if so.
0056 E004 mov r4,#0x0000 ; clear result
0058 lM:
0058 DC03 lM: exts r3,#1
005A 084A add r4,[r2] ; add data
005C 0822 add r2,#sizeof (n) ; xptrL + 2
005E 1830 addc r3,#0x00 ; xptrH + 1 + Cy
0060 2881 sub n,#1
0062 3DFA jmp cc_nz,lM ; loop if not eot
0064 CB00 ret ; need result in R4
0066 stop:
0066 E004 MOV R4,#00H
0068 CB00 RET
; FUNCTION XpAddUp (END RMASK = @0x4010)
| ||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||