DOS (and Windows) Library

The routines in this section are specific to the DOS (MSDOS, PCDOS, DRDOS) version of ScriptEase. They are included internally to the ScriptEase program. All of these routines are available to any ScriptEase program executed by ScriptEase under DOS (or Windows).

Most of these routines allow the programmer to have more power than is generally acknowledged as safe under ScriptEase' guidelines. Be cautious when you use these commands, they provide plenty of rope with which to hang yourself.

Windows is built on top of DOS, so the functions in this library are also available in the Windows version of ScriptEase.


address
 

DESCRIPTION

Convert segment:offset pointer into memory address.

SYNTAX

int Address(int segment, int offset)

COMMENTS

Address() converts the segment and offset into a single segment:offset address.

RETURN

Return a segment:offset address suitable for use in calls such as peek() and poke().

SEE ALSO

offset(), pointer(), segment()


asm
 

DESCRIPTION

Execute imbedded assembled code.

SYNTAX

int asm(byte[] buf[, int ax, int bx[, int cx, int dx[, int si[, int di[,
int ds[, int es]]]]]]]])

COMMENTS

Make a far call to the routine that you have coded into buf. ax, bx, cx, dx, si, di, ds, and es are optional; if some or all are supplied, then the ax, bx, cx, etc... will be set to these values when the code at buf is called. The code in buf will be executed with a far call to that address, and is responsible for returning via retf or other means. The ScriptEase calling code will restore ALL registers except ss, sp, ax, bx, cx, and dx. If es or ds are supplied, then they must be valid values or 0, if 0 then the current value will be used.

RETURN

Returns a long value for whatever is in DX:AX when buf returns.

EXAMPLE

The following example uses 80x86 assembly code to rotate memory bits:

RotateByteRight(byte b, int count)

// return value of byte b rotate count byte

{

assert( 0 <= b && b <= 0xFF );

assert( 0 <= count && count <= 8 )

// assembly code for would look as follows:

// ror al, cl D2C8

// retf CB

return asm(`\xD2\xC8\xCB',b,0,count,0);

}


inport
 

DESCRIPTION

Read byte from a hardware port.

SYNTAX

byte inport(int portid)

COMMENTS

Read a byte from hardware port: portid.


inportw
 

DESCRIPTION

Read word from a hardware port.

SYNTAX

int inportw(int portid)

COMMENTS

Read a word (16 bit) from hardware port: portid. Value read is unsigned (not negative).


interrupt
 

DESCRIPTION

Execute an 8086 interrupt.

SYNTAX

bool interrupt(int Interrupt, RegIn[, RegOut])

COMMENTS

Set registers, call 8086 interrupt function, and then get the return values of the registers. RegIn and RegOut are structures containing the elements corresponding to the registers on an 8086. On input, those structure members that are defined will be set, and those that are not defined will be set to zero, with the exception of the segment registers (ES & DS) which retain their current values if not explicitly specified. The possible defined input values are AX, AH, AL, BX, BH, BL, CX, CH, CL, DX, DH, DL, BP, SI, DI, DS, ES. All Fields of the Output reg structure are the same, with the addition of the FLAGS member, and all are set before returning. If RegOut is not supplied, then the return registers and FLAGS register will be set for RegIn on return from the interrupt call.

RETURN

Since many interrupts set the carry flag for error, this function will return False if the carry flag is set, else returns True.

MODIFIES

RegOut is set to the register values upon return from Interrupt. If RegOut is not supplied then RegIn is set to contain the register values upon return from Interrupt.

EXAMPLE

The following example calls the DOS interrupt service 0x2C to read the clock:

PrintDOStime()

// display DOS time as accurately as it is read

{

reg.ah = 0x2C;

interrupt(0x21,reg);

printf("%2d:%02d:%02d",reg.ch,reg.cl,reg.dh);

}


offset, segment

DESCRIPTION

Break far pointer into segment:offset components.

COMMENTS

See "segment, offset".

SEE ALSO

Address(), pointer()


outport
 

DESCRIPTION

Write byte to a hardware port.

SYNTAX

void outport(int portid, byte value)

COMMENTS

Write byte value to hardware port portid.


outportw
 

DESCRIPTION

Write word to a hardware port.

SYNTAX

void outportw(int portid, int value)

COMMENTS

Write word (16 bit) value to hardware port portid.


segment, offset

DESCRIPTION

Break far pointer into segment:offset components.

SYNTAX

int segment(byte[] buf), int offset(byte[] buf) int segment(int address), int segment(address)

COMMENTS

These functions return the segment and offset of the data at index 0 of buf, which must be a byte array. The buffer must be already big enough for whatever purpose it is used, and no changes must be made to the size of buf after these values are determined because changing the size of buf might change its absolute address. If the address versions are used, then address is assumed to be a far pointer to data, and segment will be the high word while address will be the low word. See Address() for converting segment and offset into a single address.

RETURN

Return segment or offset of buffer such that 8086 would recognize the address segment::buffer as pointing to the first byte of buf.

SEE ALSO

Address(),pointer()