
Instruction Set
4-139
LES
LES
Examples
This example copies several of the characters in a string stored in memory to a series of
bytes in the same string that overlap the original characters. The microcontroller copies the
bytes, one by one, from last to first to avoid overwriting the source bytes.
Related Instructions
If you want to
See
Load a full address stored in a doubleword into DS and another register
LDS
Load the offset of a memory component into a register
LEA
; defined in SEG_1 segment
STRING
DB
”Am186EM*”,8 DUP (?); source and dest.
STRING_ADDR
DD
STRING
; full address of STRING
NUMCHARS
EQU
8
; copy eight characters
DELTA
EQU
4
; 4 bytes away
; direct assembler that DS and ES point to
; different segments of memory
ASSUME
DS:SEG_1, ES:SEG_2
; set up DS and ES with different segment addresses
MOV
AX,SEG_1
; load one segment into DS
MOV
DS,AX
; DS points to SEG_1
MOV
AX,SEG_2
; load another segment into ES
MOV
ES,AX
; ES points to SEG_2
; load source offset (segment = DS)
; SIZE and TYPE are assembler directives
LEA
SI, SIZE STRING - TYPE STRING
; load dest. segment (DS) into ES and offset into DI
LES
DI,ES(SIZE STRING-TYPE STRING-DELTA)
MOV
CX,NUMCHARS
; set up counter
STD
; process string high to low
; copy eight bytes of string to destination within string
REP
MOVS
STRING,ES:STRING
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...