打印空格到 8086 汇编中的每个输入
Print spaces to every inputs in 8086 assembly
我找到了关于此的类似搜索,但对我来说不是很清楚。我试图在用汇编语言 8086 打印的每个字母中添加 spaces。
到目前为止我所做的是将 space 放在循环中,但它显示不同的字符并打印完全相同的字符并为嵌套循环实现另一个推入和弹出但没有任何效果。
不知道是不是我哪里做错了,因为大部分数据都存储在DL寄存器中
.stack
.code
start:
mov ah, 6
mov bh, 02h
mov cx, 0
mov dx, 184fh
int 10h
mov ah,2
mov bh,0
mov dh,11
mov dl,14
int 10h
mov cx,10
mov ah,2
mov dl,' '
push bx
mov ah,2
mov dl,'J'
x: int 21h
dec dl
push cx
inc bx
pop cx
pop bx
loop x
pop cx
mov ah,4ch
int 21h
end start
你似乎不明白 push
和 pop
有什么用。
push cx
inc bx
pop cx
仅当代码序列(程序中的inc bx
)以某种方式更改了saved/restored寄存器时,才需要使用push cx
和pop cx
封装部分代码cx
如果你需要 cx
按顺序不变。
注意 x
和 loop x
之间的循环中的不平衡 pop bx
。这将在每次迭代(10 次)中将堆栈指针增加 2,从而导致程序崩溃。
DOS 函数Int 21/AH=02h 打印DL
中的字符,它会推进光标位置,因此不需要滚动window 和设置光标位置的所有琐事。
此代码,与 TASM 4.0 组装为 tasm Connor.asm
并与 TLINK 3.01 链接
as tlink /t Connor.obj
给出可执行文件 Connor.com
打印 JIHJFEDCBA
.
如果您打算在每个字母后面添加一个 space,只需将 Int 21
的另一个调用插入您的循环(并且不要忘记 save/restore DL
而 space 被打印)。
model tiny
.code
org 256
start:
mov cx,10 ; Number of characters.
mov ah,2 ; DOS function WRITE CHARACTER
mov dl,'J' ; Start with this character.
x:int 21h ; Write DL and advance cursor.
dec dl ; Prepare the next character.
loop x ; Repeat 10 times
ret ; Terminate COM program.
end start
我找到了关于此的类似搜索,但对我来说不是很清楚。我试图在用汇编语言 8086 打印的每个字母中添加 spaces。 到目前为止我所做的是将 space 放在循环中,但它显示不同的字符并打印完全相同的字符并为嵌套循环实现另一个推入和弹出但没有任何效果。
不知道是不是我哪里做错了,因为大部分数据都存储在DL寄存器中
.stack
.code
start:
mov ah, 6
mov bh, 02h
mov cx, 0
mov dx, 184fh
int 10h
mov ah,2
mov bh,0
mov dh,11
mov dl,14
int 10h
mov cx,10
mov ah,2
mov dl,' '
push bx
mov ah,2
mov dl,'J'
x: int 21h
dec dl
push cx
inc bx
pop cx
pop bx
loop x
pop cx
mov ah,4ch
int 21h
end start
你似乎不明白 push
和 pop
有什么用。
push cx
inc bx
pop cx
仅当代码序列(程序中的inc bx
)以某种方式更改了saved/restored寄存器时,才需要使用push cx
和pop cx
封装部分代码cx
如果你需要 cx
按顺序不变。
注意 x
和 loop x
之间的循环中的不平衡 pop bx
。这将在每次迭代(10 次)中将堆栈指针增加 2,从而导致程序崩溃。
DOS 函数Int 21/AH=02h 打印DL
中的字符,它会推进光标位置,因此不需要滚动window 和设置光标位置的所有琐事。
此代码,与 TASM 4.0 组装为 tasm Connor.asm
并与 TLINK 3.01 链接
as tlink /t Connor.obj
给出可执行文件 Connor.com
打印 JIHJFEDCBA
.
如果您打算在每个字母后面添加一个 space,只需将 Int 21
的另一个调用插入您的循环(并且不要忘记 save/restore DL
而 space 被打印)。
model tiny
.code
org 256
start:
mov cx,10 ; Number of characters.
mov ah,2 ; DOS function WRITE CHARACTER
mov dl,'J' ; Start with this character.
x:int 21h ; Write DL and advance cursor.
dec dl ; Prepare the next character.
loop x ; Repeat 10 times
ret ; Terminate COM program.
end start