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


Relevant Pages

  • Re: interpreter vs. compiled
    ... a memory address to successive integers 0..9, ... Is there a reason why you're expecting c.l.p to be your personal tutor ... for Introduction to Compilers? ... Defining your own terms that don't ...
  • Re: R: GOBACK (was: Perform Thru/Go to vs. Perform - Compile Speed
    ... >> one paragraph name to ENTRY, or breaking the program into smaller ones. ... >> what it looks like in the multithreading demo I just posted. ... All compilers will have the equivalent of reentrant, ... not sharing memory with other threads. ...
  • Re: question about negative indices in fortran 77
    ... > Intel compilers for linux), but now I'm doing some modifications and I ... > subroutine where it isn't touched. ... out memory in the order arrays are declared. ...
  • Re: If you were inventing CoBOL...
    ... > IBM mainframe culture, and compilers that mimic IBM's memory model. ... That's not what memory management is for. ...
  • Re: C++ sucks for games
    ... Few, if any, compilers offer completely safe modes. ... Lisp programming is much more visual. ... >> objects around to make manual memory management manageable. ... Few programmers use the auto keyword in declarations because all ...