Category : Files from Magazines
Archive   : DDJ0892.ZIP
Filename : BORL_EXT.ASC
Output of file : BORL_EXT.ASC contained in archive : DDJ0892.ZIP
by Al Stevens
Example 1:
(a)
_AX = 123;
_ES = _DS;
(b)
mov ax,123
push ds
pop es
(c)
mov ax,123
mov ax,ds
mov es,ax
(d)
_ES = _DS;
_AX = 123;
Example 2:
_AH = 0x48; // Allocate memory function
_BX = 10; // # of paragraphs to allocate
geninterrupt(0x21); // call DOS
if ((_FLAGS & 1) == 0) // test carry bit
segment = _AX; // segment of the allocated block
else
// ... error ...
Example 3:
disable();
_SS = oldss; // interrupts must not occur now
_SP = oldsp; // otherwise SS and SP will be wrong
enable();
Example 4:
(a)
void interrupt (*oldISR)(void);
oldISR = getvect(VECTOR);
setvect(VECTOR, newISR);
(b)
(*oldISR)();
(c)
setvect(VECTOR, oldISR);
Example 5:
(a)
typedef struct {
int bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,fl;
} IREGS;
(b)
void interrupt newISR(IREGS ir)
{
// ...
}
(c)
if (ir.ax == 5)
// ....
(d)
ir.ax = 3; // return 3 in ax
ir.fl |= 1; // return the carry bit on
Example 6:
(a)
void interrupt newISR(IREGS ir)
{
// do some processing that might change registers
_AX = ir.ax; // restore the registers that the old ISR needs
_BX = ir.bx;
(*oldISR)(); // chain to the old isr
}
(b)
void interrupt newISR(IREGS ir)
{
(*oldISR)(); // chain to the old isr
ir.ax = _AX; // caller will get ax
ir.fl = _FLAGS; // and the flags
}
(c)
void interrupt newISR(IREGS ir)
{
void interrupt (*tmpISR)();
tmpISR = oldISR; // use function pointer on the stack
_DS = ir.ds; // reset DS
(*tmpISR)(); // chain to the old isr through tmp ptr
}
(d)
void interrupt newISR(IREGS ir)
{
void interrupt (*tmpISR)();
int oldds = _DS; // save ISR's DS
tmpISR = oldISR; // use function pointer on the stack
_DS = ir.ds; // reset DS
(*tmpISR)(); // chain to the old isr through tmp ptr
_DS = oldds; // reset DS
// ... do further processing
}
Example 7:
_data segment para public 'data'
_data ends
_bss segment word public 'bss'
_bss ends
_bssend segment byte public 'bss'
_bssend ends
_stack segment stack 'stack'
_stack ends
_text segment byte public 'code'
_text ends
Example 8:
tsr.exe : tsr.obj emm.obj xms.obj int2f.obj tsrinit.lib
tlink /m /s int2f emm xms tsr,tsr.exe,tsr,$(CLIB) tsrinit
tsrinit.lib : c0t.obj tsrinit.obj emminit.obj xmsinit.obj init.obj
tlib tsrinit +tsrinit.obj +c0t.obj +emminit.obj +xmsinit.obj +init.obj
Example 9:
(a)
if (_CS > 0xa000) {
dispstr("\a\r\nCannot loadhigh");
return;
}
(b)
EXTERN struct vectors {
int vno;
void (interrupt **oldvect)(void);
void (interrupt *newvect)(void);
} vectors[] = {
{TIMER, &oldtimer, (void interrupt (*)())newtimer},
{INT28, &old28, (void interrupt (*)())new28},
{KYBRD, &oldkb, (void interrupt (*)())newkb},
{DISK, &olddisk, (void interrupt (*)())newdisk},
{VIDEO, &oldvideo, (void interrupt (*)())newvideo},
{TSRPLUSINT, &old2f, (void interrupt (*)())new2f},
{0, NULL, NULL}};
#define newvectors(vecs) \
{ \
register struct vectors *vc = vecs; \
while (vc->vno) { \
*(vc->oldvect) = getvect(vc->vno); \
setvect(vc->vno, vc->newvect); \
vc++; \
} \
}
Example 10:
/* ------ compute program size ------- */
highmemory = _CS + ((unsigned)&codeend / 16);
sizeprogram = highmemory - _psp;
/* ------ adjust MCB for TSRPLUS ------- */
_ES = _psp;
_BX = sizeprogram;
_AX = 0x4a00;
geninterrupt(DOS);
Example 11:
(a)
sizeprogram = _CS+((unsigned) main >> 4)-_psp;
if ((unsigned) main % 4)
sizeprogram++;
(b)
_DX = sizeprogram;
_AX = 0x3100;
geninterrupt(DOS);
Example 12:
/* ----- keyboard ISR ------ */
static void interrupt newkb(void)
{
unsigned char kbval = inportb(0x60);
if (!hotkeyhit && !running) {
if (Keymask && (peekb(0, 0x417) & 0xf) == Keymask)
if (Scancode == 0 || Scancode == kbval)
hotkeyhit = TRUE;
if (hotkeyhit) {
/* --- reset the keyboard ---- */
kbval = inportb(0x61);
outportb(0x61, kbval | 0x80);
outportb(0x61, kbval);
outportb(0x20, 0x20);
return;
}
}
(*oldkb)();
}
Example 13:
intsp = _SP;
intss = _SS;
_SP = tsrsp;
_SS = tsrss;
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/