Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22130

redirecting result of running assembly code in linux to text file [duplicate]

$
0
0

I'm trying to write a Python script to test the output of some various code I've written in assembly against an expected output. However I am having difficulty redirecting the output into a file.I have written the following:

extern printfLINUX   equ     80H     ; interupt number for entering Linux kernelEXIT    equ     1       ; Linux system call 1 i.e. exit ()section .data    intfmt: db "%ld", 10, 0segment .text    global  mainmain:    push rax    push rsi    push rdi    mov rsi, 10    mov rdi, intfmt    xor rax, rax    call printf    pop rdi    pop rsi    pop rax     call os_return      ; return to operating systemos_return:    mov  rax, EXIT      ; Linux system call 1 i.e. exit ()    mov  rbx, 0     ; Error code 0 i.e. no errors    mov rcx, 5    int  LINUX      ; Interrupt Linux kernel

I then procede to do the following in the console:

nasm -f elf64 basic.asmgcc -m64 -o basic basic.o./basic

Which outputs 10 to the screen.However if I enter

./basic > basic.txtcat basic.txt

basic.txt appears as an empty file.My overall goal is to write a shell script that loops over each assembly file to compiling and run the file and then redirect the output of this script into a file. However I cannot do this until I can get it to work with a single file.I was wondering it it was something to do with my call to printf? Although I was under the illusion that printf writes to STDOUT.

Thanks in advance!


Viewing all articles
Browse latest Browse all 22130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>