|
-
Oct 5th, 2001, 08:34 PM
#1
Thread Starter
PowerPoster
using inline assembly in C++
I tried the following code to plot a pixel on the screen using asm but it shows me that shi*ty blue screen, and just terminates:
PHP Code:
#include <iostream.h>
int main()
{
__asm{
mov ax,13h ;mode = 13h
int 10h ;call bios service
mov ah,0Ch ;function 0Ch
mov al,4 ;color 4 - red
mov cx,160 ;x position = 160
mov dx,100 ;y position = 100
int 10h ;call BIOS service
xor ax,ax ;function 00h - get a key
int 16h ;call BIOS service
mov ax,3 ;mode = 3
int 10h ;call BIOS service
mov ax,4C00h ;exit to DOS
int 21h
}
return 0;
}
-
Oct 5th, 2001, 08:47 PM
#2
You can't call interrupts directly from within Windows.
Int21H, for example.
-
Oct 5th, 2001, 08:49 PM
#3
Thread Starter
PowerPoster
Originally posted by filburt1
That's what you get for using asm. Are you sure the assembly is cross-platform?
I don't no but I don't care about it unless it works correctly on mine for now
You can't call interrupts directly from within Windows.
Then why is there any need to use assembly if I can't call any interrupt?
-
Oct 5th, 2001, 08:50 PM
#4
Thread Starter
PowerPoster
And this code works well if I compile it as an assembly code, but it does not work when I use it as an inline assembly code in VC++.
-
Oct 10th, 2001, 02:18 PM
#5
Let me rephrase:
You can't call interrupts directly from within Windows PROGRAMS.
If you use inline assembly in vc++ you create a windows GUI or console application. If you compile as assembly code (with which compiler?) with NASM for example, you get a dos program and windows switches to a mode where this is allowed.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 10th, 2001, 03:21 PM
#6
Thread Starter
PowerPoster
So its mean that NASM or any other asm compiler switch to DOS mode when they use interrupts.
21h is a DOS interrupt but 10h is a BIOS interrupt.
So I can't even call any interrupt other than DOS one?
-
Oct 10th, 2001, 03:29 PM
#7
No, not compiler switches. NASM is a assembler for DOS programs, where interrupts are always allowed. Windows allows interrupts only for DOS programs, I think Win95 (but not 98) allows the 21H interrupt. Maybe some others too, but I don't think so. This is the reason why I didn't find a way to set an interrupt handler using VC++: it's not possible.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|