嘤嘤嘤,这个轮子有点恶心,造了好久
首先,发现一个问题.
前面造的print这个函数,它输出字符串时,低地址内存内的内容在前面,所以用在这里有问题,所以要略微更改.
今天的题目是,把在系统中16位存储的数字按10进制输出到屏幕指定行列,代码如下:
;例子 596874(10)=91B8A(16)=1001 0001 1011 1000 1010(2)
assume cs:code,ds:data,ss:stack
data segment
dw 100 dup (0) ;这里必须有容量,用于临时存储待输出的字符串
data ends
stack segment
dw 19 dup (0)
stack ends
code segment
start: mov ax,data ;076Ah
mov ds,ax
mov bx,0
mov ax,stack ;0777h
mov ss,ax
mov sp,38
;模拟使用环境
mov ax,1B8Ah
mov dx,9h
call far ptr btod
mov ax,4c00h
int 21h
btodstop: mov cx,di
add cl,30h
mov ds:[bx],cl
pop di
pop cx
mov dh,8
mov dl,3
mov ah,00000010b
call far ptr btodprint
pop bx
pop dx
pop ax
retf
btod: push ax
push dx
push bx
push cx