汇编题目:数字转字符,并在窗口上显示出来

程序题目:将数字以十进制的形式显示在屏幕上

assume cs:codesg

data segment
db 16 dup(0)
dw 123,12666,4,8,79
data ends

stack segment
db 100 dup(0)
stack ends

codesg segment
start:mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,100
mov cx,5
mov bx,0
mov ax,800h
mov es,ax

s:
push cx
mov ax,ds:[16+bx]
mov di,0
s0:
xor dx,dx
mov cx,10
div cx
add dx,30h
;mov ds:[di],dx
push dx
inc di
mov cx,ax
inc cx
loop s0

xor si,si
mov cx,di
s1:
pop ax
mov ds:[si],al
inc si
loop s1
mov ax,0
mov ds:[si],ax

mov si,ds
mov di,0
mov dx,es
call showStr
add dx,100h
mov es,dx
pop cx
add bx,2
loop s

mov ax,4c00h
int 21h

;si表示数据首地址,di表示数据首地址的偏移,
;dh表示行,dl表示列,
showStr:
push ax
push bx
push cx
push dx
push es
mov ax,0b800h
mov es,ax
push ds
mov ds,si

xor ax,ax
mov al,dh
mov bx,160
mul bl
push si
mov si,di
push ax    ;
xor ax,ax
mov al,dl
mov bl,2
mul bl
;push al    ;列
mov di,ax    ;
pop bx    ;
;xor cx,cx
mov al,0ech
showRead:
mov cl,ds:[si]
jcxz back
mov es:[bx+di],cl
inc di
mov es:[bx+di],al
inc si
inc di
jmp showRead
back:
pop si
pop ds
pop es
pop dx
pop cx
pop bx
pop ax
ret

codesg ends
end start


以上程序为自己编写,由于刚学汇编,所以可能会有很多错误,希望你能指正,大神!!!

你可能感兴趣的:(汇编题目:数字转字符,并在窗口上显示出来)