2000-05-09 01:01:16 +02:00
|
|
|
; File:
|
|
|
|
; intr.asm
|
|
|
|
; Description:
|
|
|
|
; Assembly implementation of calling an interrupt
|
|
|
|
;
|
|
|
|
; Copyright (c) 2000
|
|
|
|
; Steffen Kaiser
|
|
|
|
; All Rights Reserved
|
|
|
|
;
|
|
|
|
; This file is part of FreeDOS.
|
|
|
|
;
|
|
|
|
; FreeDOS is free software; you can redistribute it and/or
|
|
|
|
; modify it under the terms of the GNU General Public License
|
|
|
|
; as published by the Free Software Foundation; either version
|
|
|
|
; 2, or (at your option) any later version.
|
|
|
|
;
|
|
|
|
; DOS-C is distributed in the hope that it will be useful, but
|
|
|
|
; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
|
|
; the GNU General Public License for more details.
|
|
|
|
;
|
|
|
|
; You should have received a copy of the GNU General Public
|
|
|
|
; License along with DOS-C; see the file COPYING. If not,
|
|
|
|
; write to the Free Software Foundation, 675 Mass Ave,
|
|
|
|
; Cambridge, MA 02139, USA.
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
%include "segs.inc"
|
|
|
|
|
2003-03-12 23:43:53 +01:00
|
|
|
segment HMA_TEXT
|
2000-05-09 01:01:16 +02:00
|
|
|
;
|
|
|
|
; void intr(nr, rp)
|
|
|
|
; REG int nr
|
|
|
|
; REG struct REGPACK *rp
|
|
|
|
;
|
|
|
|
;
|
|
|
|
global _intr
|
|
|
|
_intr:
|
|
|
|
push bp ; Standard C entry
|
|
|
|
mov bp,sp
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
push ds
|
|
|
|
push es
|
|
|
|
|
|
|
|
mov ax, [bp+4] ; interrupt number
|
|
|
|
mov [CS:intr?1-1], al
|
|
|
|
jmp short intr?2 ; flush the instruction cache
|
|
|
|
intr?2 mov bx, [bp+6] ; regpack structure
|
|
|
|
mov ax, [bx]
|
|
|
|
mov cx, [bx+4]
|
|
|
|
mov dx, [bx+6]
|
2001-04-22 00:32:53 +02:00
|
|
|
mov si, [bx+8]
|
2000-05-09 01:01:16 +02:00
|
|
|
mov di, [bx+10]
|
2001-04-22 00:32:53 +02:00
|
|
|
mov bp, [bx+12]
|
2000-05-09 01:01:16 +02:00
|
|
|
push Word [bx+14] ; ds
|
|
|
|
mov es, [bx+16]
|
|
|
|
mov bx, [bx+2]
|
|
|
|
pop ds
|
|
|
|
|
|
|
|
int 0
|
|
|
|
intr?1:
|
|
|
|
|
|
|
|
pushf
|
|
|
|
push ds
|
|
|
|
push bx
|
|
|
|
mov bx, sp
|
|
|
|
mov ds, [SS:bx+8]
|
|
|
|
mov bx, [ss:bx+20] ; address of REGPACK
|
|
|
|
mov [bx], ax
|
|
|
|
pop ax
|
|
|
|
mov [bx+2], ax
|
|
|
|
mov [bx+4], cx
|
|
|
|
mov [bx+6], dx
|
2001-04-22 00:32:53 +02:00
|
|
|
mov [bx+8], si
|
2000-05-09 01:01:16 +02:00
|
|
|
mov [bx+10], di
|
2001-04-22 00:32:53 +02:00
|
|
|
mov [bx+12], bp
|
2000-05-09 01:01:16 +02:00
|
|
|
pop ax
|
|
|
|
mov [bx+14], ax
|
|
|
|
mov [bx+16], es
|
|
|
|
pop ax
|
2001-04-22 00:32:53 +02:00
|
|
|
mov [bx+22], ax
|
2000-05-09 01:01:16 +02:00
|
|
|
|
|
|
|
pop es
|
|
|
|
pop ds
|
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop bp
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2001-03-21 03:56:26 +01:00
|
|
|
segment INIT_TEXT
|
|
|
|
;
|
|
|
|
; void init_call_intr(nr, rp)
|
|
|
|
; REG int nr
|
|
|
|
; REG struct REGPACK *rp
|
|
|
|
;
|
|
|
|
; same stuff as above, but in INIT_SEGMENT
|
|
|
|
global _init_call_intr
|
|
|
|
_init_call_intr:
|
|
|
|
push bp ; Standard C entry
|
|
|
|
mov bp,sp
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
push ds
|
|
|
|
push es
|
|
|
|
|
|
|
|
mov ax, [bp+4] ; interrupt number
|
|
|
|
mov [CS:init_intr?1-1], al
|
|
|
|
jmp short init_intr?2 ; flush the instruction cache
|
|
|
|
init_intr?2 mov bx, [bp+6] ; regpack structure
|
|
|
|
mov ax, [bx]
|
|
|
|
mov cx, [bx+4]
|
|
|
|
mov dx, [bx+6]
|
2001-04-22 00:32:53 +02:00
|
|
|
mov si, [bx+8]
|
2001-03-21 03:56:26 +01:00
|
|
|
mov di, [bx+10]
|
2001-04-22 00:32:53 +02:00
|
|
|
mov bp, [bx+12]
|
2001-03-21 03:56:26 +01:00
|
|
|
push Word [bx+14] ; ds
|
|
|
|
mov es, [bx+16]
|
|
|
|
mov bx, [bx+2]
|
|
|
|
pop ds
|
|
|
|
|
|
|
|
int 0
|
|
|
|
init_intr?1:
|
|
|
|
|
|
|
|
pushf
|
|
|
|
push ds
|
|
|
|
push bx
|
|
|
|
mov bx, sp
|
|
|
|
mov ds, [SS:bx+8]
|
|
|
|
mov bx, [ss:bx+20] ; address of REGPACK
|
|
|
|
mov [bx], ax
|
|
|
|
pop ax
|
|
|
|
mov [bx+2], ax
|
|
|
|
mov [bx+4], cx
|
|
|
|
mov [bx+6], dx
|
2001-04-22 00:32:53 +02:00
|
|
|
mov [bx+8], si
|
2001-03-21 03:56:26 +01:00
|
|
|
mov [bx+10], di
|
2001-04-22 00:32:53 +02:00
|
|
|
mov [bx+12], bp
|
2001-03-21 03:56:26 +01:00
|
|
|
pop ax
|
|
|
|
mov [bx+14], ax
|
|
|
|
mov [bx+16], es
|
|
|
|
pop ax
|
2001-04-22 00:32:53 +02:00
|
|
|
mov [bx+22], ax
|
2001-03-21 03:56:26 +01:00
|
|
|
|
|
|
|
pop es
|
|
|
|
pop ds
|
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop bp
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX)
|
|
|
|
;
|
|
|
|
; this calls HIMEM.SYS
|
|
|
|
;
|
|
|
|
global _init_call_XMScall
|
|
|
|
_init_call_XMScall:
|
|
|
|
push bp
|
|
|
|
mov bp,sp
|
|
|
|
|
|
|
|
mov ax,[bp+8]
|
|
|
|
mov dx,[bp+10]
|
|
|
|
call far [bp+4]
|
|
|
|
|
|
|
|
pop bp
|
|
|
|
ret
|
|
|
|
|
2001-04-15 05:21:50 +02:00
|
|
|
; void FAR *DetectXMSDriver(VOID)
|
|
|
|
global _DetectXMSDriver
|
|
|
|
_DetectXMSDriver:
|
|
|
|
mov ax, 4300h
|
|
|
|
int 2fh ; XMS installation check
|
|
|
|
|
|
|
|
cmp al, 80h
|
|
|
|
je detected
|
|
|
|
xor ax, ax
|
|
|
|
xor dx, dx
|
|
|
|
ret
|
|
|
|
|
|
|
|
detected:
|
|
|
|
push es
|
|
|
|
push bx
|
|
|
|
mov ax, 4310h ; XMS get driver address
|
|
|
|
int 2fh
|
|
|
|
|
|
|
|
mov ax, bx
|
|
|
|
mov dx, es
|
|
|
|
pop bx
|
|
|
|
pop es
|
|
|
|
ret
|
|
|
|
|
|
|
|
global _keycheck
|
|
|
|
_keycheck:
|
|
|
|
mov ah, 1
|
|
|
|
int 16h
|
|
|
|
ret
|
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
;; int open(const char *pathname, int flags);
|
|
|
|
global _open
|
|
|
|
_open:
|
2001-04-15 05:21:50 +02:00
|
|
|
;; first implementation of init calling DOS through ints:
|
|
|
|
mov bx, sp
|
|
|
|
mov ah, 3dh
|
|
|
|
;; we know that SS=DS during init stage.
|
|
|
|
mov al, [bx+4]
|
|
|
|
mov dx, [bx+2]
|
|
|
|
int 21h
|
|
|
|
;; AX has file handle
|
2001-04-22 00:32:53 +02:00
|
|
|
|
|
|
|
common_exit:
|
|
|
|
jnc common_no_error
|
|
|
|
common_error:
|
|
|
|
mov ax, -1
|
|
|
|
common_no_error:
|
2001-04-15 05:21:50 +02:00
|
|
|
ret
|
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
;; int close(int fd);
|
|
|
|
global _close
|
|
|
|
_close:
|
2001-04-15 05:21:50 +02:00
|
|
|
mov bx, sp
|
|
|
|
mov bx, [bx+2]
|
|
|
|
mov ah, 3eh
|
|
|
|
int 21h
|
2001-04-22 00:32:53 +02:00
|
|
|
jmp short common_exit
|
2001-04-15 05:21:50 +02:00
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
;; UCOUNT read(int fd, void *buf, UCOUNT count);
|
|
|
|
global _read
|
|
|
|
_read:
|
2001-04-15 05:21:50 +02:00
|
|
|
mov bx, sp
|
|
|
|
mov cx, [bx+6]
|
|
|
|
mov dx, [bx+4]
|
|
|
|
mov bx, [bx+2]
|
|
|
|
mov ah, 3fh
|
|
|
|
int 21h
|
2001-04-22 00:32:53 +02:00
|
|
|
jmp short common_exit
|
2001-04-15 05:21:50 +02:00
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
;; int dup2(int oldfd, int newfd);
|
|
|
|
global _dup2
|
|
|
|
_dup2:
|
|
|
|
mov bx, sp
|
|
|
|
mov cx, [bx+4]
|
|
|
|
mov bx, [bx+2]
|
|
|
|
mov ah, 46h
|
|
|
|
int 21h
|
|
|
|
jmp short common_exit
|
|
|
|
|
2001-04-15 05:21:50 +02:00
|
|
|
;; VOID init_PSPInit(seg psp_seg)
|
|
|
|
global _init_PSPInit
|
|
|
|
_init_PSPInit:
|
|
|
|
push si
|
|
|
|
mov ah, 55h
|
|
|
|
mov bx, sp
|
|
|
|
mov dx, [bx+4]
|
|
|
|
xor si, si
|
|
|
|
int 21h
|
|
|
|
pop si
|
|
|
|
ret
|
2001-04-22 00:32:53 +02:00
|
|
|
|
2001-06-03 16:16:18 +02:00
|
|
|
;; VOID init_PSPSet(seg psp_seg)
|
|
|
|
global _init_PSPSet
|
|
|
|
_init_PSPSet:
|
|
|
|
mov ah, 50h
|
|
|
|
mov bx, sp
|
|
|
|
mov bx, [bx+2]
|
|
|
|
int 21h
|
|
|
|
ret
|
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
|
|
|
|
global _init_DosExec
|
|
|
|
_init_DosExec:
|
|
|
|
mov ah, 4bh
|
|
|
|
mov bx, sp
|
|
|
|
mov al, [bx+2]
|
|
|
|
push ds
|
|
|
|
pop es
|
|
|
|
mov dx, [bx+6] ; filename
|
|
|
|
mov bx, [bx+4] ; exec block
|
|
|
|
int 21h
|
|
|
|
jc short exec_no_error
|
|
|
|
xor ax, ax
|
|
|
|
exec_no_error
|
|
|
|
ret
|
|
|
|
|
2003-06-15 17:53:58 +02:00
|
|
|
;; int init_setdrive(int drive)
|
|
|
|
global _init_setdrive
|
|
|
|
_init_setdrive:
|
|
|
|
mov ah, 0x0e
|
|
|
|
mov bx, sp
|
|
|
|
mov dl, [bx+2]
|
|
|
|
int 21h
|
|
|
|
ret
|
|
|
|
|
|
|
|
;; int init_switchar(int char)
|
|
|
|
global _init_switchar
|
|
|
|
_init_switchar:
|
|
|
|
mov ax, 0x3701
|
|
|
|
mov bx, sp
|
|
|
|
mov dl, [bx+2]
|
|
|
|
int 21h
|
|
|
|
ret
|
|
|
|
|
2001-04-22 00:32:53 +02:00
|
|
|
;; int allocmem(UWORD size, seg *segp)
|
|
|
|
global _allocmem
|
|
|
|
_allocmem:
|
|
|
|
mov ah, 48h
|
|
|
|
mov bx, sp
|
|
|
|
mov bx, [bx+2]
|
|
|
|
int 21h
|
|
|
|
jc short common_error
|
|
|
|
mov bx, sp
|
|
|
|
mov bx, [bx+4]
|
|
|
|
mov [bx], ax
|
|
|
|
xor ax, ax
|
|
|
|
ret
|
2001-04-29 19:34:41 +02:00
|
|
|
|
2003-06-15 17:53:58 +02:00
|
|
|
;; void set_DTA(void far *dta)
|
|
|
|
global _set_DTA
|
|
|
|
_set_DTA
|
|
|
|
mov ah, 1ah
|
|
|
|
mov bx, sp
|
|
|
|
push ds
|
|
|
|
lds dx, [bx+2]
|
|
|
|
int 21h
|
|
|
|
pop ds
|
|
|
|
ret
|