简体   繁体   English

在8086汇编中打印的每个数字之间打印空格

[英]Print spaces between every numbers that's printed in 8086 Assembly

I want to print a 2D array in 8086 Assembly and I am stuck in the last few steps of the assignment. 我想在8086 Assembly中打印2D数组,但我陷入了作业的最后几个步骤。

For example, I need my output to be: 例如,我需要输出为:

1 2 3 4 5
6 7 8 9 10

instead of 代替

12345
678910

I already have a nest loop for printing out the array but I don't know how to print spaces between the numbers. 我已经有一个嵌套循环用于打印数组,但是我不知道如何在数字之间打印空格。 Thanks! 谢谢!

let's assume you have a loop, that prints numbers 1-10 假设您有一个循环,可以打印数字1-10

mov ax,1

L_again:
    push ax
    call printAX

    pop ax
    inc ax
    cmp ax,10
    jbe L_again
ret

then all you need is to add a "print a space" right after printing AX 那么您所需要做的就是在打印AX之后立即添加“打印空格”

mov ax,1

L_again:
    push ax
    call printAX
    call printSpace

    pop ax
    inc ax
    cmp ax,10
    jbe L_again
ret

which could look like this (eg for DOS). 可能看起来像这样(例如,对于DOS)。 for small functions like this you could of course simply add the few instructions right into the loop itself 对于这样的小功能,您当然可以在循环本身中直接添加一些指令

printSpace:
    mov dl, ' '
    mov ah, 2
    int 21h
    ret

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM