如何在装配数组中形成5个元素的字符串

时间:2016-10-05 22:24:18

标签: arrays assembly io x86

我目前有一个包含25个数字的数组。我想创建一个包含5个数字的字符串,然后输出它们。然后得到5个以上的数字并输出字符串等等......所以基本上是一个5x5网格的数组编号。我的问题是我不知道如何从数组中获取数字,然后将其放在字符串上。循环5x然后输出。

x86汇编。使用WORD

这是我的代码:

变量

    inputGridArray WORD MAXNBRS DUP (?)
    grid_Rows WORD ?
    grid_Cols WORD ?
    gridSize WORD ?
    temp WORD ?
    empty WORD ?
    prompt BYTE 0, 0
    string BYTE 40 DUP (0)

MACRO

printArray  MACRO array_name, size_array
        LOCAL PRINT_ARRAY, PRINT_ROW, NEXT_ROW, END_PRINT_LOOP

        lea ebx, array_name
        mov cx, 0
        mov temp, 0
        PRINT_ARRAY:
            cmp cx, grid_Cols
            je END_PRINT_LOOP
            PRINT_ROW:
                mov ax, temp
                cmp ax, grid_Rows
                je NEXT_ROW

                ;I need to construct a string maybe, to be able to put the array into a grid shape
                outputW WORD PTR [ebx]
                add ebx, 2
                inc temp
                jmp PRINT_ROW

                NEXT_ROW:
                    inc cx
                    mov temp, 0
                    jmp PRINT_ARRAY
        END_PRINT_LOOP:
    ENDM

0 个答案:

没有答案