📄 dosif.asm
字号:
Public _ms_x_curdir
;-----------
_ms_x_curdir:
;-----------
push bp
mov bp,sp
push si
mov si,6[bp] ; Get the buffer address and
mov byte ptr [si],0 ; put a zero in the first byte in
mov ah,MS_X_CURDIR ; the command is FAILED
push word ptr 4[bp]
call ms_dx_call
pop dx
pop si
pop bp
ret
Public _ms_x_exit
;---------
_ms_x_exit:
;---------
push bp
mov bp,sp
ifdef NETWARE
push es ; If this is Novell Netware and
mov ax,__psp ; the command processor is terminating
mov es,ax ; ie PSP_PARENT == PSP then do the
cmp ax,es:word ptr 16h ; special Novell Close down sequence
pop es
jnz ms_x_exit10
mov ax,7A00h ; Check for IPX being present using
int 2Fh ; the Multi-Plex Interrupt.
cmp al,0FFh
jz net_ware
ms_x_exit10:
endif
mov al,04[bp] ; Get the Return Code
mov ah,MS_X_EXIT ; terminate process function
int DOS_INT ; call the DOS
pop bp
ret
ifdef NETWARE
;
; The following routine attempts to clean-up after a Novell
; session. It does so in the following manner:-
;
; 1) Close all file handles (May be Networked !!)
; 2) Close all User Sockets
; 3) Remove all User Events from Internal lists
; 4) Use CDOS terminate function
;
net_ware:
mov ipx_offset,di
mov ipx_segment,es
mov cx,20 ; Close all the possible handles
mov bx,0 ; used by the command processor
net_w05: ; in case any have been redirected
mov ah,MS_X_CLOSE ; accross the Network
int DOS_INT
inc bx
loop net_w05
mov si,dataOFFSET socket
net_w10:
mov cx,word ptr 02[si] ; Get the number of sockets to close
mov dx,word ptr 00[si] ; starting at Socket No.
jcxz net_w30 ; Terminate on a 0 Count
push si
net_w20:
push cx
push dx ; Save Count and Socket No.
xchg dl,dh ; Swap socket no to High/Low
mov bx,1 ; Close Socket Function
call ipx ; Close Socket.
pop dx
pop cx
inc dx ; Increment Socket No
loop net_w20 ; and Loop
pop si
add si,4 ; Point to next entry in the array
jmp net_w10 ; and repeat till count is 0
net_w30: ; All sockets have been closed
mov aes_esrseg,cs
mov ax,0FFFFh ; Create Special event with the
mov bx,7 ; maximum time delay
push ds
pop es ; Pass the address of the Special
mov si,dataOFFSET aes ; Event control block call the IPX
call ipx
net_w40:
les si,aes_link ; Remove all entries from the Link
; Which are not owned by the IPX
net_w50:
mov bx,es ; get the AES segment
cmp bx,ipx_segment ; and check for a match
jnz net_w60 ; Remove this entry
les si,es:dword ptr [si] ; get the next entry and try again
jmp short net_w50
net_w60:
or bx,si ; End of List
jz net_w70 ; Yes terminate our entry
mov bx,0006h ; Cancel this event
call ipx
jmp short net_w40
net_w70:
mov bx,0006h ; Cancel our event
push ds
pop es
mov si,dataOFFSET aes
call ipx
net_exit:
mov dh,0 ; Standard Exit
mov dl,04[bp] ; With the supplied ExitCode
mov cx,P_EXITCODE ; Set the ExitCode for the Parent
int BDOS_INT
mov cx,P_TERMCPM ; Use a Concurrent Terminate Call
int BDOS_INT ; because Novell has taken over 4Ch
aes_retf: ; Dummy AES routine
retf
endif
;
; ms_x_expand(dstbuf, srcbuf) returns the full path of SRCBUF
;
Public _ms_x_expand
;-----------
_ms_x_expand:
;-----------
push bp
mov bp,sp
push si
push di
mov si,06[bp] ; Get the source String Address
mov di,04[bp] ; Get the destination string
mov byte ptr [di],0 ; address and force it to be a NULL
push ds
pop es ; ES:DI -> destination
mov ah,60h ; terminated string in case of errors
int DOS_INT
jc ms_exp_ret ; skip if error
xor ax,ax ; signal no errors
ms_exp_ret:
neg ax ; make error negative, 0 = 0
pop di
pop si
pop bp
CRET 4
Public _ms_x_wait
;---------
_ms_x_wait: ; retrieve child return code
;---------
mov ah,MS_X_WAIT ; Top byte is abort code ie ^C
int DOS_INT ; Bottom byte is return code
ret
Public _ms_x_first
;----------
_ms_x_first:
;----------
push bp
mov bp,sp
mov dx,8[bp] ; get DMA buffer address
mov ah,MS_F_DMAOFF
int DOS_INT
mov dx,4[bp] ; get ASCII string
mov cx,6[bp] ; get attribute
mov ah,MS_X_FIRST ; get search function
jmp ms_call_dos ; call DOS, check for errors
Public _ms_x_next
;---------
_ms_x_next:
;---------
push bp
mov bp,sp
mov dx,4[bp] ; get DMA buffer address
mov ah,MS_F_DMAOFF
int DOS_INT
mov ah,MS_X_NEXT ; get the function
jmp ms_call_dos ; get DX, call DOS, handle errors
ms_dx_call: ; call DOS with parameter in DX
push bp
mov bp,sp
mov dx,4[bp]
ms_call_dos:
int DOS_INT
jnc ms_dos_ok ; no carry = no error
neg ax ; else make it negative
jmp ms_dos_ret ; and return with error
ms_dos_ok:
sub ax,ax ; return 0 if no error
ms_dos_ret:
pop bp ; return 0 or negative error code
ret
Public _ms_x_rename
;-----------
_ms_x_rename:
;-----------
push bp
mov bp,sp
push di
push ds
pop es
mov ah,MS_X_RENAME
mov di,6[bp] ; ES:DI = new name
push word ptr 4[bp] ; make it look like DRC call
call ms_dx_call ; DX = 4[bp], call DOS, handle errors
pop di ; remove parameter
pop di
pop bp
ret
Public _ms_x_datetime
; ret = _ms_x_datetime (gsflag, h, &time, &date);
;-------------
_ms_x_datetime:
;-------------
push bp
mov bp,sp
mov ah,MS_X_DATETIME ; set/get time stamp function
mov al,4[bp] ; get/set subfunction (0/1)
mov bx,8[bp] ; get address of time
mov cx,[bx] ; get time
mov bx,10[bp] ; get address of date
mov dx,[bx] ; get date
mov bx,6[bp] ; get handle
int DOS_INT ; call the DOS
jc ms_dt_ret ; skip if error
sub ax,ax ; signal no errors
cmp byte ptr 4[bp],0 ; geting time/date?
jne ms_dt_ret ; skip if setting
mov bx,8[bp] ; get time address
mov [bx],cx ; update time
mov bx,10[bp] ; get date address
mov [bx],dx ; update date
ms_dt_ret:
neg ax ; make error negative, 0 = 0
pop bp
ret
;
; The following routines allow COMMAND.COM to manipulate
; the system time and date. Four functions are provided and
; these are MS_GETDATE, MS_SETDATE, MS_GETTIME and MS_SETTIME
;
; Date information is passed and return in a structure which
; has the following format.
;
; WORD Year (1980 - 2099)
; BYTE Month
; BYTE Day
; BYTE Day of the Week (Ignored on SET DATE)
Public _ms_getdate
_ms_getdate:
push bp
mov bp,sp
mov ah,MS_T_GETDATE ; get the current date from DOS
int DOS_INT
mov bx,4[bp] ; and get the structure address
mov [bx],cx ; save the year
xchg dh,dl ; swap month and day
mov 2[bx],dx ; and save
mov 4[bx],al ; and finally save the day number
pop bp ; and exit
ret
Public _ms_setdate
_ms_setdate:
push bp
mov bp,sp
mov bx,4[bp] ; and get the structure address
mov cx,0[bx] ; det the year
mov dx,2[bx] ; get the month and day
xchg dh,dl ; swap month and day
mov ah,MS_T_SETDATE ; set the current date
int DOS_INT
cbw ; 0000 = Ok and FFFF = Bad
pop bp ; and exit
ret
; Time information is passed and return in a structure which
; has the following format.
;
; BYTE Hours (0 - 23)
; BYTE Minutes (0 - 59)
; BYTE Seconds (0 - 59)
; BYTE Hundredths of a second (0 - 99)
Public _ms_gettime
_ms_gettime:
push bp
mov bp,sp
mov ah,MS_T_GETTIME ; get the current date from DOS
int DOS_INT
mov bx,4[bp] ; and get the structure address
xchg cl,ch
mov [bx],cx ; save the hours and minutes
xchg dh,dl
mov 2[bx],dx ; save seconds and hundredths
pop bp ; and exit
ret
Public _ms_settime
_ms_settime:
push bp
mov bp,sp
mov bx,4[bp] ; and get the structure address
mov cx,[bx] ; get the hours and minutes
xchg cl,ch
mov dx,2[bx] ; get seconds and hundredths
xchg dh,dl
mov ah,MS_T_SETTIME ; get the current date from DOS
int DOS_INT
cbw ; 0000 = Ok and FFFF = Bad
pop bp ; and exit
ret
Public _ms_idle_ptr
;------------
_ms_idle_ptr:
;------------
push es
push si
push di
mov ax, 4458h
int DOS_INT ; ptr in ES:AX
mov dx, es
pop di
pop si
pop es
ret
Public _ms_switchar
;-----------
_ms_switchar:
;-----------
mov ax,3700h
int DOS_INT
sub ah,ah
mov al,dl
ret
if 0
Public _ms_p_getpsp
;-----------
_ms_p_getpsp:
;-----------
mov ah,51h ; Note: SeCRET DOS 2.x entry
int DOS_INT
xchg ax,bx
ret
endif
Public _ms_f_verify
;-----------
_ms_f_verify:
;-----------
push bp
mov bp,sp
mov ah,MS_F_VERIFY
mov al,4[bp] ;get 0/1 al parameter
int DOS_INT
pop bp
ret
Public _ms_f_getverify
;--------------
_ms_f_getverify:
;--------------
mov ah,MS_F_GETVERIFY
int DOS_INT
cbw
ret
ifndef CDOSTMP
Public _ms_f_parse
;-----------
_ms_f_parse:
;-----------
push bp
mov bp, sp
push es
push si
push di
push ds
pop es
mov di, 4[bp] ; fcb
mov si, 6[bp] ; filename
mov al, 8[bp] ; flags
mov ah, MS_F_PARSE
int DOS_INT
cbw ; return code in ax
pop di
pop si
pop es
pop bp
ret
Public _ms_f_delete
;------------
_ms_f_delete:
;------------
push bp
mov bp, sp
mov dx, 4[bp] ; fcb
mov ah, MS_F_DELETE
int DOS_INT
cbw ; return code
pop bp
ret
endif
;
; The SET BREAK function returns the previous Break Flag Status
;
Public _ms_set_break
;------------
_ms_set_break:
;------------
push bp
mov bp,sp
mov dl,04[bp]
mov ax,(MS_S_BREAK SHL 8) + 2
int DOS_INT
pop bp
mov al,dl
cbw
ret
if 0
Public _ms_get_break
;------------
_ms_get_break:
;------------
mov ax,MS_S_BREAK SHL 8
int DOS_INT
mov al,dl
cbw
ret
endif
;
; mem_alloc(BYTE FAR * NEAR * bufaddr, UWORD * bufsize, UWORD min, UWORD max);
;
; max 10[bp]
; min 08[bp]
; bufsize 06[bp]
; buffadr 04[bp]
;
Public _mem_alloc
;---------
_mem_alloc:
;---------
push bp
mov bp,sp
mov bx,10[bp] ; Start with request maximum size
mem_all10:
mov ah,MS_M_ALLOC ; Attempt to allocate the maximum
int DOS_INT ; memory requested by the user.
jnc mem_all20 ; Allocation OK
cmp bx,08[bp] ; Is this less than the requested
jae mem_all10 ; No then allocate this amount
xor ax,ax ; Force the Buffer address and Buffer
mov bx,ax ; Size to Zero
mem_all20:
mov cx,bx ; Save the Buffer Size
mov bx,04[bp] ; Update the Buffer Address
mov word ptr 00[bx],0 ; Offset 0
mov word ptr 02[bx],ax ; Segment AX
mov bx,06[bp] ; Now Update the Buffer Size
mov word ptr 00[bx],cx ; and return to the caller
pop bp
ret
;
; mem_free(BYTE FAR * NEAR * bufaddr);
;
; buffadr 04[bp]
;
Public _mem_free
;---------
_mem_free:
;---------
push bp
mov bp,sp
xor ax,ax
mov bx,04[bp] ; Get the Buffer Pointer address
xchg ax,word ptr 02[bx] ; and from this the segment of the
cmp ax,0 ; allocated memory. If the memory
jz mem_free10 ; has already been freed the quit
push es ; Otherwise Free the Memory
mov es,ax
mov ah,MS_M_FREE
int DOS_INT
pop es
mem_free10:
pop bp
ret
Public _msdos
;-------
_msdos:
;-------
push bp
mov bp,sp
push si
push di
mov ah,4[bp]
mov dx,6[bp]
int DOS_INT
pop di
pop si
pop bp
ret
Public _ioctl_ver
;---------
_ioctl_ver:
;---------
ifdef DOSPLUS
mov ax,4452h ; Get DOS Plus BDOS version Number
else
mov ax,4451h ; Get Concurrent BDOS Version
endif
int DOS_INT ; Real DOS returns with Carry Set
jc cdos_v10
and ax,not 0200h ; Reset the Networking Bit
ret
cdos_v10:
xor ax,ax
ret
ifdef DOSPLUS
;
; Get CodePage information form the system. Return both the currently
; active CodePage and the System CodePage.
;
; ms_x_getcp(&globalcp, &systemcp);
;
Public _ms_x_getcp
;-----------
_ms_x_getcp:
;-----------
push bp
mov bp,sp
mov ax,MS_X_GETCP ; Get the CodePage Information
int DOS_INT ; and return an error if not
jc ms_x_getcp10 ; supported.
mov ax,bx ; Now update the callers
mov bx,04[bp] ; Global and System Codepage
mov word ptr [bx],ax ; variables
mov bx,06[bp]
mov word ptr [bx],dx
xor ax,ax
ms_x_getcp10:
neg ax ; Negate the error code has
pop bp ; no effect on 0
ret
;
; Change the current CodePage
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -