汇编网首页登录博客注册
hitlerdsaf的学习博客
博客首页博客互动【做检测题】论坛求助

我的博客

个人首页 |  我的文章 |  我的相册 |  我的好友 |  最新访客 |  文章收藏 |  论坛提问 |  友情链接 |  给我留言  
图片载入中
学习动态
最新留言
好友圈
文章收藏
友情链接

[2011-10-12 16:28] 课程设计1

图片载入中
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',   '1993',  '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, 2268, 2793, 4037, 5635, 8226
    dw  11542, 14430, 15257, 17800
;start at ds:[210]
    db 10 dup (0)
    
data ends



stack segment
    dw 32 dup (0)
stack ends

codesg segment
start:  mov ax, data
        mov ds, ax        
     
        mov ax, stack
        mov ss, ax
        mov sp, 64

        mov ax, 0B800h
        mov es, ax

        mov cx, 21
        mov bx, 0
        mov bp, 210
        mov di, 3
        mov si, 210
                
    s:  push cx
        mov ax, ds:[bx]
        mov ds:[bp], ax
        mov ax, [bx+2]
        mov ds:[bp+2], ax
        mov al, 0
        mov ds:[bp+4], al

        mov dx, di
        mov dh, dl
        mov dl, 0
        mov si, 210
         
        mov cx, 00000101B
        call show_str

        sar bx, 1
        mov ax, ds:[bx+168]
        mov dx, 0
        sal bx, 1
        add si, 10
        call dtoc
        
        mov dx, di
        mov dh, dl
        mov dl, 7
        
        mov cx, 00000101B
        call show_str

        mov ax, ds:[bx+84]
        mov dx, ds:[bx+86]
        mov si, 220
        call dtoc
        mov dx, di
        mov dh, dl
        mov dl, 20
         
        mov cx, 00000101B
        call show_str

        jmp xx
  xxx:  loop s
        jmp xxxx    

  xx:      
        mov ax, ds:[bx+84]
        mov dx, ds:[bx+86]
        sar bx,1
        mov cx, ds:[bx+168]
        sal bx,1
        call divdw
        mov si, 220
        call dtoc
        mov dx, di
        mov dh, dl
        mov dl, 30         
        mov cx, 00000101B
        call show_str        
        
        add bx, 4
        inc di
        pop cx
        jmp xxx

xxxx:        mov ax, 4c00h
        int 21h

;;function : change word data into decimal string, ended with '0'
;;input :  ax -- lower 16 bit of word data   dx---higher 16 bit of word data    ds:si--尾地址 
;;return:  none
dtoc:   ;push dx
        push bx
        ;push si
        push cx
        
        
next:   mov cx, 10
        call divdw

        add cx, 030H
        dec si
        mov ds:[si], cl

        mov cx, ax
        jcxz ok2
        jmp next
        
   ok2: mov cx, dx
        jcxz ok1

        jmp next
                
   ok1:  

        pop cx
        ;pop si
        pop bx
        ;pop dx
        ret



;;function : cannot overflow div
;;        dx -- higher 16bit of dividend   ax- lower 16bit of dividend        cx -- divisor
;;return  dx -- higher 16 bit of result    ax -- lower 16bit of result        cx --remainder
divdw:
        push bx
        push bp
        sub sp, 8
        mov bp, sp
        mov ss:[bp], ax
        ;mov ds:[28], dx
        ;mov ds:[30], cx

        ;; H/N
        mov ax, dx
        mov dx, 0
        div cx
        
        ;mov ds:[32], ax ;int(H/N)
        mov ss:[bp+4], dx ;rem(H/N)
                
        ;storage (int)H/N * 65536 
        mov bx, 0
        mov ss:[bp+6], bx
        mov ss:[bp+2], ax
        
        ;calc (rem)H/N *65536
        mov dx, ss:[bp+4]
        mov ax, 0
        
        ;(rem)H/N * 65536 + L
        add ax, ss:[bp]
        
        ;((rem)H/N * 65536 + L)/N
        div cx
        
        mov cx, dx    ;存余数
        ;两项相加
        mov dx, ss:[bp+2]
        add ax, ss:[bp+6] ; +0 可以不做

        add sp, 8
        pop bp
        pop bx       
        ret

;;function : show a string with 0 ended at certain position and color
;;dh--line no.    dl--column no.
;;cl--color       ds:si--the beginning of the string
;;return none
show_str:
        push bx
        push di 
        push ax
        push si
        push cx  
        
        
        ;;calculate the first address of the string in video memory
        mov al, dh
        mov bl, 160
        mul bl
        mov bx, ax        
        mov ah, 0
        mov al, dl
        add bx, ax
        add bx, ax
        
change: 
        mov cl, ds:[si]
        mov ch, 0
        jcxz ok        

        mov es:[bx], cl
        pop cx
        mov es:[bx+1], cl
        push cx
        inc si
        inc bx
        inc bx
        jmp short change
                
    ok: pop cx
        pop si
        pop ax
        pop di
        pop bx
        ret




codesg ends
end start
评论次数(1)  |  浏览次数(408)  |  类型(汇编作业) |  收藏此文  | 

[  hitlerdsaf   发表于  2011-10-12 18:40  ]

中间跳转的时候二级跳了,提示jump out of range ,我晕倒。二级跳显得非常不好看。唉

 
 请输入验证码  (提示:点击验证码输入框,以获取验证码