NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on February 12, 2005, 02:37:27 AM
-
creating this simple hello world prog:
org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db 'Hello, World!',0Dh,0Ah,'$'
when i executed it, the computer threw a security error. it said it was going to perform an illegal instruction
-
INT 21h function 09h expects DS:DX to point
to the string. So... where did you load DS?
-
DS is set to the current segment in com files that's not the problem, the problem is that you need to put the offset of msg to dx, not msg itself.
-
True, the dos loader sets up ds (for a .com file only!), so that's not the problem. And "mov dx, msg" *does* put the offset in dx, not "msg itself" (I assume you mean "contents" - the letters "H" and "e" - Nasm would want "mov dx, [msg]" for that!), so that isn't the problem, either.
The code, as given, looks perfectly allright - for a dos .com file. So the problem would seem to be that "my comp" doesn't like dos .com files... for some reason... Trying it in Linux would result in "can't execute binary file", rather than "illegal operation"... Windows, while it won't run 16-bit code directly, should recognize a .com file and run it as a vm86 task... Damned if I know what the problem is!
If the original poster is still around (unlikely), and hasn't long since solved the problem (even less likely), what command-line did you give Nasm to assemble this, what OS are you running, and exactly what does the error-message say?
Best,
Frank