driver .asm files optimizations (many from Arkady); remove obsolete rdatclk

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@690 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2003-09-15 10:53:09 +00:00
parent 6537b65c85
commit 9914760949
5 changed files with 87 additions and 189 deletions

View File

@ -45,16 +45,15 @@
global _fl_reset global _fl_reset
_fl_reset: _fl_reset:
mov bx,sp pop ax ; return address
mov ah,0 ; BIOS reset disketter & fixed disk pop dx ; drive
mov dl,[bx+2] push dx ; restore stack
push ax ;
mov ah,0 ; BIOS reset diskette & fixed disk
int 13h int 13h
jc fl_rst1 ; cy==1 is error sbb ax,ax ; cy==1 is error
mov ax,1 ; TRUE on success inc ax ; TRUE on success, FALSE on failure
ret
fl_rst1: xor ax,ax ; FALSE on error
ret ret
@ -64,34 +63,30 @@ fl_rst1: xor ax,ax ; FALSE on error
; ;
; COUNT fl_diskchanged(WORD drive) ; COUNT fl_diskchanged(WORD drive)
; ;
; returns 1 if disk has changed, 0 if not, 0xFF if error ; returns 1 if disk has changed, 0 if not, 0xFFFF if error
; ;
global _fl_diskchanged global _fl_diskchanged
_fl_diskchanged: _fl_diskchanged:
push bp ; C entry pop ax ; return address
mov bp,sp pop dx ; get the drive number
push dx ; restore stack
push ax ;
mov dl,[bp+4] ; get the drive number
mov ah,16h ; read change status type mov ah,16h ; read change status type
int 13h int 13h
jc fl_dchanged1 ; cy==1 is error or disk has changed mov al,1
xor ax,ax ; disk has not changed jnc fl_dc_ret1 ; cy==1 is error or disk has changed
pop bp ; C exit
ret
fl_dchanged1: cmp ah,6 cmp ah,6 ; ah=6: disk has changed
jne fl_dc_error je fl_dc_ret
mov ax,1 dec ax ; 0xFF on error
pop bp ; C exit
ret
fl_dc_error: mov ax,0FFh ; 0xFF on error fl_dc_ret1: dec ax
pop bp ; C exit fl_dc_ret: cbw
ret ret
; ;
; Format Sectors ; Format Sectors
; ;
@ -140,37 +135,31 @@ fl_common:
push bp ; C entry push bp ; C entry
mov bp,sp mov bp,sp
mov dl,[bp+4] ; get the drive (if or'ed 80h its mov cx,[bp+8] ; cylinder number (lo only if hard)
; hard drive.
mov dh,[bp+6] ; get the head number
mov bx,[bp+8] ; cylinder number (lo only if hard)
mov al,1 ; this should be an error code mov al,1 ; this should be an error code
cmp bx,3ffh ; this code can't write above 3ff=1023 cmp ch,3 ; this code can't write above 3ff=1023
ja fl_error ja fl_error
mov ch,bl ; low 8 bits of cyl number xchg ch,cl ; ch=low 8 bits of cyl number
ror cl,1 ; extract bits 8+9 to cl
xor bl,bl ; extract bits 8+9 to cl ror cl,1
shr bx,1 or cl,[bp+0Ah] ; or in the sector number (bits 0-5)
shr bx,1
mov cl,[bp+0Ah] ; sector number
and cl,03fh ; mask to sector field bits 5-0
or cl,bl ; or in bits 7-6
mov al,[bp+0Ch] ; count to read/write mov al,[bp+0Ch] ; count to read/write
les bx,[bp+0Eh] ; Load 32 bit buffer ptr les bx,[bp+0Eh] ; Load 32 bit buffer ptr
mov dl,[bp+4] ; get the drive (if or'ed 80h its
; hard drive.
mov dh,[bp+6] ; get the head number
int 13h ; write sectors from mem es:bx int 13h ; write sectors from mem es:bx
mov al,ah sbb al,al ; carry: al=ff, else al=0
jc fl_wr1 ; error, return error code and al,ah ; carry: error code, else 0
xor al,al ; Zero transfer count ; (Zero transfer count)
fl_wr1:
fl_error: fl_error:
xor ah,ah ; force into < 255 count mov ah,0 ; force into < 255 count
pop bp pop bp
ret ret
@ -187,21 +176,24 @@ _fl_lba_ReadWrite:
push ds push ds
push si ; wasn't in kernel < KE2024Bo6!! push si ; wasn't in kernel < KE2024Bo6!!
mov dl,[bp+4] ; get the drive (if or'ed 80h its mov dl,[bp+4] ; get the drive (if ored 80h harddrive)
mov ax,[bp+6] ; get the command mov ax,[bp+6] ; get the command
lds si,[bp+8] ; get far dap pointer lds si,[bp+8] ; get far dap pointer
int 13h ; read from/write to drive int 13h ; read from/write to drive
mov al,ah ; place any error code into al
xor ah,ah ; zero out ah
pop si pop si
pop ds pop ds
pop bp pop bp
ret_AH:
mov al,ah ; place any error code into al
mov ah,0 ; zero out ah
ret ret
;
; void fl_readkey (void);
;
global _fl_readkey global _fl_readkey
_fl_readkey: xor ah, ah _fl_readkey: xor ah, ah
int 16h int 16h
@ -209,50 +201,50 @@ _fl_readkey: xor ah, ah
global _fl_setdisktype global _fl_setdisktype
_fl_setdisktype: _fl_setdisktype:
push bp pop bx ; return address
mov bp, sp pop dx ; drive number (dl)
mov dl,[bp+4] ; drive number pop ax ; disk type (al)
mov al,[bp+6] ; disk type push ax ; restore stack
push dx
push bx
mov ah,17h mov ah,17h
int 13h int 13h
mov al,ah jmp short ret_AH
xor ah,ah
pop bp
ret
;
; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors);
;
global _fl_setmediatype global _fl_setmediatype
_fl_setmediatype: _fl_setmediatype:
push bp pop ax ; return address
mov bp, sp pop dx ; drive number
pop cx ; number of tracks
pop bx ; sectors/track
push bx ; restore stack
push cx
push dx
push ax
push di push di
mov dl,[bp+4] ; drive number dec cx ; should be highest track
mov bx,[bp+6] ; number of tracks xchg ch,cl ; low 8 bits of cyl number
dec bx ; should be highest track
mov ch,bl ; low 8 bits of cyl number
xor bl,bl ; extract bits 8+9 to cl ror cl,1 ; extract bits 8+9 to cl bit 6+7
shr bx,1 ror cl,1
shr bx,1
mov cl,[bp+8] ; sectors/track
and cl,03fh ; mask to sector field bits 5-0
or cl,bl ; or in bits 7-6 or cl,bl ; or in bits 7-6
mov ah,18h mov ah,18h
int 13h int 13h
mov al,ah
mov ah,0
jc skipint1e jc skipint1e
mov bx,es push es
xor dx,dx xor dx,dx
mov es,dx mov es,dx
cli cli
pop word [es:0x1e*4+2] ; set int 0x1e table to es:di
mov [es:0x1e*4 ], di mov [es:0x1e*4 ], di
mov [es:0x1e*4+2], bx ; set int 0x1e table to es:di (bx:di)
sti sti
skipint1e: skipint1e:
pop di pop di
pop bp jmp short ret_AH
ret

View File

@ -34,24 +34,14 @@ segment HMA_TEXT
global _getvec global _getvec
_getvec: _getvec:
mov bx,sp pop ax ; return address
mov ax,[ss:bx+2] pop bx ; int #
push bx ; restore stack
; push ax
; assembler version - ax = vector number add bx,bx
; returns vector in dx:ax add bx,bx ; Multiply by 4
;
global getvec
getvec:
shl ax,1 ; Multiply by 4
shl ax,1
xor dx,dx ; and set segment to 0 xor dx,dx ; and set segment to 0
mov es,dx mov es,dx
mov bx,ax les ax,[es:bx]
pushf ; Push flags mov dx,es
cli ; Disable interrupts
mov ax,[es:bx]
mov dx,[es:bx+2]
popf ; Pop flags
ret ret

View File

@ -1,87 +0,0 @@
;
; File:
; rdatclk.asm
; Description:
; read the AT style clock from bios
;
; Copyright (c) 1995
; Pasquale J. Villani
; All Rights Reserved
;
; This file is part of DOS-C.
;
; DOS-C 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.
;
; Logfile: C:/dos-c/src/drivers/rdatclk.asv
;
; $Header$
;
%include "../kernel/segs.inc"
segment HMA_TEXT
;
;COUNT ReadATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds)
;BYTE *bcdDays;
;BYTE *bcdHours;
;BYTE *bcdMinutes;
;BYTE *bcdSeconds;
;
global _ReadATClock
_ReadATClock:
push bp
mov bp, sp
xor cx, cx ; cx=dx=0 check if present
xor dx, dx ; if it returns non-zero
clc ; necessary according to RBIL
mov ah,4
int 1ah
jc @RdATerror
or cx, cx
jnz @RdAT1140
or dx, dx
jnz @RdAT1140
@RdATerror: mov ax, 1
pop bp
ret
@RdAT1140:
clc
mov ah, 2
int 1ah
jc @RdATerror
; bcdSeconds = 10
; bcdMinutes = 8
; bcdHours = 6
; bcdDays = 4
mov bx,word [bp+6] ;bcdHours
mov byte [bx],ch ;Hours
mov bx,word [bp+8] ;bcdMinutes
mov byte [bx],cl ;Minutes
mov bx,word [bp+10] ;bcdSeconds
mov byte [bx],dh ;Seconds
clc
mov ah,4
int 1ah
jc @RdATerror
mov bx,word [bp+4] ;bcdDays
mov word [bx],dx ;Days
mov word [bx+2],cx
sub ax,ax
pop bp
ret

View File

@ -38,17 +38,17 @@ segment HMA_TEXT
; ;
global _ReadPCClock global _ReadPCClock
_ReadPCClock: _ReadPCClock:
xor ah,ah mov ah,0
int 1ah int 1ah
extern _DaysSinceEpoch ; ; update days if necessary extern _DaysSinceEpoch ; ; update days if necessary
mov ah,0 ; (ah is still 0, al contains midnight flag)
add word [_DaysSinceEpoch ],ax ; *some* BIOS's accumulate several days add word [_DaysSinceEpoch ],ax ; *some* BIOS's accumulate several days
adc word [_DaysSinceEpoch+2],0 ; adc word [_DaysSinceEpoch+2],0 ;
mov ax,dx ; set return value ; set return value dx:ax
mov dx,cx xchg ax,cx ; ax=_cx, cx=_ax
xchg ax,dx ; dx=_cx, ax=_dx (cx=_ax)
ret ret

View File

@ -38,10 +38,13 @@ segment HMA_TEXT
; ;
global _WritePCClock global _WritePCClock
_WritePCClock: _WritePCClock:
mov bx,sp
; Ticks = 4 ; Ticks = 4
mov cx,word [ss:bx+4] pop ax ; return address
mov dx,word [ss:bx+2] ;Ticks pop dx
pop cx ; Ticks
push cx ; restore stack
push dx
push ax
mov ah,1 mov ah,1
int 1ah int 1ah
ret ret