My problem is I am trying to take user input in a loop and every time I want to store that input into a place in the memory to access it later and print it with some changes. And I am being confused regarding how to first declare an array that can hold my 5 words for example, and later how to store the input every time into that array.
Exactly I am taking names of subjects: and the loop in c++ would look something like that:
string subjects_code[5]
for(int i=0; i<5; i++)
cin>>subjects_code[i];
// like AFJS421 , CSFA424, SCSJ1023 and so on
I did my research all over the internet and YouTube, I found that you can't declare an array of strings in assembly, you basically have a single array of bytes followed by a null terminator. I understand that and I did my code with it and it is working, but the problem is I really need to store the 5 subjects codes into 5 different variables (or at least memory locations), because later after some calculations I need to print back those subjects.
;taking input from user: in a Loop
;in .data I have subjects_code BYTE MAX DUP(?)
MAX = 20
mov ebx,0
mov count, 5 ; cuz ReadString uses ecx as buffersize
InputLoop:
; This is just a prompt out, no need to worry about it
mov ecx, MAX
mov edx, OFFSET Enter_code ; setting offset for prompt
; temp variable to read into it, use it for assgining
mov edx, OFFSET temp_subject_code
call ReadString ; reading the code into temp
mov subjects_code+[ebx], temp_subject_code
add ebx, 4
mov ecx, count
dec count
Loop InputLoop
;---------------------------------------------------------------
After storing every string, I expect to do at the end of the program:
subject1: SCSJ134
subject2: SCSR231
Subject3: SCSI392
all the way up to Subject5.