K
K
Kezzya2021-11-05 00:46:47
assembler
Kezzya, 2021-11-05 00:46:47

How to find the length of an array?

InBuff    label  byte
   MaxSymb   Db  9
    RealSymb  Db  ?
  StringT db 1 dup (' ')

After calling the 10th function, 21 interrupts, the length of the array should be written to RealSymb, but for some reason I get the number 1 for any length of the string.
I also used len StringT - it also gives 1 ... although I entered 3 characters there The
question is, how can I find the length this array (what did the user enter?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2021-11-05
@Kezzya

MaxSymb Db 9
RealSymb Db ?
StringT db 1 dup(' ')

It should be here StringT db 9 dup (' '), otherwise the input will overwrite what is there further in memory.
I tried and do so mov cx, InBuff[0] , mov cx, InBuff[1] no difference.

These instructions load a 16-bit register from memory and the length value is 8-bit. Something like this would be correct:mov cl, [RealSymb]
len equ $ - StringT - doesn't come out, also gives 1

It generally defines a constant whose value is equal to the difference between the current address and the address of StringT. If you do this in your program immediately after the definition of StringT, then 1 will turn out, because the length of StringT is 1 byte.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question