Re: call instruction

"Tomek" <i-tommy@xxxxxxxxx> wrote in message
hello everyone,

does anyone know how to start executing program from specific address in
memory ?

FYI, although most DOS compilers map addresses nicely, the C standard
doesn't require that C pointers be able to access user assigned or user
programmed memory addresses.

let's say I work in dos real mode, my snippet of code

int *b = 0xffe2

__asm {
mov ax, b
call ax <- why it doesn't work ?

<- why it doesn't work ?

I don't know. I've never used assembly in C to call an address... (just C

this snippet of code simply hangs my pc, i guess i should put 'ret'
to the specific address in memory

any help will be appreciated

Well, knowing what compiler would help: TurboC, BorlandC, MSVC 1.52 16-bit,
OpenWatcom, DJGPP 16-bit patch, Digital Mars, Pacific C, etc. (Those are
just 16-bit, no 32-bit DPMI or Dos Extender based compilers of which there
are even more...)

Anyway, this depends on the compilers extensions and if or how it maps
memory. For 16-bit RM with OpenWatcom, you'd do this (calls original IBM
BIOS reset address directly):

#ifdef __WATCOMC__
#ifndef __386__
/* 16-bit RM only */

#include <i86.h>
/* i86.h for MK_FP */

void ( __far *reset)();
/* pointer to function with compiler extension for 16-bit segmented
addresses */

/* MK_FP macro constructs a 16-bit segmented address from segment:offset */

(*reset)(); /* call the function */


I'd first look to see if your compiler has MK_FP which I suspect is common
to many 16-bit DOS compilers.

For 32-bit OW and DJGPP, it requires much more coding. I can post examples
if you need them.

Rod Pemberton