jasonlin1206 - 2010-08-31

1.The code always get RUN-TIME error with DEV-C++ ! But it runs correct if it
is compiled with DJ Delerie's DJGPP
2. The assembly assembled with NASM.
3. I am sure the "call _rand" cause the run-time error but don't know how to fix.
4. its a win32 console application, compiled with dev-c++ correctly.

C code

include <stdio.h>

include <stdlib.h>

int asm_fnctn(); / protype the external ASM fnc /
int main()
{
int rnd;
rnd=asm_fnctn();
printf("Random num. = %x\n",rnd);
return 0;
}


assembly code

p586
glogal _asm_fnctn ;public to the C main prgrm
extern _rand ;C's function name
;
segment .bss ;data segment
temp resd 1 ;for temporary data
;
segment .text ;code segment
_asm_fnctn:
enter 0,0
pusha
call _rand ;calling the C function , the hot spot !
mov ,eax
popa
mov eax, ;reload the random # before leaving
leave
ret