0

I keep getting the same error: error: parser: instruction expected
I get this error with the following line:

WSTRING 'MESSAGE' 

My code is:

Bits 16 call clear_screen WSTRING 'MESSAGE' jmp $ %MACRO WSTRING 1 mov si, %1 call print %ENDMACRO 

I've tried this and doesn't work either:

Bits 16 MSG DB 'MESSAGE',0 call clear_screen WSTRING MSG jmp $ %MACRO WSTRING 1 mov si, %1 call print %ENDMACRO 
10
  • You can use the actual code instead of the macro, and then you will see which of the two instructions is incorrect. Commented Apr 27, 2018 at 18:35
  • You'd have to do something like creating a variable in memory somewhere with msg_str: db "MESSAGE", 0 and then do WSTRING msg_str Commented Apr 27, 2018 at 18:38
  • Please see edit Commented Apr 27, 2018 at 18:39
  • 2
    Please show us the entire file and make this as minimal reproducible example, not bits and pieces. The order you place things can be an issue. Commented Apr 27, 2018 at 18:43
  • For instance I hope your macro appears BEFORE you use it otherwise you'd get an error. Commented Apr 27, 2018 at 18:43

1 Answer 1

2

You cannot use a literal string as an instruction's operand. You can only use string 's address. This means, you need to instruct the assembler to place that string somewhere, and then use its symbolical address.

Sign up to request clarification or add additional context in comments.

1 Comment

NASM allows multi-byte character constants. NASM in 16-bit mode assembles mov si, 'MESSAGE' to BE 4D 45, and warns word data exceeds bounds [-w+number-overflow]. So yes you can use a quoted literal string as an immediate, but it gives you the bytes (in little-endian order, i.e. SIL = M), not an address.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.