1

I'm trying to print a character to stdout using write in Linux x86 assembly, using at&t syntax. This code doesn’t work:

.data

.text

.global main

main:
    movl    $4,%eax
    movl    $1,%ebx
    movl    $53,%ecx //'5'
    movl    $4,%edx
    int     $0x80

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

What's the problem?

untitled
  • 389
  • 4
  • 13
  • 2
    [`man 2 write`](http://linux.die.net/man/2/write) ... it expects a pointer to the thing to print, so you have to place it into memory, you can't just do `movl $'5', %ecx`. – Jester Jan 16 '16 at 13:30
  • 1
    I've placed `p: .long 53` and `movl $p,%ecx` and it works. Thanks – untitled Jan 16 '16 at 13:35
  • 1
    @Jester: Please make your comment an answer – Hille Jan 16 '16 at 14:08

0 Answers0