首页 > 代码库 > 汇编课程设计1

汇编课程设计1

要求:把试验七的数据显示在屏幕上

  

assume cs:code
stack segment
    dw 0,0,0,0,0,0,0,0
stack ends
;******************************数据段******************************
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个年份的字符串
  dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
  dd 345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000
    ;21年公司收入数据
  dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635
  dw 8226,11542,14430,15257,17800
    ;21年公司员工人数
  dd 21 dup (0)     ;21个人均年收入
  dw 10
data ends

code segment
start:
        mov ax,stack
        mov ss,ax
        mov sp,16

        mov ax,data
        mov ds,ax

        mov ax,0b800h
        mov es,ax

;计算人均收入
        mov si,84
        mov di,168
        mov bx,210
        mov cx,21

    jisuan:
        call div_dd
        add si,4
        add di,2
        add bx,4
        loop jisuan
;清屏
        call clear_scr
;显示年份数据
        mov bx,0
        mov bp,160
        mov cx,21
    year1:
        mov si,0
        push cx
        mov cx,4
    year2:
        call show_year
        add si,2
        inc bx
        loop year2
        add bp,160
        pop cx
        loop year1

;显示收入数据
        mov bx,84
        mov bp,180
        mov cx,21
    shouru:
        mov di,0
        call show_shouru
        add bx,4
        add bp,160
        loop shouru
;显示员工数据
        mov bx,168
        mov bp,200
        mov cx,21
    yuangong:
        mov di,0
        call word_show
        add bx,2
        add bp,160
        loop yuangong
;显示人均收入
        mov bx,210
        mov bp,220
        mov cx,21
    renjun:
        mov di,0
        call show_shouru
        add bx,4
        add bp,160
        loop renjun

        mov ax,4c00h
        int 21h


;dd除法运算
div_dd:
        push ax
        push dx
        mov dx,0
        mov ax,[si+2]
        div word ptr [di]
        mov [bx+2],ax
        mov ax,[si]
        div word ptr [di]
        mov [bx],ax
        pop dx
        pop ax
        ret


;清屏
clear_scr:
        push bp
        push cx
        mov bp,0
        mov cx,22
    clear1:
        mov si,0
        push cx
        mov cx,80
    clear2:
        mov byte ptr es:[bp+si],0168
        mov byte ptr es:[bp+si+1],0
        add si,2
        loop clear2
        add bp,160
        pop cx
        loop clear1
        pop cx
        pop bp
        ret

;显示一个字节的字符year
show_year:
        push ax
        mov al,[bx]
        mov es:[bp+si],al
        mov byte ptr es:[bp+si+1],02h
        pop ax
        ret

;显示dword型数据为字符串,存入显示区域
show_shouru:
        push ax
        push bx
        push cx
        push dx
        push si

        mov dx,ds:[bx+2]
        mov ax,ds:[bx]
        mov si,0
    s1:
        push ax
        mov ax,dx
        mov dx,0
        div word ptr ds:[294]
        mov bx,ax
        pop ax
        div word ptr ds:[294]
        push dx
        inc si
        mov dx,bx
        mov cx,ax
        jcxz ok1
        jmp short s1
    ok1:
        mov cx,dx
        jcxz ok2
        jmp short s1
    ok2:
        mov cx,si
    s2:
        pop ax
        add al,30h
        mov es:[bp+di],al
        mov byte ptr es:[bp+di+1],02h
        add di,2
        loop s2
        pop si
        pop dx
        pop cx
        pop bx
        pop ax
        ret

;转换word型数据为字符串
word_show:
        push ax
        push bx
        push cx
        push dx
        push si
        mov ax,ds:[bx]
        mov si,0
    s3:
        mov bl,al
        mov al,ah
        mov ah,0
        div byte ptr ds:[294]
        mov bh,al
        mov al,bl
        div byte ptr ds:[294]
        mov bl,ah
        mov ah,bh
        push bx
        mov cx,ax
        inc si
        jcxz ok3
        jmp short s3
    ok3:
        mov cx,si
    s4:
        pop ax
        add al,30h
        mov es:[bp+di],al
        mov byte ptr es:[bp+di+1],02h
        add di,2
        loop s4
        pop si
        pop dx
        pop cx
        pop bx
        pop ax
        ret

code ends
end start

 技术分享

 

汇编课程设计1