chapter eight
Descriptive definition reg symbol denotes a register, a segment register SREG described
Reg: ax, bx, CX, dx, ah, al, was, BL, ch, table, to, DL, sp, BP, is, di
sreg:ds、ss、cs、es
8.1 bx, yes, 和 bp
In 8086CPU, only four registers may be used in [......] is addressed to the memory unit
The following instructions are wrong
mov ax,[cx]
mov ax,[ax]
mov ax,[dx]
mov ax,[ds]
In [......], the four individual registers can occur, or only occur in four combinations: bxhesi, bx and di, Si and BP, BP and di
The following instruction is correct
mov ax,[bx+si+idata]
mov ax,[bp+si+idata]
The following instructions are incorrect
mov ax,[bx+bp]
mov ax,[si+di]
Just use the register bp [......], and the instruction is not given explicitly address segment, segment address is the default ss
mov ax,[bp] ;等价于mov ax,ss:[bp]
mov ax,[bp+si] ;等价于mov ax,ss:[bp+si]
8.2 data processing machine instruction in any place
Before execution instruction data, may be processed in three places: the internal CPU, memory, ports
8.3 assembler language expression data position
1, immediate (idata)
For data comprising machine instructions directly given directly (prior to execution in the instruction buffer of the CPU) in the assembly instruction
mov ax,1
add bx,2000h
mov al,'a'
2, the register
Data to be processed in the instruction register, the corresponding register names are given in the assembly instruction
3, segment address (SA) and offset address (EA)
Instruction data to be processed in memory
8.4 Addressing
[bx+idata] [bx].idata idata[bx] [bx][idata]
[bx+si+idata] [bx].idata[si] idata[bx][si]
8.5 How long instruction data to be processed
8086CPU instruction, data can be processed in two sizes, byte and word, it is to be specified in the machine instruction, the operation instruction is the word or byte operation
1, indicated by the register name
2, in the absence of a register name, the length of the memory cell specified by the operator X ptr. X may be a byte or word instructions in assembler
mov word ptr ds:[0],1
inc word ptr [bx]
inc byte ptr ds:[0]
add byte ptr [bx],2
In the memory unit access instruction does not participate in the register, it is necessary to use X ptr, otherwise the CPU can not know the unit is to be accessed by byte or word units units
Some commands are the default length, such as push
8.6 Addressing the integrated application
An entry for the DEC's (1982) as follows
Company Name: DEC
President Name: Ken Olsen
Ranking: 137
Income: 40
Known products: PDP
The data stored in the memory of FIG.
By 1988 DEC's information has been changed as follows
1, Ken Olsen in rich list ranking has risen to 38
2, DEC's income increased by $ 7 billion
3, the company's well-known series of products has become VAX
mov ax,seg
mov ds,ax
mov bx,60h
mov word ptr [bx+0ch],38
add word ptr [bx+0eh],70
mov si,0
mov byte ptr [bx+10h+si],'V'
inc si
mov byte ptr [bx+10h+si],'A'
inc si
mov byte ptr [bx+10h+si],'X'
c language has structure, you can write about this program in the style of c language
mov ax,seg
mov ds,ax
mov bx,60h
mov word ptr [bx].0ch,38
add word ptr [bx].0eh,70
mov si,0
mov byte ptr [bx].10h[si],'V'
inc si
mov byte ptr [bx].10h[si],'A'
inc si
mov byte ptr [bx].10h[si].'X'
In programming, a structured perspective on the data to be processed, the whole structure of the positioning BX (company). Each data area (company name, etc.) is positioned Idata structural body, si positioning each element in the array item
8.7 div instruction
div is a division instruction, Precautions
1, the divisor: there are two kinds of 8-bit and 16-bit, or in a memory unit reg
2, the dividend: Default in AX and AX, DX, or, if the divisor is 8-bit, 16-bit dividend, AX stored in the default, if the divisor is a 16-bit, 32-bit dividend, compared, and stored in the AX, DX , DX storing high 16, AX store low 16
3, if the divisor is 8 bits, the supplier AL, the AH stored in the remainder memory division operation, if the divisor is 16, the AX storage, stores the DX remainder
The following format
div reg
div 内存单元
div byte ptr ds:[0] ; (al)=(ax)/((ds)*16+0)的商
; (ah)=(ax)/((ds)*16+0)的余数
div word ptr es:[0] ; (ax)=((dx)*10000h+(ax))/((es)*16+0)的商
; (dx)=((dx)*10000h+(ax))/((es)*16+0)的余数
Examples
Calculated by the division instruction 100001/100
100001> 65535, deposited with the United dx and ax, the dividend is 32 bits, even if the divisor 100 can be stored in 8-bit registers, but is a 16-bit register holds the
10001 = 186A1H, so DX = 0001H AX = 86A1H
mov dx,1
mov ax,86A1H ; (dx) *10000H+(ax) = 100001
mov bx,100
div bx
After performing (ax) = 03E8H (dx) = 1
Calculated by the division instruction 1001/100
mov ax,1001
mov bl,100
div bl
8.8 dd directive
Double-word data defined dd
data segement
db 1
dw 1
dd 1
data ends
data: 3 is at a 00000001H
Computing a first data segment div data divided by the second data, the third storage unit is present and Suppliers data
data segment
dd 100001
dw 100
dw 0
data ends
The first data is double-word, use the DX and AX joint storage
mov ax,data
mov ds,ax
mov ax,ds:[0]
mov dx,ds:[2]
div word ptr ds:[4]
mov ds:[6],ax
8.9 after
And db, dw, dd, like, DUP is processed by a compiler symbol, and in conjunction with them, and, repeating the data
db 3 dup (0) ; 相当于db 0,0,0
db 3 dup (0,1,2) ; 相当于db 0,1,2,0,1,2,0,1,2
db 3 dup ('abc','ABC') ; 相当于db 'abcABCabcABCabcABC'
dup use format
db repetitions dup (duplicate data byte)
dw repetitions dup (duplicate font data)
dd repetitions dup (duplicate double word)
It is defined as the total capacity of 200 bytes of stack segment
stack segment
db 200 dup (0)
stack ends