home *** CD-ROM | disk | FTP | other *** search
- ;
- ; i86.asm INTEL 8086 primitives
- ;
- ; (C) Copyright 19896 SOuth Mountain Software Inc.
- ; All Rights Reserved
- ;
- ; ====================================
- ; Microsoft C interface
- ; ====================================
- ;
- ; i86_int Execute the software interrupt
- ; i86_peek Read the byte of logical 8086 memory
- ; i86_poke Write the byte of logical 8086 memory
- ; i86_in Read the port (new for revision 2.0)
- ; i86_out Write the port value (new for revision 2.0)
- ;
- ; Please include the I86.h file when compiling C programs
- ; using the i86 functions.
- ;
- ; revision history:
- ;
- ; 1.0 10/12/86 6196 Original code
- ; 1.1 08/21/87 Saving the DI register with INT calls
- ; 2.0 Renamed <Label> reserved symbol to <GotoL>
- ; (for MASM rev 5.0)
- ; Added i86_in and i86_out
-
- INCLUDE ECLMACRO.INC
- modstart i86
-
-
-
- ; ===============================================================
- ; i86_int Execute the software interrupt
- ; ===============================================================
- ;
- ; C invocation:
- ; #include "i86.h"
- ;
- ; int int_no, flags;
- ; struct i86_reg packet;
- ; flags = i86_int(int_no, &packet);
- ;
- ; Stack: i86_reg type:
- ; +------------+ +------------+
- ; | packet --|----+ | DX | + 06
- ; |------------| | +------------|
- ; | int_no | | | CX | + 04
- ; |------------| | |------------|
- ; | return IP | | | BX | + 02
- ; |------------| | |------------|
- ; | return BP | +---->| AX | + 00
- ; |------------| +------------+
- ; | | |
- ; V
- ;
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; Stack as above
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; AX Full 8086 flag word value
- ; packet.wreg.AX register AX after the software interrupt
- ; packet.wreg.BX register BX after the software interrupt
- ; packet.wreg.CX register CX after the software interrupt
- ; packet.wreg.DX register DX after the software interrupt
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; Not applicable
- ; ==============================================================
-
- entry i86_int
- pushreg
- PUSH DI ; *** Revision 1.1 ***
- PUSH SI
- PUSH DS
- loadint1 AX ; Store the given INTerrupt
- MOV BYTE PTR CS:[GotoL-1], AL
-
- loadptr2 ; Unload registers into DX:BX
- MOV SI, BX
- MOV DS, DX
- PUSH SI
- PUSH DS
-
- MOV AX, [SI]
- MOV BX, [SI+2]
- MOV CX, [SI+4]
- MOV DX, [SI+6]
-
- JMP CAUSE_RELOAD_CACHE
- CAUSE_RELOAD_CACHE:
- INT 00
- GotoL:
- POP DS
- POP SI
- MOV [SI], AX
- MOV [SI+2], BX
- MOV [SI+4], CX
- MOV [SI+6], DX
-
- PUSHF
- POP AX ; Restore flags in return AX
- POP DS
- POP SI
- POP DI ; *** Revision 1.1 ***
- popreg
- RET
- endit i86_int
-
-
- ; ===============================================================
- ; i86_peek Read the byte of logical 8086 memory
- ; ===============================================================
- ;
- ; C invocation:
- ; #include "i86.h"
- ;
- ; unsigned int offset, segment;
- ; unsigned char byte;
- ; byte = i86_peek(offset, segment);
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; first arg int Offset word
- ; second arg int Segment word
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; AL Byte read from memory
- ; AH 00
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; Not applicable
- ; ==============================================================
-
- entry i86_peek
- pushreg
- PUSH DS
- PUSH BX
- loadint2 BX
- MOV DS, BX
- loadint1 BX
- MOV AL, [BX]
- MOV AH, 0
- POP BX
- POP DS
- popreg
- RET
- endit i86_peek
-
-
- ; ===============================================================
- ; i86_poke Write the byte of logical 8086 memory
- ; ===============================================================
- ;
- ; C invocation:
- ; #include "i86.h"
- ;
- ; unsigned int offset, segment;
- ; unsigned char byte;
- ; i86_poke(offset, segment, byte);
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; first arg int Offset word
- ; second arg int Segment word
- ; third arg int Byte to write
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; Not applicable
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; Not applicable
- ; ==============================================================
-
- entry i86_poke
- pushreg
- PUSH DS
- PUSH BX
-
- loadint2 BX
- MOV DS, BX
- loadint1 BX
- loadint3 AL
- MOV [BX], AL
-
- POP BX
- POP DS
- popreg
- RET
- endit i86_poke
-
- ; ===============================================================
- ; i86_in Read the byte from I/O space
- ; ===============================================================
- ;
- ; C invocation:
- ; #include "i86.h"
- ;
- ; unsigned int io_address; /* 12 bits only */
- ; unsigned char byte;
- ; byte = i86_in(io_address);
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; first arg int I/O 12-bit address
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; AL Byte read from memory
- ; AH 00
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; Not applicable
- ; ==============================================================
-
- entry i86_in
- pushreg
- PUSH DX
- loadint1 DX
- IN AL, DX
- MOV AH, 0
- POP DX
- popreg
- RET
- endit i86_in
-
-
- ; ===============================================================
- ; i86_out Write the byte to I/O space
- ; ===============================================================
- ;
- ; C invocation:
- ; #include "i86.h"
- ;
- ; unsigned int io_address; /* 12 bits only */
- ; unsigned char byte;
- ; i86_out(io_address, byte);
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; first arg int I/O 12-bit address
- ; 2nd arg int byte to write
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; not applicable
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; Not applicable
- ; ==============================================================
-
- entry i86_out
- pushreg
- PUSH DX
- loadint1 DX
- loadint2 AX
- OUT DX, AL
- MOV AX, 0
- POP DX
- popreg
- RET
- endit i86_out
-
- modend i86
- END
-