cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/28/14:15:28

From: igp AT vlc DOT servicom DOT es (Ignacio García Pérez)
Newsgroups: comp.os.msdos.djgpp
Subject: HELP!... execute CODE in DATA segment seems not work
Date: Fri, 28 Aug 1998 17:46:19 GMT
Organization: GND
Lines: 92
Message-ID: <35e6eadc.3949780@crispin>
Reply-To: igp AT vlc DOT servicom DOT es
NNTP-Posting-Host: rdsi23.vlc.servicom.es
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,

I've been playing around with the idea of using interrupt wrappers
located in C structures. But had no luck and can't guess what's wrong.

The following code has an array of bytes which corresponds to a simple
interrupt service routine that just increments a variable. This code
is patched with the proper DS selector value and the proper offset of
the variable to be incremented.

Afterwards, I just set the IRQ0 (INT8, timer tick interrupt) to point
to the byte array, and the print continuously the variable value.

If the interrupt service woutine were being serviced properly, the
printed value should increment (yes, I declared it volatile). If it
were being called properly but there was something wrong with the code
in the byte array, the machine would surely just hang up or blow away
with some SIGSEGV signal, but none of the two things happens. The
variable is not incremented.

I attach the sources just in case some DJGPP guru can tell me what's
wrong there:



#include <extdef.h>
#include <dpmi.h>
#include <sys\segments.h>



byte Test[]={

/* 0000 */   0x50,                  /*         pushl   %eax         */
/* 0001 */   0x1E,                  /*         pushl   %ds          */
/*      */                          /*                              */
/* 0002 */   0x66,0xB8,             /*         movw    $0000,%ax    */
/* 0004 */   0x00,0x00,             /*                              */
/* 0006 */   0x66,0x8E,0xD8,        /*         movw    %ax,%ds      */
/* 0009 */   0xFF,0x05,             /*         incl    0            */
/* 000b */   0x00,0x00,0x00,0x00,   /*                              */
/*      */                          /*                              */
/* 000f */   0xB0,0x20,             /*         movb    $0x20,%al    */
/* 0011 */   0xE6,0x20,             /*         outb    %al,$0x20    */
/*      */                          /*                              */
/* 0013 */   0x1F,                  /*         popl    %ds          */
/* 0014 */   0x58,                  /*         popl    %eax         */
/* 0015 */   0xCF,                  /*         iret                 */

    };



#include <conio.h>

volatile dword TickCount;



void main(void) {
    __dpmi_paddr A,B;


    *(word  *)(Test+0x0004)=(word)_my_ds();	// Path code so it can
    *(dword *)(Test+0x000B)=(dword)&TickCount;	// increment TickCount


    B.selector=(word)_my_ds();	// New interupt vector will
    B.offset32=(dword)&Test; 	// point to code in data
				// segment

    if (__dpmi_get_protected_mode_interrupt_vector(0x08,&A))
    	{ cprintf("Error GET\r\n"); return; }
    if (__dpmi_set_protected_mode_interrupt_vector(0x08,&B))
    	{ cprintf("Error SET\r\n"); return; }

    while (!kbhit()) {
    	cprintf("%lu\r\n",TickCount);
    	}
    getch();

    if (__dpmi_set_protected_mode_interrupt_vector(0x08,&A))
    	{ cprintf("Error SET\r\n"); }

    }






Thanks. Nacho.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019