Thread overview
asm, access violation?
Apr 29, 2004
LightEater
Apr 29, 2004
imr1984
Apr 29, 2004
LightEater
Apr 29, 2004
Norbert Nemec
Apr 29, 2004
Walter
April 29, 2004
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;
mov BH, 0; /* video page #0 */
int 0x10;
}
}


April 29, 2004
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;
>mov BH, 0; /* video page #0 */
>int 0x10;
>}
>}
>
>


April 29, 2004
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;
> mov BH, 0; /* video page #0 */
> 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.
April 29, 2004
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
April 29, 2004
"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;
> mov BH, 0; /* video page #0 */
> 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.