Instruction Set
4-158
MOVS
MOVS
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.
; 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
PUSH
ES
; save ES
; load source offset (segment = DS)
LEA
SI, SIZE STRING - TYPE STRING
; load dest. segment (DS) into ES and offset into DI
LES
DI,ES:SIZE ES:STRING-TYPE ES: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
POP
ES
; restore saved ES
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...