2

I'm trying to write my first assembly procedure, but NASM gives me errors when assembling. My code is:

Hello PROC
segment .data
tekst db "Hello World!",0Dh,0Ah,"$"
segment stosik stack
resb 64
segment .text
mov ax, .data
mov ds, ax
mov ax, stosik
mov ss, ax
mov dx, tekst
mov ah, 9
int 21h
mov ax, 4C00h
int 21h
ENDP

This code will give me this error on the first line with the PROC directive:

error: parser: instruction expected

Why am I getting this error and how can I fix it so that my code will assemble properly?

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
neir45
  • 31
  • 1
  • 4
    Well, NASM tell you exactly what the problems are. So what is your question? – Kijewski Nov 29 '15 at 01:39
  • 2
    You might want to take a quick look at [this answer](https://stackoverflow.com/questions/33265239/c-and-resource-protection-in-memory/33265884#33265884), in part because it includes a nasm-style hello world program that you could use to debug your own. – code_dredd Nov 29 '15 at 01:39
  • You should check the [how to ask](http://stackoverflow.com/help/how-to-ask) page. – code_dredd Nov 29 '15 at 01:42
  • "tekst"? does not look like any assembly command/statement I've eve seen... To make question look more reasonable and well researched - use ">" to format error message, point to exact lines that have errors and explain why searching for error messages did not explain the problem (with couple link+one line explanation) – Alexei Levenkov Nov 29 '15 at 01:46
  • Probably meant `test` instead of `tekst`... – code_dredd Nov 29 '15 at 01:52
  • 1
    `tekst` is a label (NASM doesn't need a colon after it in that case). I think the user is using a language other than English (dutch?) in the code. – Michael Petch Nov 29 '15 at 01:56
  • 2
    Those people closing this because of a typo didn't really look at the code. There is a lot more wrong about it `tekst` is not a typo if you are writing code and have variables with names that aren't English. – Michael Petch Nov 29 '15 at 02:03
  • It almost seems the OP is mixing MASM/TASM syntax with NASM (which won't work) – Michael Petch Nov 29 '15 at 02:05
  • I recommend that @neir45 consider looking at this tutorial on converting MASM/TASM syntax to NASM http://left404.com/2011/01/04/converting-x86-assembly-from-masm-to-nasm-3/ . Or possible they want MASM syntax but are using NASM (tag suggests otherwise, but it could be a miscommunication) – Michael Petch Nov 29 '15 at 02:07
  • Another source of information on NASM syntax (vs MASM) is here: https://courses.engr.illinois.edu/ece390/archive/mp/f99/mp5/masm_nasm.html – Michael Petch Nov 29 '15 at 02:10
  • @neir45 : Can you edit your question and add all of your program and not just the Hello PROC you are trying to create? – Michael Petch Nov 29 '15 at 02:51

1 Answers1

1
Hello PROC
...
ENDP

is correct in masm/tasm, however will not work using nasm. The correct syntax would be:

Hello:
...

Using masm/tasm syntax with nasm will make it complain about the first and last lines for error: parser: instruction expected and warning: label alone on a line without a colon might be in error.