Instruction Set
4-154
MOV
MOV
Examples
This example defines and sets up the stack for a program.
This example for the SD186EM demonstration board controls the LEDs that are mapped
(using negative logic) to eight of the microcontroller’s programmable input/output (PIO) pins
according to the signal levels in AL. Because some of the LEDs on the board are mapped
to the low eight PIO pins (5–0)—and some are mapped to the next eight PIO pins (15–
14)—the example duplicates the signal levels in AH. Before writing the PIO signal levels
to the PIO Data 0 (PDATA0) register, the example uses NOT to convert them to negative
logic.
This example sets up the Data Segment (DS) register and the Extra Segment (ES) register
with the same segment address. This is useful if you will be using MOVS to copy one string
to another string stored in the same segment. If you set up DS and ES with different segment
addresses, you must copy the value in one of them to the other—or override the source
segment—before using MOVS.
; define stack segment
SEG_STACK
SEGMENT
’STACK’
DB
500 DUP (?)
STACK:
SEG_STACK
ENDS
; set up stack (in code segment)
MOV
AX,SEG_STACK
; load stack segment into SS
MOV
SS,AX
; SS points to SEG_STACK
MOV
AX,STACK
; load stack offset into SP
MOV
SP,AX
; SP points to STACK
; control LEDs mapped using negative logic
; load eight LED signal levels into AL
...
; write to LEDs
MOV
DX,PIO_DATA0_ADDR
; address of PDATA0 register
MOV
AH,AL
; copy AL to AH
NOT
AX
; LEDs are negative logic
OUT
DX,AX
; write out signals to port
; set up DS and ES with same segment address
; direct assembler that both DS and ES point to
; the same segment of memory
ASSUME
DS:SEG_C, ES:SEG_C
; set up DS and ES with SEG_C segment
; (can’t copy directly from memory location
; to segment register)
MOV
AX,SEG_C
; load same segment into DS and ES
MOV
DS,AX
; DS points to SEG_C
MOV
ES,AX
; ES points to SEG_C
Содержание 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...