|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
代码:- assume cs:codesg,ds:datasg,ss:stacksg,es:table
- table 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个字符串(0 - 53h) 84
- dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
- dd 345980,590827,803530,1183000,1843000,2795000,3753000,4649000,5937000
- ;以上是表示21年公司总收入的21个dword型数据(54h - A7h)84
- dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
- dw 11542,14430,15257,17800
- ;以上是表示21年公司雇员人数的21个word 型数据(A8h - D1h)
- dw 5,3,42,104,85,210,123,111,105,125,140,136,153,211,199,209,224,239
- dw 260,304,333;(D2h -FBh )
- table ends
- datasg segment
- dw 21 dup(0)
- datasg ends
- stacksg segment
- dw 20 dup(0)
- stacksg ends
- codesg segment;实验要求:将datasg段中的数据输出
- start: mov ax,datasg
- mov ds,ax
-
- mov ax,table
- mov es,ax
-
- mov ax,stacksg
- mov ss,ax
- mov sp,40
- ;初始化各段
-
-
- mov si,0
- mov cx,21
- push cx
-
- mov dh,1
- mov dl,1;输出属性
- mov cl,2
- mov si,0
- mov di,0
- mov bx,0
-
- _out_put: mov ax,es:[bx] ;年份
- mov [si],ax
- mov ax,es:[bx].2
- mov [si+2],ax
-
- mov ax,es:[bx+54h];收入
- mov dx,es:[bx+56h]
- add si,6
- call dtoc
-
- mov ax,es:[di+0A8h];人数
- add si,2
- call dtoc
-
- mov ax,es:[di+0D2h]
- add si,2
- call dtoc
- inc si
- mov byte ptr [si],0
- mov si,0;索引字符串首地址
-
- call show_str
-
- inc dh;下一行
- add bx,4
- add di,2
- pop cx
-
- loop _out_put
-
- mov ax,4c00h
- int 21h
- show_str: ;将指定字符串 (以0结尾)输出到屏幕
- ;参数: 1.输出字符串的行 (dh 0-24)
- ; 2.输出字符串的列 (dl 0-79)
- ; 3.输出字符串的颜色(cl)
- ; 4.字符串起始地址si
- ;返回值: 无
- push ax
- push es
- push si
- push bx
- push dx
- push cx
- mov ax,0b800h ;载入显存地址
- mov es,ax
-
- mov bl,dl
- mov bh,0
- mov ax,160;行*160+列
- mul dh
- add bx,ax;指向显存首次显示地址
-
- show_react: mov cl,[si]
- mov ch,0
- jcxz show_return
- mov es:[bx],cl
- pop cx
- mov es:[bx+1],cl
- push cx
- inc si
- add bx,2
- jmp short show_react
- show_return: pop cx
- pop dx
- pop bx
- pop si
- pop es
- pop ax
- ret
-
- divdw: ;功能:进行不会溢出的除法运算,被除数为dword 型,除数为word型,结果为dword型。
- ;参数: 1.(ax) = dword 型数据的低16位
- ; 2.(dx) = dword 型数据的高16位
- ; 3.(cx) = 除数
- ;返回值: (dx) = 结果的高16位,(ax) = 结果的低16位
- ; (cx) = 余数
-
- ;X:被除数,范围:[0 - FFFFFFFF]
- ;N:除数,范围:[0,FFFF]
- ;H:X高16位,范围:[0,FFFF]
- ;L:X低16位,范围:[0,FFFF]
- ;int(): 描述性运算符,取商。
- ;rem();描述性运算符,取余数。
- ;公式:X/N = int (H/N)*65536 + [rem(H/N)*65536+L]/N
- push bx
- push ax
-
- mov ax,dx
- mov dx,0
- div cx;ax为商,dx为余数,dx作为二次除法的高位
- mov bx,ax
- pop ax
- div cx
- mov cx,dx
- mov dx,bx
- pop bx
- ret
- dtoc: ;功能: 将 word 型数据转变为10进制数的字符串,字符串以0为结尾符
- ;参数:(ax)=dword 型数据的低16位
- ; (dx)=dword 型数据的高16位
- ; ds:si指向字符串的首地址
- ;返回: 无
- ;思路:除10求余+30h
- push di
- push ax
- push cx
- push dx
- push si
- mov di,0
- mov cx,10d
- dtoc_div:
- call divdw
- mov cx,ax
- jcxz dtoc_ok
- add dx,30h
- push dx;字符入栈
- inc di
- jmp short dtoc_div
- dtoc_ok:
- add dx,30h
- push dx
- mov cx,di
-
- dtoc_loop: pop [si]
- inc si
- loop dtoc_loop
- ; mov byte ptr [si],0
- pop si
- pop dx
- pop cx
- pop ax
- pop di
- ret
-
- codesg ends
- end start
-
-
-
复制代码
Debug调试:
不知道哪里出问题了,看了一天了,哪位大神帮下呗。 |
|