PT630 Programming Reference Guide
Page 45 of 59
------------------------------------------------------------------------------------------------------------------
1.5.29 Allocate Memory
Entry Parameter: AH = 48H
BX = block size in paragraphs (16 bytes) to be allocated
Return Value: if success, CARRY flag is cleared
AX
=
segment
address
of
block
allocated
if failed , CARRY flag is set
AX = error code
BX = largest available memory block in paragraphs
Example
:
int TS_alloc_mem(unsigned int size,unsigned char far *str,int *free)
{
unsigned long aa;
regs.h.ah=0x48;
regs.x.bx=size;
int86(0x21,®s,®s);
*free = regs.x.bx;
aa = (unsigned long)regs.x.ax * 10000L;
str = (unsigned char far *)aa;
if ((regs.x.cflag & 0x01) == 0) return(1);
else return(-1);
}
1.5.30 Free Allocated Memory
Entry Parameter: AH = 49H
ES = segment address of block to be freed
Return Value: if success ,
CARRY flag is cleared
if
failed
,
CARRY
flag
is
set
AX = error code
Example
:
int TS_free_mem(unsigned char far *str)
{
unsigned long aa;
regs.h.ah=0x49;
segregs.es=FP_SEG(str);
int86x(0x21,®s,®s,&segregs);
if ((regs.x.cflag & 0x01) == 0) return(1);
else return(-1);
}