|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- assume cs:code
- 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年的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年公司总收入的21个dword型数据
-
- 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型数据
- data ends
- table segment
- db 16 dup (0)
- table ends
- stack segment
- db 64 dup (0)
- stack ends
- code segment
- start: mov ax,data
- mov es,ax
- mov ax,table
- mov ds,ax
- mov si,0
-
- mov ax,stack
- mov ss,ax
- mov sp,64
-
- mov bx,0
- mov di,0
- mov dh,1
- mov cx,21
- s: push cx
- mov ax,es:[bx]
- mov [si],ax
- mov ax,es:[bx+2]
- mov [si+2],ax
- mov byte ptr [si+4],0
- mov cl,00000111B
- mov dl,1
- call show_str
-
- push dx
- mov ax,es:[bx+84]
- mov dx,es:[bx+86]
- call dtocdw
- pop dx
- add dl,10
- call show_str
-
- mov ax,es:[di+168]
- call dtoc
- add dl,10
- call show_str
-
- push dx
- mov ax,es:[bx+84]
- mov dx,es:[bx+86]
- div word ptr es:[di+168]
- call dtoc
- pop dx
- add dl,10
- call show_str
-
- inc dh
- add bx,4
- add di,2
- pop cx
- loop s
-
- mov ax,4c00h
- int 21h
- ;名称:show_str
- ;功能:在指定的位置,用指定的颜色,显示一个用0结束的字符串
- ;参数:(dh)=行号(取值范围0~24),(dl)=列号(取值范围0~79)
- ; (cl)=颜色,ds:si指向字符串的首地址
- ;返回:无
- show_str:
- push ax
- push es
- push si
- push di
- push cx
-
- mov ax,0B800h
- mov es,ax
- mov al,0A0h
- mul dh
- mov di,ax
- mov al,2
- mul dl
- add di,ax
- mov al,cl
- mov ch,0
- s0: mov cl,[si]
- jcxz ok0
- mov es:[di],cl
- inc di
- mov es:[di],al
- inc si
- inc di
- jmp short s0
-
- ok0:pop cx
- pop di
- pop si
- pop es
- pop ax
- ret
- ;名称:dtoc
- ;功能:将word型数据转变为表示十进制数的字符串,字符串以0为结尾符
- ;参数:(ax)=word型数据
- ; ds:si指向字符串的首地址
- dtoc: push bx
- push dx
- push ax
- push cx
- push si
-
- mov bx,0
- s1: mov cx,0Ah
- mov dx,0
- div cx
- push dx
- inc bx
- mov cx,ax
- jcxz ok1
- jmp short s1
- ok1:mov cx,bx
- s2: pop ax
- add al,30h
- mov [si],al
- inc si
- loop s2
- mov byte ptr [si],0
-
- pop si
- pop cx
- pop ax
- pop dx
- pop bx
- ret
- ;名称:dtocdw
- ;功能:将dword型数转变为表示十进制数的字符串,字符串以0位结尾符。
- ;参数:(ax)=dword型数据的低16位
- ; (dx)=dword型数据的高16位
- ; ds:si指向字符串的首地址
- dtocdw:
- push ax
- push bx
- push cx
- push dx
- push si
-
- mov bx,0
- s3: mov cx,0Ah
- call divdw
- push cx
- inc bx
- mov cx,dx
- jcxz s4
- jmp short s3
-
- s4: mov cx,ax
- jcxz ok2
- jmp short s3
-
- ok2:mov cx,bx
- s5: pop ax
- add al,30h
- mov [si],al
- inc si
- loop s5
- mov byte ptr [si],0
-
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- ;名称:divdw
- ;参数:(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
- push ax
- mov ax,bx
- div cx
- mov cx,dx
- pop dx
-
- pop bx
- ret
-
- code ends
- end start
复制代码 |
|