王爽《汇编》课程设计一
2011-10-27 00:43
316 查看
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'
;54h
dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
;0a8h
dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5638,8226
dw 11542,14430,15257,17800
;0d2h
db 10h dup (0) ;show_str显示的
data ends
;********************************************************************
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
;*********************************************************************
;清屏
call clear
;**********************************************************************
mov cx,21 ;共21行,循环21次
mov di,0 ;初始化
mov si,0 ;初始化
mov dh,2 ;初始化
;**********************************
display:
push cx
;**********************************
;显示年份
mov cx,4
push di
mov di,0d2h
call sent_str
pop di
push si
mov si,0d2h
mov dl,12
mov cl,111b;颜色
call show_str
pop si
;***********************************
;显示收入
push si
push dx
mov ax,54h[si]
mov dx,54h[si+2]
mov si,0d2h
call dtoc
pop dx
mov dl,26
call show_str
pop si
;**********************************
;显示雇员
push si
push dx
mov ax,0a8h[di]
mov dx,0
mov si,0d2h
call dtoc
pop dx
mov dl,40
call show_str
pop si
;**********************************
;显示人均收入
push si
push dx
push cx
mov ax,54h[si]
mov dx,54h[si+2]
mov cx,0a8h[di]
call divdw
mov si,0d2h
call dtoc
pop cx
pop dx
mov dl,56
call show_str
pop si
;**********************************
inc dh;下一行
add si,4
add di,2
pop cx
loop display
;**********************************
;返回
mov ax,4c00h
int 21h
;***********************************
;
;以下是子程序
;
;***********************************
;名称:clear
;功能:清屏
;参数:无
;返回:无
clear:
push ds
push dx
push cx
push di
push ax
mov dx,0
mov ax,0b800h
mov ds,ax
mov cx,25
clear1:
push cx
mov cx,80
clear2:
mov ds:[di],ax
inc di
inc di
loop clear2
pop cx
loop clear1
pop ax
pop di
pop cx
pop dx
pop ds
;*********************************************************************
;名称:sent_str
;功能:
;参数:
;
;返回:
sent_str:
push ax
push si
push di
add di,cx
mov byte ptr ds:[di],0
pop di
sent_str1:
mov al,ds:[si]
mov ds:[di],al
inc di
inc si
loop sent_str1
pop si
pop ax
;*********************************************************************
;名称:show_str
;功能:在指定的位置,用指定的颜色,显示以0结束的字符串。
;参数:(dh)=行号(取值范围0--24),(dl)=列号(取值范围0--79),(cl)=颜色,
; ds:si指向字符串的首地址
;返回:无
show_str:
push si
push di
push dx
push ax
push es
mov ax,0b800h
mov es,ax
mov al,0a0h
mov ah,0
mul dh
add dl,dl
mov dh,0
add ax,dx
mov di,ax
mov ah,cl
again:
cmp byte ptr ds:[si],0
jz over
mov al,ds:[si]
mov es:[di],ax
add di,2
inc si
jmp again
over:
pop es
pop ax
pop dx
pop di
pop si
ret
;************************************************************
;名称:divdw
;功能:进行不会产生溢出的除法运算,被除数dword型,除数word型结果为dword型.
;参数:(ax)=dword型数据的低16位.
; (dx)=dword型数据的高16位.
; (cx)=除数
;返回:(dx)=结果的高16位,(ax)=结果的低16位,(cx)=余数
divdw:
push bx
mov bx,ax
mov ax,dx
mov dx,0
div cx
xchg ax,bx
div cx
mov cx,dx
mov dx,bx
pop bx
ret
;************************************************************
;名称:dtoc
;功能:将dword型数据转变为表示十进制数的字符串,字符串以0为结束符.
;参数:(ax)=dword型数据低16位,(dx)=dword型数据高16位.
;返回:ds:si指向字符串首地址,字符串以0为结束符.
dtoc:
push ax
push bx
push cx
push dx
push si
push di
mov di,0
mov bx,si
sub si,si
mov byte ptr[bx][si],0 ;字符串以0结束
dtoc1:
mov cx,10
call divdw;dx=高位,ax=低位,cx=余
inc di
mov si,di
add cl,30h
dtoc_again:
mov ch,ds:[bx][si-1]
mov ds:[bx][si],ch
dec si
jne dtoc_again
mov ds:[bx][si],cl
;进行判断
mov cx,dx
jcxz next
jmp dtoc1
next:
mov cx,ax
jcxz dtoc_end
jmp dtoc1
dtoc_end:
pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
;*********************************************************************
code ends
end start
相关文章推荐
- 王爽 汇编语言 课程设计1 独立完成
- 王爽 汇编语言 课程设计1
- 汇编语言-王爽-课程设计1
- 王爽 汇编语言 实验十 课程设计1
- 王爽 汇编语言 课程设计2 修正
- 王爽 -- 汇编语言课程设计2一些问题记录
- 王爽汇编第十章课程设计精简设计~(整理)
- 汇编语言(王爽)--课程设计一
- 王爽汇编语言课程设计1
- 王爽汇编语言课程设计1
- 王爽汇编语言课程设计1
- 汇编语言(王爽) 课程设计1
- 王爽汇编语言课程设计2
- 王爽.汇编.第三版.课程设计1.答案
- 8086汇编学习小记-王爽汇编语言课程实验15及课程设计2的DOS环境
- 王爽--------汇编语言 课程设计2
- 汇编语言 王爽第二版 课程设计1
- 王爽 汇编 课程设计1
- 汇编语言 王爽(第三版)课程设计一
- 学习<<汇编语言 -王爽>>,自已完成的一道课程设计题 (5)