
Instruction Set
4-249
XLAT
XLAT
Examples
This example translates a string of ASCII numbers in memory to unpacked decimal digits.
The microcontroller translates the numbers, one by one, from first to last.
This example translates the offset (base+index) of a byte within a table in memory to the
value of that byte.
; defined in SEG_D segment
TABLE
DB
0,1,2,3,4,5,6,7,8,9
STRING
DB
”0123456789”
; notify assembler: DS and ES specify the
; same segment of memory
ASSUME DS:SEG_D, ES:SEG_D
; set up DS and ES with the same segment address
MOV
AX,SEG_D
; load segment into DS and ES
MOV
DS,AX
; DS points to SEG_D
MOV
ES,AX
; ES points to SEG_D
; translate ASCII numbers to unpacked decimal digits
; set up for string operation
LEA
SI,STRING
; load source offset (segment = DS)
LEA
DI,STRING
; load dest. offset (segment = DS)
MOV
CX,10
; set up counter
CLD
; process string from low to high
LEA
BX,TABLE
; load table base (segment = DS)
ASCII2BCD:
; translate bytes
LODSB
; copy ASCII # from string to AL
XLATB
; translate to unpacked decimal
STOSB
; copy back to string
LOOP
ASCII2BCD
; while CX is not 0, jump
; to top of loop
; defined in SEG_B segment
TABLE
DB
3,6,12,24,48,96,192
; notify assembler: DS and ES point to
; different segments of memory
ASSUME
DS:SEG_A, ES:SEG_B
; set up DS and ES with different segment addresses
MOV
AX,SEG_A
; load one segment into DS
MOV
DS,AX
; DS points to SEG_A
MOV
AX,SEG_B
; load another segment into ES
MOV
ES,AX
; ES points to SEG_B
; translate index to component (override default segment)
MOV
AL,3
; set up index: AL = 3
LEA
BX,ES:TABLE
; load table base into BX
XLAT
ES:[BX]
; translate: AL = 24
Summary of Contents for Am186 Series
Page 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Page 10: ...Table of Contents x...
Page 18: ...Programming 1 8...
Page 40: ...Instruction Set Listing 3 14...