The MASM Forum

General => The Campus => Topic started by: mocallins on January 03, 2016, 07:51:28 AM

Title: exception Privileged Instruction 0xc000096 at 0x00401015
Post by: mocallins on January 03, 2016, 07:51:28 AM
New to using MASM32, with very tiny bit of understanding with assembly language.

There's a whole story of what I've tried, but the bottom line, can't get this code to work:

main proc

    mov dx, 0cf8h
    mov eax, 80000090h
    out dx,eax
    mov dx, 0cfch
    in eax,dx

    .if eax == 31504d44h
        print "S"
    .elseif eax == 32504d44h
        print "D"
    .elseif eax == 33504d44h
        print "M"
    .else
        print "0"
    .endif

    ret

main endp
Title: Re: exception Privileged Instruction 0xc000096 at 0x00401015
Post by: dedndave on January 03, 2016, 08:11:57 AM
hardware I/O instructions (IN, OUT, INS, OUTS) are not permited in user mode under NT operating systems
they are generally permitted in 16-bit real mode, however (some may be emulated by the NT OS)
Title: Re: exception Privileged Instruction 0xc000096 at 0x00401015
Post by: mocallins on January 03, 2016, 09:55:41 AM
16-bit can't use eax, is that correct ?

What's the alternative ? any ?
Title: Re: exception Privileged Instruction 0xc000096 at 0x00401015
Post by: FORTRANS on January 04, 2016, 12:55:21 AM
Hi,

Quote from: mocallins on January 03, 2016, 09:55:41 AM
16-bit can't use eax, is that correct ?

   No, that is incorrect.  16-bit code for MS-DOS can use 32-bit
registers.  See the .386 directive and the USE16 parameter for
the SEGMENT directive.

QuoteWhat's the alternative ? any ?

   I have not done this, so I may be mistaken, but you can load
a driver that will allow you to us the I/O instructions.

HTH,

Steve N.
Title: Re: exception Privileged Instruction 0xc000096 at 0x00401015
Post by: mocallins on January 04, 2016, 08:54:02 AM
Hmmmm, so I went and looked where I got the assembly code example, that I modified and tried in masm32.

No wonder there's no example for WES2009.
There are examples for DOS, Linux and Windows CE.

Windows CE probably doesn't have the restrictions, like Windows XP, restrictions to accessing hardware directly.

Hmmmmm   :(
Title: Re: exception Privileged Instruction 0xc000096 at 0x00401015
Post by: mocallins on January 04, 2016, 09:57:11 AM
Ok, so I found a utility that allows my program to run without exception.

And since I used the print command, in a console, I can see that its printing the correct value.

Now since I will call this masm program, how can I get it to return the value its printing, to the calling program ?
Title: Re: exception Privileged Instruction 0xc000096 at 0x00401015
Post by: dedndave on January 06, 2016, 10:40:57 PM
it is likely to be in the EAX register
this is the standard (windows ABI) method of returning results or status
Title: Re: exception Privileged Instruction 0xc000096 at 0x00401015
Post by: mocallins on January 15, 2016, 04:17:51 PM
Yep, that's what all the examples I've found, show to use.
Here's what its currently set at, trying to use the pointer to the location in EAX:

    .if eax == 31504d44h
        print "S",13,10
        STRING varS,"S"
        mov eax, OFFSET varS

hasn't helped :(