实验七,求指点,求交流,求优化大师!!!
ASSUME CS:CODE,DS:DATA,SS:STACKDATA 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',12 dup(0) ;12 dup(0)是为了整理内存数据
DD 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
DD 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000,0,0,0;同上
DW 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226,11542,14430,15257,17800
DATA ENDS
STACK SEGMENT
DW 8 DUP(0)
STACK ENDS
TABLE SEGMENT
DB 21 DUP('YEAR SUMM NE ?? ')
TABLE ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,16
MOV AX,TABLE
MOV ES,AX
MOV BX,0
MOV CX,21
MOV DI,0
MOV BP,0
S:
PUSH CX
MOV SI,0
MOV CX,2
B:
MOV AX,
MOV ES:,AX
MOV AX,
MOV ES:,AX
ADD SI,2
ADD DI,2
LOOP B
MOV AX,
MOV ES:,AX
MOV AX,ES:
MOV DX,ES:
DIV WORD PTR ES:
MOV ES:,AX
ADD BX,2
POP CX
ADD BP,16
LOOP S
MOV AX,4C00H
INT 21H
CODE ENDS
END START
我贴贴我的代码,大家互相学习吧:
assume cs:code,ds:data,ss:table
data segment
db '1975','1976','1977','1978','1979','1980','1981','1982'
db '1983','1984','1985','1986','1987','1988','1989','1990'
db '1991','1992','1993','1994','1995'
dd 16,22,382,1235,2390,8000,16000,24486,50065,97479
dd 140417,197514,345980,590827,803530,1183000,1843000
dd 2759000,3753000,4649000,5937000
dw 3,7,9,13,28,38,130,220,475,778,1001,1442,2258,2793
dw 4037,5635,8226,11542,11430,15257,17800
data ends
table segment
db 22 dup('year summ ne ?? ')
table ends
code segment
start: mov ax,data
mov ds,ax
mov ax,table
mov ss,ax
mov sp,160H
mov bp,0
mov bx,0
mov di,0
mov cx,21;外循环对应行,即不同年份的数据
s: push cx
mov cx,4;内循环处理复制年份
mov si,0
s0: moval, ;年份
mov ,al
inc si
loop s0
pop cx
movax,84;总收入
mov,ax
movdx,86
mov,dx
mov ax, 168;人数
mov , ax
mov ax,;人均
div word ptr
mov ,ax
add bp,16
add bx,4
add di,2
loop s
mov ax,4c00H
int 21H
code ends
end start 我觉得有点疑惑有关于这个DIV
这里被除数是32位的, 为什么没有把高16位放进DX,因为你后面把ax的当做商来处理,说明这里被除数是32位的
引用楼上的“
mov ax,;人均
div word ptr
mov ,ax
”
我刚看了视频里面也没这个, 因为在放总收入时已经把高位数据放到DX中了: movax,84;总收入
mov,ax
movdx,86
mov,dx 我也贴一下,哈哈
assume cs:codesg
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
stack segment
db 16 dup (0)
stack ends
table segment
db 21 dup ('year summ ne ?? ')
table ends
codesg segment
start:
mov ax,codesg
sub ax,24h
mov ds,ax
mov es,ax
mov bx,0
mov ss,ax
mov sp,00f0h
mov cx,21
mov di,0
MOV SI,0
s: push cx
mov cx,2
s1:
mov dx, ;前面两个4字节
mov es:,dx
mov dx,ds:
mov es:,dx
add bx,2
ADD SI,2
loop s1
mov dx,ds: ;雇员人数
mov es:,dx
add di,2
MOV DX,ES: ;除法运算
MOV AX,ES:
MOV cx,ES:
DIV cx
MOV ES:,AX
MOV AX,ES;使段地址+1
INC AX
MOV ES,AX
MOV SI,0 ;使目的地址复位
pop cx
loop s
mov ax,4c00h
int 21h
codesg ends
end start
{:10_266:}{:10_266:}
页:
[1]