-2

I need to get user input and put it into cArr dw 21 dup('') for later use, and I can't seem to figure out how to do it. Can someone help me?

fuz
  • 88,405
  • 25
  • 200
  • 352

1 Answers1

0
cArr dw 21 dup('')

Not sure how these empty quotes will ever define an array.
I think you need cArr dw 21 dup(0) to obtain an array of 21 words.


Since you ask for putting the user input in an array of words I conclude that you're not just inputting text characters, but want to store information about the keys pushed.

Define an extra variable cArrPtr that will - at all times - be an offset in the cArr array. Once you get a word-sized information store it at the current offset in the array and then adjust the offset to point to the next element taking care of the wrap-around.

    cArr    dw 21 dup(0)
    cArrPtr dw 0
    ...
    mov     ah, 00h         ;BIOS 'WaitKey'
    int     16h
    mov     bx, cArrPtr
    mov     cArr[bx], ax
    add     bx, 2           ;Elements are 2 bytes each
    cmp     bx, 21*2        ;21 elements in the array
    jb      OK              ;Still pointing to an available spot
    xor     bx, bx          ;Reset to point to 1st element
OK:
    mov     cArrPtr, bx
Sep Roland
  • 33,889
  • 7
  • 43
  • 76