home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
decus
/
RB140
/
grlib03a.arj
/
MSDOS.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-12-08
|
9KB
|
430 lines
PAGE 60,132
title MSDOS.ASM
;UPDATE HISTORY
;==============
; 29-11-84 Preserve ES register across int 18 in kbd calls
;---------------------------------------------------------------+
; |
; Definitions for 'C' Modules |
; |
;---------------------------------------------------------------+
include asmc.h
include asmk.h
SEGEND CODE
.xlist
; Parameter offsets
param1 EQU @ab+[BP]
param2 EQU @ab+2[BP]
param3 EQU @ab+4[BP]
param4 EQU @ab+6[BP]
param5 EQU @ab+8[BP]
param6 EQU @ab+10[BP]
param7 EQU @ab+12[BP]
param8 EQU @ab+14[BP]
param9 EQU @ab+16[BP]
param10 EQU @ab+18[BP]
; macros
ldata macro
?dptr = -2
endm
lvar macro nam
nam equ ?dptr
?dptr = ?dptr-2
endm
enter macro lvars
push bp
mov bp,sp
ifnb <lvars>
sub sp,(lvars+1)/2
endif
endm
leave macro
pop bp
ret
endm
?genp macro pnum
ifnb <p&pnum>
push p&pnum
endif
endm
ccall macro p1,p2,p3,p4,p5,p6,p7,p8,p9,p10
?p = 10
rept 10
?genp %?p
?p = ?p-1
endm
endm
.list
;---------------------------------------------------------------
;
; Interface to stranger MSDOS functions:
;
; ax = msdos(ax, bx, cx, dx);
; if carry set: _carry = 1 else 0
;
;----------------------------------------------------------------
SEGDEF DATA
PUBLIC _carry ;global carry flag
_carry dw 0
SEGEND DATA
SEGDEF CODE
PUBLIC msdos ;entry point
PROCDEF msdos
enter
mov ax,param1
mov bx,param2
mov cx,param3
mov dx,param4
mov _carry,0
Push ES ;save es
int 21h ;call msdos
Pop ES ;save es
jnc nocarry
mov _carry,1
nocarry: leave
PROCEND msdos
SEGEND CODE
;---------------------------------------------------------------+
; |
; Fast Video Put Line and Attributes |
; |
; Vers. 1.0 9/13/83 A.F. |
; |
; History: |
; |
; 9/13/83 Created AF |
; |
;---------------------------------------------------------------+
;
; putline (line, col, string)
; putattr (line, col, len, array)
;
; int line,col; /* place to put string or attribs */
; char *string; /* string to write */
; char array[]; /* array of attributes */
; int len /* length of attribute array */
;
SEGDEF CODE
public putline,putattr
PROCDEF putline
enter ;initialize stack
push es ;gets clobbered
mov si,param3 ;si=> string
; get the string length in cx
push ds ;es=ds
pop es
mov di,si ;set =>
cld ;going up!
mov cx,-1 ;set count
xor al,al ;look for null
repne scasb
inc cx
not cx ;cx now has the length
mov ax,2 ;set move characters
; Putline and Putattr common code
put:
mov bl,param1 ;get line
mov bh,param2 ;and col
cmp bl,1 ;make sure line is in range 1-24
jl exit
cmp bl,24
jg exit
push ax ;save
mov al,bh ;check to make sure we don't
add ax,cx ;exceed the end of the line
cmp ax,81 ;assuming 80 chars single width
pop ax
ja exit
mov bp,ds ;the call requires bp=ds
mov di,14h ;function #
int 18h ;do it
exit:
pop es
leave
PROCEND putline
PROCDEF putattr
enter ;initialize stack
push es
mov dx,param4 ;dx=> attributes
mov cx,param3 ;length
mov ax,1 ;set attributes
jmp put ;go to common part of routines
PROCEND putattr
SEGEND CODE
SEGDEF DATA
; TRANSLATION TabLE TO CONVERT FIRMWARE 16-BIT KEYCODES INTO 'FINAL' KEYCODES
;
; FINAL KEYCODE KEY ID FIRMWARE FINAL
keytbl db 15 ;HELP 00 TO 15.
db 16 ;DO 01 TO 16.
db 0 ;COMPOSE 02 TO 0
db 2 ;PRINT SCREEN 03 TO 2
db 0FFh ; 04
db 4 ;F4 05 TO 4
db 0FFh ; 06
db 6 ;INTERRUPT 07 TO 6
db 0FFh ; 08
db 7 ;RESUME 09 TO 7
db 0FFh ; 0A
db 8 ;CANCEL 0B TO 8
db 0FFh ; 0C
db 9 ;MAIN SCREEN 0D TO 9
db 0FFh ; 0E
db 10 ;EXIT 0F TO 10.
db 0FFh ; 10
db 14 ;ADDTNL OPTIONS 11 TO 14.
db 0FFh ; 12
db 17 ;F17 13 TO 17.
db 0FFh ; 14
db 18 ;F18 15 TO 18.
db 0FFh ; 16
db 19 ;F19 17 TO 19.
db 0FFh ; 18
db 20 ;F20 19 TO 20.
db 0FFh ; 1A
db 21 ;FIND 1B TO 21.
db 0FFh ; 1C
db 22 ;INSERT HERE 1D TO 22.
db 0FFh ; 1E
db 23 ;REMOVE 1F TO 23.
db 0FFh ; 20
db 24 ;SELECT 21 TO 24.
db 0FFh ; 22
db 25 ;PREV SCREEN 23 TO 25.
db 0FFh ; 24
db 26 ;NEXT SCREEN 25 TO 26.
db 0FFh ; 26
db 27 ;UP-ARROW 27 TO 27.
db 0FFh ; 28
db 29 ;DOWN-ARROW 29 TO 29.
db 0FFh ; 2A
db 30 ;RIGHT-ARROW 2B TO 30.
db 0FFh ; 2C
db 28 ;LEFT-ARROW 2D TO 28.
db 0FFh ; 2E
db 31 ;KEYPAD 0 2F TO 31.
db 0FFh ; 30
db 0FFh ; 31
db 32 ;KEYPAD 1 32 TO 32.
db 0FFh ; 33
db 0FFh ; 34
db 33 ;KEYPAD 2 35 TO 33.
db 0FFh ; 36
db 0FFh ; 37
db 34 ;KEYPAD 3 38 TO 34.
db 0FFh ; 39
db 0FFh ; 3A
db 35 ;KEYPAD 4 3B TO 35.
db 0FFh ; 3C
db 0FFh ; 3D
db 36 ;KEYPAD 5 3E TO 36.
db 0FFh ; 3F
db 0FFh ; 40
db 37 ;KEYPAD 6 41 TO 37.
db 0FFh ; 42
db 0FFh ; 43
db 38 ;KEYPAD 7 44 TO 38.
db 0FFh ; 45
db 0FFh ; 46
db 39 ;KEYPAD 8 47 TO 39.
db 0FFh ; 48
db 0FFh ; 49
db 40 ;KEYPAD 9 4A TO 40.
db 0FFh ; 4B
db 0FFh ; 4C
db 42 ;KEYPAD DASH 4D TO 42.
db 0FFh ; 4E
db 0FFh ; 4F
db 41 ;KEYPAD COMMA 50 TO 41.
db 0FFh ; 51
db 0FFh ; 52
db 43 ;KEYPAD PERIOD 53 TO 43.
db 0FFh ; 54
db 0FFh ; 55
db 48 ;KEYPAD ENTER 56 TO 48.
db 0FFh ; 57
db 0FFh ; 58
db 44 ;KEYPAD PF1 59 TO 44.
db 0FFh ; 5A
db 0FFh ; 5B
db 45 ;KEYPAD PF2 5C TO 45.
db 0FFh ; 5D
db 0FFh ; 5E
db 46 ;KEYPAD PF3 5F TO 46.
db 0FFh ; 60
db 0FFh ; 61
db 47 ;KEYPAD PF4 62 TO 47.
db 0FFh ; 63
db 0FFh ; 64
db 5 ;BREAK 65 TO 5.
SEGEND DATA
;******************************************************************
;* character I/O
;*
; int kbd16(&i) /* level 1 console in */
; int *i;
;
; int kbdin(&i); /* level 2 console in */
; int *i;
;
; kbdout(c); /* level 2 character out */
; unsigned char c;
;
SEGDEF CODE
public kbd16,kbdin,kbdout
PROCDEF kbd16
push bp ;Computer Innovations says ax,bc,cx,dx,si & di free
mov bp,sp ; [bp+0] = old bp
; [bp+2] = return address
; [bp+4] = first (only) argument
mov di,06 ; 16 bit console function
Push ES ;save es
int 18h ; msdos equivalent of int 40
; cl = 0, 1 or FF
; ax = 16 bit character.
pop es
xchg ax,cx ; al = 0, 1 or FF, cx = char.
cbw ; ax = 0, 1 or FFFF
and ax,ax ; if ax != FFFF, don't translate...
jns nochar ; ... just return status (in ax).
test ch,01 ; ch bit 0 is 1 for function keys.
jz nofunc ; if not a function key, skip translation.
lea bx, keytbl ; address of translate table.
xchg cx,ax ; swap character and status (ax = character)
xlat ; translate char in al to one in table.
xchg ax,cx ; swap character and status (ax = status)
nofunc: mov bx,param1 ; get parameter (address of buffer)
mov [bx],cx ; put char in the buffer
nochar: pop bp ; status is in ax
ret
PROCEND kbd16
PROCDEF kbdin
push bp ;Computer Innovations says ax,bc,cx,dx,si & di free
mov bp,sp ; [bp+0] = old bp
; [bp+2] = return address
; [bp+4] = first (only) argument
mov di,02 ; 8 bit console in function
Push ES ;save es
int 18h ; msdos equivalent of int 40
; cl = 0 or FF
; al = 8 bit character.
pop es
xchg ax,cx ; al = 0 or FF, cx = char.
cbw ; ax = 0 or FFFF
and ax,ax ; if ax != FFFF ...
jns kin1 ; ... just return status (in ax).
mov bx,param1 ; get parameter (address of buffer)
mov [bx],cx ; put char in the buffer
kin1: pop bp ; status is in ax
ret
PROCEND kbdin
PROCDEF kbdout
push bp ;Computer Innovations says ax,bc,cx,dx,si & di free
mov bp,sp ; [bp+0] = old bp
; [bp+2] = return address
; [bp+4] = first (only) argument
mov ax,param1 ; get char for output
mov di,02 ; 8 bit console out function
Push ES ;save es
int 18h ; msdos equivalent of int 40
pop es
ret
PROCEND kbdout
SEGEND CODE
;---------------------------------------------------------------+
; |
; Enable and Disable Cursor |
; |
;---------------------------------------------------------------+
;
; enb_cur()
; dis_cur()
;
SEGDEF CODE
public enb_cur,dis_cur
PROCDEF enb_cur
enter ;initialize stack
push es ;gets clobbered
mov di,0Ah ;function #
int 18h ;do it
pop es
leave
PROCEND enb_cur
PROCDEF dis_cur
enter ;initialize stack
push es
mov di,08h
int 18h
pop es
leave
PROCEND dis_cur
SEGEND CODE
END