Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

plotting point in 13h with Open Watcom inline assembly

18 views
Skip to first unread message

Laura Martignas

unread,
Sep 21, 2003, 5:11:23 PM9/21/03
to
Hi

I use Open Watcom to play with 13h mode. It's just for fun :)

To init 13h mode, here is my code :

void initMode13(void)
{
_asm
{
mov ax,13h
int 10h
}
}

and to plot :

void main(void)
{
initMode13();
char far *screen = (char far*)0x0A0000000;
*screen = (char) 1;
}

colour 1 is supposed to be red (0xff0000, initialized before 13h mode). But
when I run, my program hangs. Why ?

I use this command line to compile :

wcl386 /l=dos4g test.c

Someone to help me ?

Thx
Laura

Matt Taylor

unread,
Sep 21, 2003, 6:46:05 PM9/21/03
to
The screen's address is A000:0000. I'm not familiar with Watcom, but my
guess is that your pointer is 0A00:0000.

-Matt

"Laura Martignas" <laura...@libertysurf.fr> wrote in message
news:Xns93FDEBFBDB7...@213.228.0.196...

Frank Kotler

unread,
Sep 21, 2003, 7:26:42 PM9/21/03
to
Laura Martignas wrote:

> void main(void)

"int main". Pretty please?

> {
> initMode13();
> char far *screen = (char far*)0x0A0000000;

Looks like too many zeros. Try 0xA0000.

Best,
Frank

Herman Dullink

unread,
Sep 22, 2003, 5:02:54 PM9/22/03
to
> I use Open Watcom to play with 13h mode. It's just for fun :)
> To init 13h mode, here is my code :
<snip>
> mov ax,13h
> int 10h
<snip>

> char far *screen = (char far*)0x0A0000000;
> *screen = (char) 1;
<snip>

> I use this command line to compile :
> wcl386 /l=dos4g test.c

I don't know too much about Open Watcom, but I do know
about the PC's hardware.
For compatibility reasons, the CPU of a PC has several
operating modes. DOS only knows about 16-bit, but DOS extenders
and newer operating systems know 32-bit (or 64-bit :-)
On the lowest software level, 16-bit and 32-bit aren't 100% compatible,
and that's probably what goes wrong here. The code uses 16-bit
DOS programming stuff, while being compiled for 32-bit (looking at the
command line).
I suggest you look into the manual how to target 16-bit DOS, _or_
look for their 32-bit equivalents.

Herman

alex

unread,
Sep 26, 2003, 4:01:11 AM9/26/03
to

"Laura Martignas" <laura...@libertysurf.fr> wrote in message
news:Xns93FDEBFBDB7...@213.228.0.196...
> Hi
>
> I use Open Watcom to play with 13h mode. It's just for fun :)
>
> void main(void)
> {
> initMode13();
> char far *screen = (char far*)0x0A0000000;
> *screen = (char) 1;
> }
>
> colour 1 is supposed to be red (0xff0000, initialized before 13h mode).
But
> when I run, my program hangs. Why ?

I see you're linking into dos4gw.

Welcome to protected mode. You now address memory in a linear fashion.
to convert a seg:off pair to a linear address u do the following:

linear=(segment shl 4)+offset
so quite simply B800:0000 becomes 0xb8000

Segment registers under protected mode arnt used in the say way as they are
under realmode.
They are used in the form of sel:offset

you can use a DPMI call to allocate a selector and set its base address as
0xa0000

all u do is load ES with the selector, and your reference memory location
(pixel) in EDI

thats one approach (not necessarily the best)

if your DS and ES already have a base of 0, they're likely to have a limit
of 4gig, so
you can just address anything inside that space with your ESI/EDI registers

your program is hanging because of an incompatible memory pointer.

cheers
alex

Chris Giese

unread,
Sep 26, 2003, 10:43:35 PM9/26/03
to
/* 32-bit Watcom C with CauseWay DOS extender */
int main(void) {
char *screen = (char *)0xA0000;
initMode13();
*screen = 1;
return 0;
}

/* 32-bit Watcom C with DOS/4GW extender
(*** This code is untested ***) */
int main(void) {
char *screen = (char *)0xA0000;
initMode13();
*screen = 1;
return 0;
}

/* 32-bit Watcom C with PharLap DOS extender
(*** This code is untested ***) */
#include <dos.h> /* MK_FP() */
#define PHARLAP_CONVMEM_SEL 0x34
int main(void) {
char far *screen = (char far *)MK_FP(PHARLAP_CONVMEM_SEL, 0xA0000);
initMode13();
*screen = 1;
return 0;
}

/* 16-bit Watcom C (real mode) */
#include <dos.h> /* MK_FP() */
int main(void) {
char far *screen = (char far *)MK_FP(0xA000, 0);
initMode13();
*screen = 1;
return 0;
}


mchiper

unread,
Sep 29, 2003, 9:56:53 AM9/29/03
to

In comp.lang.asm.x86, Msg ID: <bl0rji$l4m$1...@lust.ihug.co.nz>
"alex" <n...@spam.pls.kthx.com>, wrote:

>"Laura Martignas" <laura...@libertysurf.fr> wrote in message
>news:Xns93FDEBFBDB7...@213.228.0.196...

>> I use Open Watcom to play with 13h mode. It's just for fun :)

I'm new to HLLs,
I've been resisting it for years.
Now I'm trying to decide which one to learn..

After getting Open Watcom, and cuz it looks like
the basics are there,
I decided on "just enough" of C/C++ and Fortran to get a clue.
And the same for win, NT and O/S2.
- Hey .. It rhymes !!!

A few questions for all..
Re: "It's just for fun".
Sounds like an apology - If so for what?


>I see you're linking into dos4gw.

That is what got me to Watcom.

>Welcome to protected mode. You now address memory in a linear fashion.
>to convert a seg:off pair to a linear address u do the following:

Now that I'm there, Have I arrived at a good place to start?
Cuz I think I've also come to the place I want to end too..
What else is there?

OBTW - If it isn't for fun, what's it for? Money? << sucker !!

--
Ray

0 new messages