8086寻址方式汇总
assume cs:code,ds:data
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'
dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
dw 11542,14430,15257,17800
data ends
table segment
db 21 dup('year summ ne ?? ')
table ends
code segment
start:
mov ax,data
mov ds,ax
mov ax,table
mov es,ax
mov bx,0
mov bp,0
mov cx,21
mov ax,0
l: push cx
mov si,0
mov cx,4
a:
mov dl,[bx][si]
mov es:[bp][si],dl ;使用bp 默认段寄存器为ss,所以须指定为es
inc si
loop a
; mov es:[bp].0[si],byte ptr ' '
mov si,0
mov cx,2
b:
mov dx,[bx].84[si]
mov es:[bp].5[si],dx
push dx ;保存dx用于后面除法计算
inc si
inc si
loop b
; mov es:[bp].5[si],byte ptr ' '
mov si,0
push bx ;对bx判断,前两项数据每个都是双字型,在定位时+4 正确,而第三项数据为字型,需处理
cmp bx,0
ja s
c:
mov dx,[bx].168[si]
mov es:[bp].10[si],dx
inc si
inc si
; mov es:[bp].10[si],byte ptr ' '
mov di,dx ;将dx值给di用于除法计算
pop bx
pop dx ;div默认使用dx存放被除数的高8位,ax存放被除数的低8位
mov ds:[210],ax ;保存ax
pop ax
div di
mov es:[bp].0dh,ax
mov ax,ds:[210] ;恢复ax
pop cx
add bp,16 ;定位下一行table
add bx,4 ;定位下一项数据
loop l
jmp v
s:
inc al
push ax ;保存al值,防止在乘法运算中被修改
mov ah,2
mul ah
sub bx,ax
pop ax
jmp c
v: mov ah,4ch
int 21h
code ends
end start