如何在 16 位代码中将光标向下移动一行?
How to move the cursor down a line in 16-bit code?
这是我写的代码我想像在普通键盘上一样在程序集 8086 上写,但是每次我按回车键它都会下降一行并在 RAM 中写入第二个字母我该如何修复它在不重置 ram 的情况下,用户可以从键盘写入。
data segment
; add your data here!
msg db ?
nxtline db 10,13,'$'
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
xor ax,ax
mov ah,1
xor bx,bx
mov bx,offset msg
ifpressed:
;pusha
mov ah,1
int 21h
cmp al,0Dh ;check when enter is pressed
jz nextline
mov [bx],al
add bx,2
;popa
jmp ifpressed
nextline:
lea dx, nxtline
mov ah, 9
int 21h
jmp ifpressed
reapet:
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
`
...but every time i press on enter it goes down a line...
这正是创建程序的目的。
如果您不希望发生这种情况,请从您的程序中删除接下来的两行:
cmp al,0Dh ;check when enter is pressed
jz nextline
或保留这两行但更改 nxtline 的定义(删除 13):
nxtline db 10,'$'
它不适用于我的 bios 中断汇编程序,我认为它适用于 dos 汇编程序。
尝试通过像这样更改 dl 和 dh 寄存器来手动更改列和行:
Prompt: mov si, PromptChar
mov ah, 2
mov dh, 15 # change row to 15
mov dl, 0 # change column to 0
int 10h
lodsb
mov ah, 9
int 10h
jmp short End
这是我写的代码我想像在普通键盘上一样在程序集 8086 上写,但是每次我按回车键它都会下降一行并在 RAM 中写入第二个字母我该如何修复它在不重置 ram 的情况下,用户可以从键盘写入。
data segment
; add your data here!
msg db ?
nxtline db 10,13,'$'
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
xor ax,ax
mov ah,1
xor bx,bx
mov bx,offset msg
ifpressed:
;pusha
mov ah,1
int 21h
cmp al,0Dh ;check when enter is pressed
jz nextline
mov [bx],al
add bx,2
;popa
jmp ifpressed
nextline:
lea dx, nxtline
mov ah, 9
int 21h
jmp ifpressed
reapet:
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
`
...but every time i press on enter it goes down a line...
这正是创建程序的目的。 如果您不希望发生这种情况,请从您的程序中删除接下来的两行:
cmp al,0Dh ;check when enter is pressed
jz nextline
或保留这两行但更改 nxtline 的定义(删除 13):
nxtline db 10,'$'
它不适用于我的 bios 中断汇编程序,我认为它适用于 dos 汇编程序。 尝试通过像这样更改 dl 和 dh 寄存器来手动更改列和行:
Prompt: mov si, PromptChar
mov ah, 2
mov dh, 15 # change row to 15
mov dl, 0 # change column to 0
int 10h
lodsb
mov ah, 9
int 10h
jmp short End