www.digitalmars.com         C & C++   DMDScript  

D - asm, access violation?

reply LightEater <LightEater_member pathlink.com> writes:
Hi,

I'm trying to set the cursor position using inline asm, i came up with the
following nifty function, the program compiles, however when i call the function
i get an "Error: Access Violation". Any ideas on what might be wrong?

void GotoXY (ubyte x, ubyte y)
{ 
asm { 
mov AH, 2; /* cursor position */
mov DH, y;
mov DL, x; 

int 0x10; 
}
}
Apr 29 2004
next sibling parent reply imr1984 <imr1984_member pathlink.com> writes:
i ran that code in C++ and it does the same thing, it throws when int 0x10 is
called. Maybe thats a protected instruction? I dont really know much about the
int instruction sorry :( (what does it do anyway?)

In article <c6qlmd$omq$1 digitaldaemon.com>, LightEater says...
Hi,

I'm trying to set the cursor position using inline asm, i came up with the
following nifty function, the program compiles, however when i call the function
i get an "Error: Access Violation". Any ideas on what might be wrong?

void GotoXY (ubyte x, ubyte y)
{ 
asm { 
mov AH, 2; /* cursor position */
mov DH, y;
mov DL, x; 

int 0x10; 
}
}
Apr 29 2004
parent LightEater <lighteater suchar.NOSPAM.net> writes:
In article imr1984 says...
 i ran that code in C++ and it does the same thing, it throws when int 0x10 is
 called. Maybe thats a protected instruction? I dont really know much about the
 int instruction sorry :( (what does it do anyway?)
Well, int is used for executing interrupts and int 10h, function 2 is supposed to set cursor position :o
Apr 29 2004
prev sibling next sibling parent Norbert Nemec <Norbert.Nemec gmx.de> writes:
LightEater wrote:

 Hi,
 
 I'm trying to set the cursor position using inline asm, i came up with the
 following nifty function, the program compiles, however when i call the
 function i get an "Error: Access Violation". Any ideas on what might be
 wrong?
 
 void GotoXY (ubyte x, ubyte y)
 { 
 asm {
 mov AH, 2; /* cursor position */
 mov DH, y;
 mov DL, x;

 int 0x10;
 }
 }
Wow - I didn't see something like that since the old days of programming DOS. What do you want to do? BIOS programming? No reasonably modern OS would base cursor handling on BIOS calls.
Apr 29 2004
prev sibling parent "Walter" <newshound digitalmars.com> writes:
"LightEater" <LightEater_member pathlink.com> wrote in message
news:c6qlmd$omq$1 digitaldaemon.com...
 I'm trying to set the cursor position using inline asm, i came up with the
 following nifty function, the program compiles, however when i call the
function
 i get an "Error: Access Violation". Any ideas on what might be wrong?

 void GotoXY (ubyte x, ubyte y)
 {
 asm {
 mov AH, 2; /* cursor position */
 mov DH, y;
 mov DL, x;

 int 0x10;
 }
 }
Generating interrupts only works when running a 16 bit program. D only supports 32 bit programming. Generating an interrupt from a Win32 program will cause an access violation. To set the cursor position in a 32 bit Win32 program, check out the Windows console API.
Apr 29 2004