Problem with int 21h and Masm32.

  • Follow


code:

  .486
  .model flat, stdcall
  option casemap: none

..code
start:
  mov ah, 4ch
  int 21h
end start

Alright, simple enough.  I type that into QEditor then hit the console
assemble and link button from the project menu which basically does
this:

ml /c /coff <file>.asm
link /SUBSYSTEM:CONSOLE /OPT:NOREF <file>.obj

Assembles and links without errors or warnings...I go to run it and
when it tries to execute the int 21h line I get an "access violation".

I got this thing to work last night by linking it with tlink instead,
after looking at the hex for both versions of the executable I noticed
that the big difference is in the header of the exe.  The masm32
linker version even has an ascii string saying that this program does
not run in dos mode, so it makes sense that calling a DOS interrupt
won't work.  So I guess my question is how can I get the linker that
is included in the masm32 package to create exe's that can call DOS
interrupts?  Is there a 16-bit combatibility mode or something I can
use?  Does this have to do with coff?  Can I make it link in another
format? etc?

Thanx a bunch.

0
Reply spamtrap 9/3/2004 12:10:53 AM


Nelson wrote:
> 
> code:
> 
>   .486
>   .model flat, stdcall
>   option casemap: none
> 
> .code
> start:
>   mov ah, 4ch
>   int 21h
> end start
> 
> Alright, simple enough.  I type that into QEditor then hit the console
> assemble and link button from the project menu which basically does
> this:
> 
> ml /c /coff <file>.asm
> link /SUBSYSTEM:CONSOLE /OPT:NOREF <file>.obj


> So I guess my question is how can I get the linker that
> is included in the masm32 package to create exe's that can call DOS
> interrupts?  Is there a 16-bit combatibility mode or something I can
> use?  Does this have to do with coff?  Can I make it link in another
> format? etc?

1. This code above is for 32-bit mode. You must write a 16-bit DOS
   code to do an interrupt. Change the code to:

	.486
	.model small
	option segment:use16	;don't forget this

	.code
	start:
		mov ah, 4ch
		int 21h
	end start

2. You need the 16-bit Microsoft linker.
   See http://www.ht.sakura.ne.jp/~delmonta/programmierung/masm-e.html

3. At last, you'll be successful with ml /c <file>.asm (don't add /COFF),
   then	use 16-bit linker.

========================================================================
(Mr.) IIJIMA Hiromitsu,                  mailto:delmonta@ht.sakura.ne.jp
           aka Delmonta            http://www.ht.sakura.ne.jp/~delmonta/

0
Reply IIJIMA 9/3/2004 1:27:09 AM


IIJIMA Hiromitsu  <spamtrap@crayne.org> wrote:
>
>1. This code above is for 32-bit mode. You must write a 16-bit DOS
>   code to do an interrupt. Change the code to:
>
>	.486
>	.model small
>	option segment:use16	;don't forget this

You can skip the "option" if you just swap the order of the first two
lines:

	.model small
	.486

>	.code
>	start:
>		mov ah, 4ch
>		int 21h
>	end start
-- 
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.

0
Reply Tim 9/3/2004 5:53:15 AM

IIJIMA Hiromitsu  <spamtrap@crayne.org> wrote in message news:<4137C717.F3981A06@ht.sakura.ne.jp>...

Nelson,



 wrote:
> > 
> > code:
> > 
> >   .486
> >   .model flat, stdcall
> >   option casemap: none
> > 
> > .code
> > start:
> >   mov ah, 4ch
> >   int 21h
> > end start
> > 
> > Alright, simple enough.  I type that into QEditor then hit the console
> > assemble and link button from the project menu which basically does
> > this:
> > 
> > ml /c /coff <file>.asm
> > link /SUBSYSTEM:CONSOLE /OPT:NOREF <file>.obj
> 
> 
> > So I guess my question is how can I get the linker that
> > is included in the masm32 package to create exe's that can call DOS
> > interrupts?  Is there a 16-bit combatibility mode or something I can
> > use?  Does this have to do with coff?  Can I make it link in another
> > format? etc?
> 
> 1. This code above is for 32-bit mode. You must write a 16-bit DOS
>    code to do an interrupt. Change the code to:
> 
> 	.486
> 	.model small
> 	option segment:use16	;don't forget this
> 
> 	.code
> 	start:
> 		mov ah, 4ch
> 		int 21h
> 	end start
> 
> 2. You need the 16-bit Microsoft linker.
>    See http://www.ht.sakura.ne.jp/~delmonta/programmierung/masm-e.html
> 
> 3. At last, you'll be successful with ml /c <file>.asm (don't add /COFF),
>    then	use 16-bit linker.
> 
> ========================================================================
> (Mr.) IIJIMA Hiromitsu,                  mailto:delmonta@ht.sakura.ne.jp
>            aka Delmonta            http://www.ht.sakura.ne.jp/~delmonta/

0
Reply spamtrap 9/3/2004 10:47:24 AM

Apologies for the duplicate posting, must have hit the wrong key while
typing the answer.

Nelson,

Delmonta has pointed you in the right direction with the 16 bit OMF
linker. MASM32 will not build 16 bit files and to make the point, int
21h cannot be used in 32 bit windows.

If you really want to work with 16 bit DOS code, try and get hold of
the last commercial release of MASM 611d as it was well suited for
that purpose.

Regards,

hutch at movsd dot com

0
Reply spamtrap 9/13/2004 11:10:11 AM

4 Replies
344 Views

(page loaded in 0.047 seconds)

Similiar Articles:










7/21/2012 1:59:53 AM


Reply: