"Illegal instruction" - nothing works

Programming, for all ages and all languages.
Post Reply
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

"Illegal instruction" - nothing works

Post by Merdini »

I just installed TASM and before that, i tried FASM.
I get "Illegal instruction" on the first line even though there is nothing work.

Something as simple as:

Code: Select all

DOSSEG
.MODEL SMALL
.STACK 100h
.DATA
HelloMessage DB 'Hello, world',13,10,'$'
.CODE
mov ax,@data
mov ds,ax
mov ah,9
nov dx, OFFSET HelloMessage
int 21h
mov ah,4ch
int 21h
END
Any ideas?
I use windows obviously.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: "Illegal instruction" - nothing works

Post by Love4Boobies »

I may be mistaken but IIRC you had to do something like

Code: Select all

.code
somelabel:
end somelabel
I know there are two ways of specifying the entry point using that syntax but I'm not sure yours is one of them. I've used MASM in the past; I know TASM is somewhat different and I know nothing about FASM. Hope I helped.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: "Illegal instruction" - nothing works

Post by Merdini »

Thanks for you help.

Whatever i try, i get the "illegal instruction" error on the first line :?

EDIT:
Okay, i think im doing some other things wrong aswell.
Im just starting to learn Assembly, and the following code:

Code: Select all

.model small
.stack
.data
message   db "Hello world, I'm learning Assembly !!!", "$"
.code
main   proc
   mov   ax,seg message
   mov   ds,ax

   mov   ah,09
   lea   dx,message
   int   21h

   mov   ax,4c00h
   int   21h
main   endp
end main
gets a error on the first line. This is what i've been told about the first line:
.model small : Lines that start with a "." are used to provide the assembler with infomation. The word(s) behind it say what kind of info. In this case it just tells the assembler the program is small and doesn't need a lot of memory.

What can the problem be?

EDIT2:
It worked now with TASM =)
User avatar
Thomas
Member
Member
Posts: 281
Joined: Thu Jun 04, 2009 11:12 pm

Re: "Illegal instruction" - nothing works

Post by Thomas »

Hi,
The words with dot are called Assembler directives that are used to instruct the assembler than the machine.You should consider learning to use the DEBUG utility and figure out what went wrong ( since you are doing real mode assembly).{Most possible cause of your error message is you not setting up the segment registers properly.}

{Please do excuse my poor english}
--Thomas
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: "Illegal instruction" - nothing works

Post by qw »

Shouldn't "DOSSEG" be ".DOSSEG"?
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: "Illegal instruction" - nothing works

Post by Love4Boobies »

I looked up a FASM example and it didn't look anything like MASM. You should probably know that each assembler is different; assembly, unlike C, is not a standard language. You'll need to learn each assembler's syntax. For the one you're using I suggest using JWasm.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply