0

all I want to display in the terminal the return value (13) of the function Additionner (An add function). It is stored in the %eax register.

I know, I don't have to make a function for this program, but it's done that way because I'm learning.

`.section .text
.globl _start
_start:
    
    pushl $9
    pushl $4
    call additioner
    movl %eax, %ebx
    
    
    #Show Value
    movl %ebx, %ecx #Content i want to show
    movl $4, %eax #Write
    movl $1, %ebx #StdOut
    movl $1, %edx #Len
    int $0x80 #Syscall
    
    movl $1, %eax
    xorl %ebx, %ebx  
    int $0x80
    
.type additionner, @function
additioner:
    pushl %ebp
    movl %esp, %ebp
    subl $4, %esp
    movl 8(%ebp), %eax
    movl 12(%ebp), %ebx
    add %ebx, %eax
    movl %ebp, %esp
    popl %ebp
    ret`

I search on the internet, on chatgpt, in my books, but nothing. I tried to change the length, and I was wondering if the write function could only be used to display ascii, if so how do I pass the result which is in my register into an ascii string and display it afterwards.

Thanks a lot for help

  • You have to format the number as text, choosing a certain base (eg decimal, hexadecimal, binary). Indeed the write function only writes text. And you mustn't put the text itself in a register, the register as accepted by the system call must have a pointer to a buffer somewhere in memory. – ecm Apr 06 '23 at 20:28

0 Answers0