A data processing computer, computing machine, there are two problems:
- Processing the position data
- The length of the process data
These two issues must be given instructions (sometimes explicit, sometimes implicit), whether those calculators will not work in the machine instructions.
Descriptive definition of symbols:
- REG (Register): ax, bx, cx, dx, ah, al · ·· sp, bp, si, di
- SREG (segment registers): ds, ss, cs, es
bx, si, di and bp
to sum up:
- In 8086, only these four registers can be used
[...]
for memory addressing. - In
[...]
, they can be individually present or appear in combination (combination must be no other registers, but can have Idata) - Bp segment address of the default (and bx, si, di ds are different) in the ss
Data processing machine instruction in any place
The data processing can be divided into three categories: read, write, operation
before the instruction is executed, data can be processed in three places: the internal cpu, memory, port
Assembler language expression data location
- Immediate (Idata)
of the data directly in the machine instructions comprising (prior to execution in the instruction buffer cpu), in assembly language known as: immediate (Idata) - Register
data to be processed is stored in the instruction register, the corresponding register name given - Segment address (SA) and offset address (EA)
data in the memory, the position data given by SA + EA
Addressing
Positioning the memory cell method, it is called addressing
How long instruction data to be processed
The front is divided into the given implicit and explicit given, for example, by a register and push, pop or the like is implicitly given.
Add can not explicitly specify the data length, it requires explicit data given length. The method of explicit data length has given ptr
an instruction, for example:
mov word ptr ds:[0], 1
mov byte ptr ds:[0],1
inc ...
add ...
div instruction
div instruction is a divide instruction
dividend / divisor = Remainder List ......
- Divisor: There are two kinds of 8-bit and 16-bit (byte and word), or a memory cell in the reg
- Dividend: Default dx or ax and ax put in 8 bits when a divisor, dividend, compared with 16, ax stored in the default. When the divisor bit 16, compared with 32-bit dividend, dx high storage 16, storing the lower 16 bits AX.
- Results: The divisor is 8, the al storage providers, ah store the remainder. If the divisor is 16, the storage provider ax, dx store the remainder.
Dd directive
Useful been to db, and dw, for example:
db 1 ;占1个字节
dw 1 ;占1个word(2个字节)
dd used to define the dword (double word, Gemini). dd 1
Occupy the 2 word (4 bytes).
after
dup operator is used to define a data identified by the compiler. And db, dw, dd with the use, for repeated definition data.
For example:
DB DUP. 3 (0)
DB DUP. 3 (0,1,2)
DB DUP. 3 ( 'ABC', 'the ABC')
Experiment 7
answer
assume cs:code, ds:data, es:table
data segment
db '1975', '1976', '1977', '1978', '1979', '1980', '1981', '1982', '1983'
db '1984', '1985', '1986', '1987', '1988', '1989', '1990', '1991', '1992'
db '1993', '1994', '1995'
; 21年, 4*21=84个字节
dd 16, 22, 382, 1356, 2390, 8000, 16000, 24486, 50065, 97479, 140417, 197514
dd 345980, 590827, 803530, 1183000, 1843000, 2759000, 3753000, 4649000, 5937000
; 21年每年总收入,84字节
dw 3, 7, 9, 13, 28, 38, 130, 220, 476, 778, 1001, 1442, 2258, 2793, 4037, 5635, 8826
dw 11542, 14430, 15247, 17800
; 21年每年雇佣人数, 42字节
data ends
table segment
db 21 dup ('year summ ne ?? ')
table ends
stack segment
dw 16 dup(0)
stack ends
code segment
start:
mov ax, data
mov ds, ax
mov ax, table
mov es, ax
mov bx, 0
mov si, 0
mov di, 0
mov cx, 21
s0:
mov ax, 0[bx].[0]
mov es:[si].[0], ax
mov ax, 0[bx][2]
mov es:[si].[2], ax
mov ax, 84[bx].[0]
mov es:[si].[5], ax
mov ax, 84[bx][2]
mov es:[si].[7], ax
mov ax, 168[di].[0]
mov es:[si].[10], ax
mov ax, es:[si].[5] ; 计算人均收入
mov dx, es:[si].[7]
div word ptr es:[si].[10]
mov es:[si].[13], ax
add bx, 4
add si, 10H
add di, 2
loop s0
mov ax, 4c00H
int 21H
code ends
end start
dup table 21 defines the actual segment * 16 bytes, corresponding to the positions also fill the space.