Assembly 读取BCD中的一对输入坐标,并使用汇编语言将光标移动到屏幕上的指定位置

Assembly 读取BCD中的一对输入坐标,并使用汇编语言将光标移动到屏幕上的指定位置,assembly,x86,Assembly,X86,这是我的节目 display macro msg lea dx,msg mov ah,09h int 21h endm .model small .data msg1 db 10h,13h,"Enter row$" msg2 db 10h,13h,"Enter Column$" row db ? col db ? .code mov ax,@data mov ds,ax display msg1 call read mov row,al display msg2 call read m

这是我的节目

display macro msg
lea dx,msg
mov ah,09h
int 21h
endm

.model small
.data
msg1 db 10h,13h,"Enter row$" 
msg2 db 10h,13h,"Enter Column$"
row db ?
col db ?

.code
mov ax,@data
mov ds,ax

display msg1
call read
mov row,al

display msg2
call read
mov col,al

mov ah,00
mov al,3
int 10h

mov ah,02
mov bh,00
mov dh,row
mov dl,col
int 10h

mov ah,01h
int 21h

mov ah,4ch
int 21h

read proc 

mov ah,01
int 21h
and al,0fh
mov bl,al

mov ah,01
int 21h
and al,0fh

mov ah,bl

MOV CL,4
SHL AH,CL
ADD AL,AH

ret 
read endp

end
所以我知道行和列的位置应该被指定为12和40,以将其放置在屏幕的中心,但是使用这个程序,它的位置不在中心

我想问题是当我接受输入时,因为当我把行值直接放在dh和DL寄存器中,把列值直接放在40,指针就在中间


有人能帮我吗?多亏了汇编中的一堆未注释的行对于没有编写它的人来说几乎是一团无法阅读的混乱

让我们一步一步来:

; first of all, set the video mode
mov ah, 0x00 ; function: set video mode
mov al, 0x03 ; video mode: 0x03
int 0x10     

; set the cursor position to 0:0 (DH:DL)
mov ah, 0x02 ; function: set cursor position
xor bh, bh ; page: 0x00
xor dh, dh ; row: 0x00
xor dl, dl ; column: 0x00
int 0x10

; read row into DH
call read_num
mov dh, dl

; if you want to, you can read a separator character between them
; call read_num

; read column into DL
call read_num

; set the cursor position again to DH:DL
mov ah, 0x02 ; function: set cursor position
xor bh, bh ; bh: just to make sure BH remains 0x00
int 0x10

...

read_num: ; will read two decimal characters from input to DL
    ; DOS interrupt for reading a single characted
    mov ah, 0x01 ; function: read a character from STDIN
    int 0x21

    and al, 0x0F ; get the number from the ASCII code
    mov bl, 0x0A
    mul bl       ; move it to the place of tens

    mov dl, al      ; dl = al*10 

    ; DOS interrupt for reading another char
    mov ah, 0x01 ; function: read a character from STDIN
    int 0x21

    and al, 0x0F
    add dl, al      ; dl = dl + al

    ret
在这段代码中,你将十分之一乘以16。你需要10的乘法。一种简单的方法是使用
aad
指令

mov ah,bl
aad        ;This is AH * 10 + AL
ret

就像我说的,光标的位置不在中间,@user35443如果你不介意的话,你能按顺序发送一次没有注释的代码吗?我不明白你的意思。你想让我怎么做?如果可以的话,只发送没有任何注释的代码,因为我没有得到正确的输出。你是说你的代码,还是我的代码没有注释?我的计划不是一个完整的计划,而是一个草图和指南。不过,有些部分可以按字面意思复制。
mov ah,bl
aad        ;This is AH * 10 + AL
ret