0

I am new in assembly and I want to print a value stored in a register with assembly AT&T.

.text
.globl main

main:
    mov $42, %edx

    # what should be here?

    mov $1, %eax
    mov $0, %ebx
    int $0x80

I found many "Hello, world" examples with section ".data" and write calls, but write accepts a string buffer, not an integer. What is the most elegant way to output the number in %edx into stdout?

Fomalhaut
  • 8,590
  • 8
  • 51
  • 95
  • What do you mean by "elegant"? Some would consider using years-verified code like `libc` and `printf`, others would write their own converter, and minority of people would use some high level programming language. – Ped7g Aug 16 '18 at 20:02
  • 2
    (seasoned assembly programmers usually don't bother and just check the value directly in register in debugger, outputting results is overrated) – Ped7g Aug 16 '18 at 20:14

0 Answers0