How do I get info from the stack, using inline assembly, to program in c? -


i have task , i'm asking help. (on simple c lang')

what need do? need check every command on main c program (using interrupt num 1) , printing message if next command same procedure sent earlier stack, other procedure.

what want do? want take info stack, using inline assembley, , put on variable can compare on c program after returnning c. (volatile)

this program:

#include <stdio.h> #include <dos.h> #include <conio.h> #include <stdlib.h>  typedef void (*fun_ptr)(void); void interrupt (*int1save) (void); //pointer interrupt num 1//  volatile fun_ptr our_func; char *str2;  void interrupt my_inter (void) //new interrupt// {volatile fun_ptr next_command; asm {   push bp     mov bp,sp     push ax     push bx     push es     mov es,[bp+4]                mov bx,[bp+2]      mov ax,es:[bx]     mov word ptr next_command,ax       pop es     pop bx     pop ax     pop bp} if (our_func==next_command) printf("procedure %s has been called\n",str2);}  void animate(int *iptr,char str[],void (*funptr)(), char fstr[]) { str2=fstr; our_func=funptr;  int1save = getvect(1); // save old interrupt// setvect(1,my_inter);      asm {   pushf //tf on//     pop ax     or ax,100000000b     push ax     popf}}  void unanimate() {asm {  pushf //tf off//         pop ax         , ax,1111111011111111b         push ax         popf} setvect (1,int1save); //restore old interrupt//}  void main(void) {int i;  int f1 = 1;  int f2 = 1;  int fibo = 1;   animate(&fibo, "fibo", sleep, "sleep");  for(i=0; < 8; i++)  {   sleep(2);   f1 = f2;   f2 = fibo;   fibo = f1 + f2;} // for//  unanimate();} // main// 

my question... off course problem @ "my inter" on inline assembly. can't figure out. doing wrong? (please take @ code above) wanted save address of pointer specific procedure (sleep) in volatile our_func. take info (address each next command) stack volatile next_command , finaly returnning c , make compare each time. if same value (address) on both variables print specific message. hope i'm clear..

10x,

nir b

answered comment op

i got answer wanted:

asm {   mov si,[bp+18]  //taking address of each command//         mov di,[bp+20]         mov word ptr next_command+2,di         mov word ptr next_command,si} if ((*our_func)==(*next_command))   //making next_command compare//     printf("procedure %s has been called\n",str2); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -