dos_compilers/Microsoft C v1/IO.ASM
2024-06-30 12:06:07 -07:00

49 lines
1.0 KiB
NASM
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

; This module defines subroutines to input and output bytes from
; an auxiliary port.
;
; name inp -- input byte from port
;
; synopsis c = inp(port);
; int c; returned byte
; int port; port address
;
; description This function inputs a byte from the specified port
; address and returns it as the function value.
;
PGROUP GROUP PROG
PROG SEGMENT BYTE PUBLIC 'PROG'
PUBLIC INP,OUTP
ASSUME CS:PGROUP
INP PROC NEAR
PUSH BP ;SAVE BP
MOV BP,SP
MOV DX,[BP+4] ;GET PORT ADDRESS
IN AL,DX ;GET INPUT BYTE
XOR AH,AH ;CLEAR HIGH BYTE
POP BP
RET
INP ENDP
;
; name outp -- output byte to port
;
; synopsis outp(port,c);
; int port; port address
; int c; byte to send
;
; description This function sends the specified character to
; the specified port.
;
OUTP PROC NEAR
PUSH BP ;SAVE BP
MOV BP,SP
MOV DX,[BP+4] ;GET PORT ADDRESS
MOV AX,[BP+6] ;GET OUTPUT BYTE
OUT DX,AL
POP BP
RET
OUTP ENDP
PROG ENDS
END
,SP
MOV DX,[BP+4] ;GET PORT ADDRESS
MOV AX,[BP+6]