The task is to write a file byte analysis. I can not understand how to read bytes.

section .data title_text db 'Getting strings from file' lengthTitle_text equ $- title_text file_name db 'myfile.txt' lengthFileName equ $- file_name section .bss info resb 1 info_size resb 1 file_disc resb 4 section .text global _start _start: mov eax, 4 mov ebx, 1 mov ecx, title_text mov edx, lengthTitle_text int 80h _rep: mov eax, 5 mov ebx, file_name mov ecx, 0 mov edx, 0777 int 0x80 mov [file_disc],eax mov eax, 3 mov ebx, [file_disc] mov ecx, info mov edx, 1 int 0x80 cmp eax,0 je _exit mov eax, 4 mov ebx, 1 mov ecx, info mov edx, 1 int 80h jmp _rep _exit: mov eax, 1 mov ebx, 0 int 80h 

This code constantly prints the first byte, but I can’t understand how to output the second without first output ... and so on.

    1 answer 1

    You have an incorrect _rep label. You re-open the file on each cycle, respectively, the pointer jumps to its beginning. That's right - move it here:

     _rep: mov eax, 3 mov ebx, [file_disc] mov ecx, info mov edx, 1 int 0x80 

    BTW, if not with your eyes, then this bug is caught instantly at the first pass through the code in the debugger. Try, debuggers is a useful thing :)