assume cs:codesg,ds:datasg,ss:stacksg
datasg 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年的 21个字符串, (字节)
dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
dd 345982,590827,803530,1183000,1843000,27759000,3753000,4649000,5937000
;********以上是21年的公司总收入的21个word型数据(双字)
dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
dw 11542,14430,15257,17800
;********以上是21年公司雇员人数 单位(字)
datasg ends
stacksg segment
;栈区代码存放位置
dd 0,0,0,0,0,0,0,0
stacksg ends
codesg segment
start:
;***************初始化寄存器部分**************************
mov ax,datasg
mov ds,ax
mov si,0
mov bx,0
mov ax,0b800h
mov es,ax
mov di,10
mov ax,20h
mov es:[di],ax
add di,160
mov ax,stacksg
mov ss,ax
mov sp,32
mov cx,21
call str_push
mov ax,4c00h
int 21h
str_push: ;保存现场
push si
push bx
;************** 整理数据转变字符串保存到显存内存段中 ********************
str_stor:
push di
push cx
mov al,ds:[bx+0] ;
mov ah,82h
mov es:[di],ax ;
add di,2 ; 对于年份的整理
mov al,ds:[bx+1] ;
mov ah,82h
mov es:[di],ax ;
add di,2
mov al,ds:[bx+2] ;
mov ah,82h
mov es:[di],ax ;
add di,2 ; 对于年份的整理
mov al,ds:[bx+3] ;
mov ah,82h
mov es:[di],ax ;
add di,18 ;
mov ax,ds:[bx+54h] ;
push ax
mov dx,ds:[bx+54h+2] ; 转换收入数据成字符串存入
push dx
call dtoc ; 转化函数入口
add di,20
mov ax,ds:[si+0a8h+0] ;
mov dx,0 ; 转换收入数据成字符串存入
call dtoc ; 转化函数入口
add di,20
pop dx
pop ax
mov cx,[si+0a8h+0]
div cx ;
mov dx,0
call dtoc ; 转化函数入口
pop cx
pop di
add di,160
add si,2
add bx,4
loop str_stor
str_ok:
pop bx
pop si
add di,40
ret
;************************** str 子程序结束 *********************
;************************** 防溢出 div运算 ********************
dtoc:
push bx
push si
push di
mov bx,0
dtocdd:
push bx
push ax ;先计算高位,再计算低位。低位先入栈
mov cx,10
mov ax,dx
mov dx,0 ;
div cx ;
mov bx,ax ;保存ax
pop ax ;弹出ax计算低位
div cx
add dl,30h
mov cl,dl ;余数保存在cl里
mov byte ptr es:[di],cl ;余数入显存
inc di ;di指针增加
mov dx,bx ;dx保存的是最终结果的高位、
mov bx,cx
mov cx,ax
pop bx
inc bx
push es:[di-1]
jcxz dtocdd_head
jmp short dtocdd
dtocdd_head:
mov cx,bx
mov ax,di
sub ax,cx
mov di,ax
dtocdd_mid:
pop dx
push cx
mov bx,dx
mov dh,82h
mov word ptr es:[di],dx
add di,2
pop cx
jcxz dtocdd_ok
loop dtocdd_mid
dtocdd_ok:
pop di
pop si
pop bx
ret
;************************** 防溢出 div结束 ********************
codesg ends
end start
王爽汇编 课程设计1 笔记
最新推荐文章于 2022-10-27 20:01:28 发布