(inline assembler)calling interrupts in program compiled on MsVC.net, winXP 
Author Message
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP

I got error when I tried to call interrupts in program compiled on MsVC.Net,
winXP (inline assembler)
May I call interrupts in console program but not dos one?
So how can I display a character on the screen?

I found different code on different book for doing the same thing. But how
can I know wether is the correct one for my system???
 __asm {
  mov ah, 0Ah
  mov al, 'A'
  mov bh, 00h
  mov cx, 02h
  INT 10h
 }

 __asm {
  mov ah, 02h
  mov dl, 'A'
  INT 21h
 }

Help please



Mon, 17 Oct 2005 13:28:14 GMT  
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP

Quote:
> I got error when I tried to call interrupts in program compiled on
MsVC.net,
> winXP (inline assembler)
> May I call interrupts in console program but not dos one?
> So how can I display a character on the screen?

> I found different code on different book for doing the same thing. But how
> can I know wether is the correct one for my system???
>  __asm {
>   mov ah, 0Ah
>   mov al, 'A'
>   mov bh, 00h
>   mov cx, 02h
>   INT 10h
>  }

>  __asm {
>   mov ah, 02h
>   mov dl, 'A'
>   INT 21h
>  }

> Help please

VC .NET compiles code for Windows. Calling an interrupt is going to generate
an exception. In DOS, it was different. DOS programs call interrupts to
execute system routines. Windows will emulate that behavior for a DOS
program, but it won't work in a Windows program.

You can still use the code, but you'll need tools that can create DOS
programs. For starters, get an assembler that can create 16-bit code like
MASM or NASM. You can try the examples this way to learn assembler.

-Matt



Mon, 17 Oct 2005 05:15:21 GMT  
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP
Quote:

> I got error when I tried to call interrupts in program compiled on MsVC.net,
> winXP (inline assembler)
> May I call interrupts in console program but not dos one?

No you aren't allowed by the cause of protection :) The only allowed
one is 0x2E afair which is the system call interrupt. But this should
only be done by libraries.

Quote:
> So how can I display a character on the screen?

Just call the appropriate library function. If you can include & link
them, use the stdlib for example (putc). Alternatively you could use
the WriteConsole WinAPI but it is rather complicated to handle with
the Console directly.

Quote:
> I found different code on different book for doing the same thing. But how
> can I know wether is the correct one for my system???
>  __asm {
>   mov ah, 0Ah
>   mov al, 'A'
>   mov bh, 00h
>   mov cx, 02h
>   INT 10h
>  }

>  __asm {
>   mov ah, 02h
>   mov dl, 'A'
>   INT 21h
>  }

Just look for int 10h and int 21h. These are BIOS and DOS call and
both can only be used in DOS. But if your book only handles DOS
examples you could link your program as DOS executable with an
appropriate linker and could use it like it was DOS.


Mon, 17 Oct 2005 04:40:08 GMT  
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP

Quote:
> VC .NET compiles code for Windows. Calling an interrupt is going to
generate
> an exception. In DOS, it was different. DOS programs call interrupts to
> execute system routines. Windows will emulate that behavior for a DOS
> program, but it won't work in a Windows program.

But I'm trying to do that directly not using any library function and must
be in console program, and inline assembler. Isn't this possible??


Tue, 18 Oct 2005 13:07:23 GMT  
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP

Quote:
> > So how can I display a character on the screen?
> Just call the appropriate library function. If you can include & link
> them, use the stdlib for example (putc). Alternatively you could use
> the WriteConsole WinAPI but it is rather complicated to handle with
> the Console directly.

But I'm trying to do that directly not using any library function. Isn't
this possible??


Tue, 18 Oct 2005 13:05:45 GMT  
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP


Quote:
>But I'm trying to do that directly not using any library function and must
>be in console program, and inline assembler. Isn't this possible??

You can't access the screen directly in Windows. If you write a console app
then it is still a windows program using a virtual display and not the normal
VGA display as it is used in DOS. You shouldn't confuse these two just because
a console app looks like a DOS screen. Depending on what you want to do, if
you really want to write directly to a screen buffer then you should use
DirectX or OpenGL.

--
Gerhard Gruber

Fr jedes menschliche Problem gibt es immer eine einfache L?sung:
Klar, einleuchtend und falsch. (Henry Louis Mencken)



Tue, 18 Oct 2005 03:47:06 GMT  
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP

Quote:

>>>So how can I display a character on the screen?

>>Just call the appropriate library function. If you can include & link
>>them, use the stdlib for example (putc). Alternatively you could use
>>the WriteConsole WinAPI but it is rather complicated to handle with
>>the Console directly.

> But I'm trying to do that directly not using any library function. Isn't
> this possible??

Library/WinAPI is the best you can do. Windows just allows nothing
more :) And the int10h and int21h are just another form of library call.


Tue, 18 Oct 2005 05:34:30 GMT  
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP

Quote:
> > VC .NET compiles code for Windows. Calling an interrupt is going to
> generate
> > an exception. In DOS, it was different. DOS programs call interrupts to
> > execute system routines. Windows will emulate that behavior for a DOS
> > program, but it won't work in a Windows program.

> But I'm trying to do that directly not using any library function and must
> be in console program, and inline assembler. Isn't this possible??

No.

Think about it. Windows manages the hardware, so you don't have direct
access. The GDI further controls the screen so that it becomes a shared
resource. You can't do any I/O without calling some library routine to do it
for you.

If you use the console APIs, you can do console I/O at the lowest level that
Windows will allow you to do it. In DOS emulation, Windows traps these
interrupts and redirects them through these APIs. Call GetStdHandle to
retrieve the output console handle and you can then call WriteFile or
WriteConsole to write to the screen.

-Matt



Tue, 18 Oct 2005 11:51:43 GMT  
 (inline assembler)calling interrupts in program compiled on MsVC.net, winXP

Quote:

>> > So how can I display a character on the screen?
>> Just call the appropriate library function. If you can include & link
>> them, use the stdlib for example (putc). Alternatively you could use
>> the WriteConsole WinAPI but it is rather complicated to handle with
>> the Console directly.

>But I'm trying to do that directly not using any library function. Isn't
>this possible??

Not in Win32, no.  You said you were using inline assembler in VC++, right?
That means you're writing a 32-bit program.  In a Win32 program, as in ALL
modern operating systems, you must use the operating system in order to do
console I/O.

Do not think about APIs like WriteConsole as extraneous library routines
that interfere with your ability to do your work.  They *ARE* the low-level
I/O method in Win32.
--

  Providenza & Boekelheide, Inc.



Wed, 26 Oct 2005 11:35:37 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. ASSISTANCE REQUIRED - large memory model with inline MSVC assembler

2. porting inline Watcom asm to MSVC inline asm

3. How to...Call interrupts from WinXP???

4. MSVC 4.2 re-arranges inline asm

5. Calling REXX programs from within an assembler program

6. Compiling assembler program in Linux

7. Calling interrupts from within interrupts????????

8. PM Programming: Interrupts not interrupting

9. Help on Net Express COBOL dll and calling the DLL from VB program

10. Compiling 1.7 with MSVC

11. Problem with MSVC-compiled Ruby On Win2k

12. Scm problems compiled under MSVC 5.0

 

 
Powered by phpBB® Forum Software