home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Du Jour
/
SoftwareDuJour.iso
/
BUSINESS
/
DBASE
/
DBAPG.ARC
/
TIMEWAIT.ASM
< prev
next >
Wrap
Assembly Source File
|
1984-08-08
|
6KB
|
184 lines
;------------------------------------------------------------------------;
; TIMEWAIT.ASM by Steve Manes ;
; ;
; Prints current system time at locations specified in entry ;
; character variable (ROW,COLUMN). Format for X,Y is identical ;
; to dBASE convention in the "@ x,y" command. ;
; ;
; Two (2) character variables MUST be pre-initialized before calling ;
╗ thi≤ routinσ anΣ I╬ THI╙ ORDER║ STOR┼ "00:00:00" T╧ memvar1 ;
╗ STOR┼ "x,y" T╧ memvar2 ;
; Caution: NO error checking is done for the correct initialization ;
; of these variables! ;
; ;
; When keyboard entry is detected, the time display is erased and ;
; keyboard entry will commence at the same X,Y coordinates and the ;
; contents will be written to memvar2. Keyboard entry will cease ;
; when a carriage return is detected or string length exceeds the ;
; pre-initialized length of memvar2. The time when keyboard entry ;
; commenced will reside in memvar1. ;
; ;
; CALLing convention: CALL memvar2 ;
;------------------------------------------------------------------------;
CSEG SEGMENT 'CODE'
ASSUME CS:CSEG
mov si,bx ; we need BX so save variable address in SI
mov ch,45 ; turn off cursor
mov cl,13
mov ah,1
int 10h
;---------------------------------------------------------------------;
; Convert screen coordinates to binary. Hold X,Y address word in DI ;
;---------------------------------------------------------------------;
sub cx,cx ; clear the register
mov ch,2 ; through the loop twice
mov dl,10 ; multiplier
convert_XY:
sub ax,ax ; clear the register
inc bx ; next digit
mov al,byte ptr [bx] ; read 1st digit
and al,0Fh ; and convert to binary
inc bx ; next digit
mov dh,byte ptr [bx]
cmp dh,'0' ; is it a digit?
jb next_nmbr
mul dl ; two digit #. Mult hi-digit by 10
and dh,0Fh ; convert low digit to binary
add al,dh ; add high and low digits to AL
inc bx
next_nmbr: dec ch ; decrement loop counter
cmp ch,0 ; have X and Y been converted?
je load_Y ; no, X loaded; Y not converted yet.
load_X: mov cl,al ; store X temporarily in CL
jmp convert_XY
load_Y: sub bx,bx ; clear the register
mov bl,al ; load Y value
mov bh,cl ; load X value
mov di,bx ; store coordinates in DI
jmp main_prog ; and move on
print_time PROC NEAR
push si ; save string pointer
mov bx,0 ; "zero" display page
mov cx,1 ; display one character
mov dx,di ; get X,Y coordinates
sub si,9 ; back up to preceding TIME variable
mov bp,8 ; loop counter
write: mov ah,2 ; locate cursor
int 10h
mov al,byte ptr [si] ; write character
mov ah,10
int 10h
inc dl ; increment cursor column
inc si ; next character in string
dec bp ; decrement counter
cmp bp,0 ; all eight characters displayed?
ja write ; no, finish writing time
pop si ; restore original string pointer
ret
print_time ENDP
make_ascii PROC NEAR
div dl ; divide AX value by 10
add al,'0' ; convert remainder to ASCII
add ah,'0' ; convert quotient to ASCII
dec bx ; back up string pointer
mov byte ptr [bx],ah ; write low digit to string
dec bx
mov byte ptr [bx],al ; write high digit to string
dec bx
ret
make_ascii ENDP
main_prog:
mov bx,si ; X,Y variable contents address -1
sub bx,1 ; move to end of previous TIME
; variable.
mov ah,2Ch ; get current time from BIOS
int 21h
mov dl,10 ; divisor
sub ax,ax ; clear the register
mov al,dh ; load seconds and convert to ASCII
call make_ascii
sub ax,ax
mov al,cl ;load minutes
call make_ascii
sub ax,ax
mov al,ch ; load hours
call make_ascii
call print_time ; write current time to screen
mov ah,0Bh ; see if key has been pressed
int 21h
cmp al,0FFh ; is character available?
je keybd_entry ; yes, get input
jmp main_prog ; no, keep writing time
;------------------------------------------------------------------------;
; This routine will write the keyboard entry to the original screen ;
; coordinate variable. Entry will stop when carriage return is detected ;
; or the length of the entry string equals the original length of the ;
╗ screeε coordinatσ variable« ;
;------------------------------------------------------------------------;
keybd_entry: ; erase screen at time variable
mov bp,8 ; loop counter
mov cx,1 ; character count
mov bx,0 ; "zero" display page
mov dx,di ; get original X,Y coordinates
erase: mov ah,2 ; locate cursor
int 10h
mov al,' ' ; print ASCII space
mov ah,10
int 10h
inc dl ; next column
dec bp ; decrement loop counter
cmp bp,0 ; all 8 characters blanked?
ja erase ; no, blank the next character
mov dx,di ; cursor back to original X,Y
mov ah,2
int 10h
mov ch,12 ; turn cursor back on
mov cl,13
mov ah,1
int 10h
mov bx,si ; null the CALLing variable
mov cl,byte ptr [bx] ; get length byte
init: inc bx ; next character
mov byte ptr [bx],' ' ; ASCII space character
dec cl
cmp cl,0 ; are all characters blanked?
ja init ; no, blank the next character
mov bx,si ; variable contents address -1
mov cl,byte ptr [bx] ; load the length byte to loop limiter
key1: inc bx
mov ah,1 ; keyboard input function
int 21h
cmp al,0Dh ; carriage return?
je dB_return ; yes, exit program
mov byte ptr [bx],al ; no, write it to string
dec cl ; decrement loop counter
cmp cl,0 ; limit reached?
je dB_return ; yes, exit program
jmp key1 ; and continue reading input.
dB_return:
ret ; should be an intra-segment RET
CSEG ENDS
END
;------------------------------------------------------------------------;