
Instruction Set
4-176
POP
POP
Examples
This example copies a string of 16-bit integers in one segment of memory to a string in
another segment. The words are copied, one by one, from last to first.
; defined in SEG_A
STRING1
DW
-30000,10250,31450,21540,-16180
S1_LENGTH EQU
5
; defined in SEG_B
STRING2
DW
S1_LENGTH DUP (?)
S2_END_ADDR
DD
S SIZE STRING2 - TYPE STRING2
; notify assembler: DS and ES specify
; different segments of memory
ASSUME DS:SEG_A, ES:SEG_B
; set up segment registers with different segments
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
; copy string in segment A to string in segment B
; save ES
PUSH
ES
; set up registers and flags
LEA
SI,STRING1
; load source offset (segment = DS)
; load dest. segment into ES and offset into DI
LES
DI,ES:S2_END_ADDR
MOV
CX,S1_LENGTH
; set up counter
STD
; process string high to low
; copy source string to destination
REP
MOVSW
; restore saved ES
POP ES
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...