hi,
I am trying to write a simple communication app using interrupts. The idea is to send a intr and a global memory direccion to pass messages. The thing is when I try to send the
offset and segment (of mem, look at code) the driver(driver.c) does not recieve the correct values!!!!
If anyone can help me I would be gratefull, thank in advance
pd: Sorry for my English
bye
------------------- Driver.C -------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <memory.h>
#include <string.h>
#include <malloc.h>
#define INT_IDLE 0x28
// I have Tried 0x05,0x21 and 0x14
#define INT 0x14
#define SHIFTL(x, n) (_ADDRESS = 0L, _ADDRESS = (long)(x), _ADDRESS << )
#define HIBYTE(x) (((unsigned)(x) >> 8) & 0xff)
#define LOWBYTE(x) ((unsigned)(x) & 0x00ff)
#define REGPAK unsigned es, unsigned ds, unsigned di, unsigned si, unsigned bp, unsigned sp, unsigned bx, unsigned dx, unsigned cx, unsigned ax, unsigned ip, unsigned cs, unsigned flags
void (_interrupt _far *func)( void );
void _interrupt _far handler(REGPAK)
{
if (LOWBYTE(ax) == 0x2d || INT!=0x21) {
// Here I get something strange, the value ax,bx,cx does no
// corresponde too the ones that a send in Test.C
cprintf("Handler %u %u %u\n",ax,cx,bx);
/*
* pars_message(MK_FP(bx,cx),buffer);
*/
}
_chain_intr(func);
outp(0x20,0x20);
}
void main(int argc,char *argv[])
{
unsigned int _ss;
unsigned int _sp;
cprintf("Resident 0x%x\n",INT);
func = _dos_getvect(INT);
_disable();
_dos_setvect(INT,handler);
_enable();
_asm {
mov _ss,SS
mov _sp,SP
}
_dos_keep(0, (_ss + (_sp >> 4) + 1) - _psp);
}
------------------- Test.C -------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
#include <malloc.h>
#include <memory.h>
#define BUFFER_SIZE 1024
#define CANT_ARGUMENT 12
#define ARGUMENT_SIZE 128
#define INT_IDLE 0x28
#define INT 0x14
unsigned int ret;
//extern unsigned _stklen = 64000U;
char str_buffer[BUFFER_SIZE];
void main (int argc,char *argv[])
{
char __far *mem;
union _REGS inregs={0};
union _REGS outregs={0};
if (argc>=3) {
char type = argv[1][0];
int command = atoi(argv[2]);
int i;
sprintf(str_buffer,"%c%i ",type,command);
for(i = 3;i<argc;i++) {
strcat(str_buffer,argv);
strcat(str_buffer,"\\"
}
mem = (char __far *) _fmalloc(BUFFER_SIZE);
_fstrcpy(mem,str_buffer);
inregs.x.bx = FP_SEG(mem);
inregs.x.cx = FP_OFF(mem);
inregs.x.ax = 0x002d
cprintf ("Sending to:0x%x\n",INT);
cprintf ("Msg(%u):'%Fs' %u:%u\n",inregs.x.ax,mem,inregs.x.bx,inregs.x.cx);
// version 1 ( when INT equals to 0x21 in driver.c )
//ret = _intdos(&inregs,&outregs);
// version 2
//ret = _int86(INT,&inregs,&outregs);
// version 3
_asm {
mov AX,0x002d
mov BX,inregs.x.bx
mov CX,inregs.x.cx
int INT
}
} else {
cprintf("usage: Test <type> <command> <arg1> <arg2> ... <argN>\n\n"
}
}
I am trying to write a simple communication app using interrupts. The idea is to send a intr and a global memory direccion to pass messages. The thing is when I try to send the
offset and segment (of mem, look at code) the driver(driver.c) does not recieve the correct values!!!!
If anyone can help me I would be gratefull, thank in advance
pd: Sorry for my English
bye
------------------- Driver.C -------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <memory.h>
#include <string.h>
#include <malloc.h>
#define INT_IDLE 0x28
// I have Tried 0x05,0x21 and 0x14
#define INT 0x14
#define SHIFTL(x, n) (_ADDRESS = 0L, _ADDRESS = (long)(x), _ADDRESS << )
#define HIBYTE(x) (((unsigned)(x) >> 8) & 0xff)
#define LOWBYTE(x) ((unsigned)(x) & 0x00ff)
#define REGPAK unsigned es, unsigned ds, unsigned di, unsigned si, unsigned bp, unsigned sp, unsigned bx, unsigned dx, unsigned cx, unsigned ax, unsigned ip, unsigned cs, unsigned flags
void (_interrupt _far *func)( void );
void _interrupt _far handler(REGPAK)
{
if (LOWBYTE(ax) == 0x2d || INT!=0x21) {
// Here I get something strange, the value ax,bx,cx does no
// corresponde too the ones that a send in Test.C
cprintf("Handler %u %u %u\n",ax,cx,bx);
/*
* pars_message(MK_FP(bx,cx),buffer);
*/
}
_chain_intr(func);
outp(0x20,0x20);
}
void main(int argc,char *argv[])
{
unsigned int _ss;
unsigned int _sp;
cprintf("Resident 0x%x\n",INT);
func = _dos_getvect(INT);
_disable();
_dos_setvect(INT,handler);
_enable();
_asm {
mov _ss,SS
mov _sp,SP
}
_dos_keep(0, (_ss + (_sp >> 4) + 1) - _psp);
}
------------------- Test.C -------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
#include <malloc.h>
#include <memory.h>
#define BUFFER_SIZE 1024
#define CANT_ARGUMENT 12
#define ARGUMENT_SIZE 128
#define INT_IDLE 0x28
#define INT 0x14
unsigned int ret;
//extern unsigned _stklen = 64000U;
char str_buffer[BUFFER_SIZE];
void main (int argc,char *argv[])
{
char __far *mem;
union _REGS inregs={0};
union _REGS outregs={0};
if (argc>=3) {
char type = argv[1][0];
int command = atoi(argv[2]);
int i;
sprintf(str_buffer,"%c%i ",type,command);
for(i = 3;i<argc;i++) {
strcat(str_buffer,argv);
strcat(str_buffer,"\\"
}
mem = (char __far *) _fmalloc(BUFFER_SIZE);
_fstrcpy(mem,str_buffer);
inregs.x.bx = FP_SEG(mem);
inregs.x.cx = FP_OFF(mem);
inregs.x.ax = 0x002d
cprintf ("Sending to:0x%x\n",INT);
cprintf ("Msg(%u):'%Fs' %u:%u\n",inregs.x.ax,mem,inregs.x.bx,inregs.x.cx);
// version 1 ( when INT equals to 0x21 in driver.c )
//ret = _intdos(&inregs,&outregs);
// version 2
//ret = _int86(INT,&inregs,&outregs);
// version 3
_asm {
mov AX,0x002d
mov BX,inregs.x.bx
mov CX,inregs.x.cx
int INT
}
} else {
cprintf("usage: Test <type> <command> <arg1> <arg2> ... <argN>\n\n"
}
}