2

I'm trying to convert my simple program from Intel syntax to the AT&T(to compile it with GAS). I've successfully converted a big part of my application, but I'm still getting an error with the int(the interrupts). My function is like this:

printf:
    mov $0x0e, %ah
    mov $0x07, %bl

    nextchar:
       lodsb
       or %al, %al
       jz return
       int 10
       jmp nextchar

    return:
       ret

msg db "Welcome To Track!", 0Ah

But when I compile it, I got this:

hello.S: Assembler messages:
hello.S:13: Error: operand size mismatch for int'
hello.S:19: Error: no such instruction:
msg db "Hello, World!",0Ah'

What I need to do?

Nathan Campos
  • 28,769
  • 59
  • 194
  • 300

1 Answers1

7

In GAS, constants need a $. Change that line to:

int $10

And your message should be:

msg: .byte "Welcome to Track!", 0x0a

Or even better:

msg: .asciiz "Welcome to Track!\n" 
Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
Carl Norum
  • 219,201
  • 40
  • 422
  • 469
  • Now what I got was this: `hello.S:19: Error: bad expression - hello.S:19: Error: junk at end of line, first unrecognized character is H` – Nathan Campos May 28 '10 at 18:21
  • @Nathan, You didn't write what I put down then. You left the 'h' on the end of that line. `h` is not a hexadecimal digit, so it chokes trying to parse it. – Carl Norum May 28 '10 at 18:25
  • @Carl: Of course I did, it's this: `msg: .byte "Welcome to Track!", 0x0A`, but I got that error! **:(** – Nathan Campos May 28 '10 at 18:29
  • There is an `H` there somewhere or it wouldn't be giving you that error. – Carl Norum May 28 '10 at 18:47
  • @Carl: Sorry, my bad, in the error, it's `W` not `H`, but what I think is that the problem is on the first letter of the sentence(inside the quotes)... – Nathan Campos May 28 '10 at 19:52
  • 1
    @Nathan, your assembler must have different syntax than mine, then. Go check its manual for more details. – Carl Norum May 28 '10 at 20:13
  • But, it's GAS. Anyway, +1 for you to at least try to help me. **:)** – Nathan Campos May 28 '10 at 20:40
  • @Nathan, mine is GAS too. Just clearly not the same version/variety as yours. – Carl Norum May 28 '10 at 20:45
  • I would also suggest using `.asciz`. I didn't see anyone bring it up but I think the OP is trying to use teletype output via the BIOS. It should be `int $0x10` and not `int $10` (the former being hex and the latter decimal) – Michael Petch Oct 25 '14 at 20:41