Answer the question
In order to leave comments, you need to log in
Linux NASM reading and outputting file contents?
I act according to the plan
- Open (I get the file descriptor)
- Read (I read the file by the descriptor)
- Write (I write what I read into the terminal descriptor)
But there is no output
SECTION .text
global _start
_start:
mov eax,05 ;; Подпрограмма Open
mov ebx,file ;; Помещаю адресс строки названия файла
mov ecx,00 ;; Флаг только чтение
int 0x80
mov ebx,eax ;; Теперь если я правильно понял в EAX лежит дескриптор, его ложу в EBX
mov eax,03 ;; Подпрограмма Read
mov ecx,buff ;; Помещаю адресс куда читать
mov edx,4096 ;; Сколько читать
int 0x80
mov eax,04 ;; Подпрограмма Write
mov ebx,01 ;; Дискриптор терминала ( вивод )
mov ecx,buff ;; Помещаю адресс буффера откуда писать
mov edx,4096 ;; Сколько читать
int 0x80
jmp $ ;; Зависаю...
SECTION .data
file db "test_01.asm",0 ;; Массив с названием файла
buff resb 4096 ;; Резерв для буффера
db 0 ;; Так на всякий :D Мои методы
Answer the question
In order to leave comments, you need to log in
1 - "int 0x80" confuses me, this is an interrupt call with hexadecimal number 80 (for DOS there was a typical command int 21 ... or int 0x21 ??), but does it work on x64 systems? (I don’t know myself, I haven’t “picked up checkers” for a long time)
2 - did you try to google? Linux ASM reading and displaying the contents of a file .. and performing tasks more atomically ... just print something on the screen for a start?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question