Below i wrote a code that will compare characters and move letters to litere array and numbers to numere array. The problem is that when i am trying to print the letters array using printf , it actually not printing anything. I think i made a mistake when i was moving values from the array that have all the characters to another array, but i am not sure.
litere times 255 db 0
numere times 255 db '?'
mov ESI,0 ;index of the full array of characters from text file
mov EDI,0 ;index of numbers array
mov EBX,0 ;index of letters array
mov ECX,[numar_caractere_citite] ;the number of all numbers and letters from the original array
repeta:
push ECX
mov DL,byte[continut_fisier+esi]
cmp DL,"0"
jl cmp_litere
cmp DL,"9"
jg cmp_litere ;if EDX>=0 && EDX <= 9 --> we found a number
jmp found_cifra
cmp_litere:
cmp DL, "A" ; compare EDX with "A"
jl continua ; jump to next character if less
cmp DL, "Z" ; compare EDX with "Z"
jle found_letter ; if EDX is >= "A" && <= "Z" -> found a letter
cmp DL, "a" ; compare EDX with "a"
jl continua ; jump to next character if less (since it's between "Z" & "a")
cmp DL, "z" ; compare EDX with "z"
jg continua ; above "Z" -> not a character
found_letter:
mov [litere+EBX],byte DL
inc EBX
jmp continua
found_cifra :
mov [numere+EDI],byte DL
inc EDI
continua:inc ESI
pop ECX
loop repeta
;HERE i am trying to print each character from litere array
mov ECX,[dim_sir_litere] ;number of letters from litere array
mov ESI,0
afisare_litere:
push ECX
mov AL, byte [litere+ESI]
cbw
cwde
push dword EAX
push dword format_caracter ;format is %c
call [printf]
add ESP, 4*2
inc ESI
pop ECX
loop afisare_litere
===>> UPDATE <<===== THIS IS THE CODE THAT IS ACTUAL WORKING
mov [dim_sir_litere], EBX ;the length of letters array
mov EBX,[dim_sir_litere] ;number of letters from litere array
mov ESI,litere
afisare_litere:
lodsb
push dword EAX
push dword format_caracter ;format is %c
call [printf]
add ESP, 4*2
sub EBX,1
cmp EBX,0
jne afisare_litere