Reading a line in a TASM x86 assembly

I am trying to read a line from a user in a TASM assembly, I know that I need a buffer to store input, max. length and actual length, but I seem to have forgotten exactly how we declare the buffer

my attempt was like this.

Buffer db 80 ;max length
       db ?  ;actual length
       db 80 dup(0);i think here is my problem but can't remember the right format

Thanks in advance

+3
source share
1 answer

The DB directive (define byte) is used to allocate memory blocks of byte size. The section that comes after the database indicates the value that should be placed in the allocated memory. For example, if you want to define one byte of memory with a value of 65, you can use the following directive.

SingleByte   DB  65        ; allocate a single byte and write 65 into the byte

DUP () . , , , DUP. DUP . , 10- , 65, .

TenBytes     DB  10 DUP(65); allocate 10 bytes and write 65 into each byte

, , ? . , ? 0.

Buffer       DB  80 DUP(?) ; set aside 80 bytes without assigning them any values

. , , , - .

Buffer       DB  80 DUP(0) ; 80-byte buffer initialized to all zeros
BufferMaxLen DB  80        ; maximum length of Buffer
BufferLen    DB  0         ; actual length of Buffer
+2
source

Source: https://habr.com/ru/post/1740662/


All Articles