Pregunta

I have this instruction:

asm("message: .byte 'Hello, World!', 0x0A");

For some reason the compiler says junk at end of line, first recognized character is 'e'. I tried replacing the .byte with db according to other examples on the web. Then the output was no such instruction: 'db 72ello, World!440x0A' (notice the numbers instead of the apostrophe). To me it seems like there is something wrong with the parsing of the '.

What can I do?

¿Fue útil?

Solución

  1. .byte only works for a single byte, like 0xFA, or 'F'.
  2. db is intel syntax, inline assembly uses GNU syntax.

  3. As mentioned above, .byte only works for one byte. To use strings, use either .ascii or .asciz -- the former is a simple array of bytes, while the latter is null terminated.

ie. asm("message: .asciz \"Hello, World!\n\"");

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top