home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
UTILITY
/
TIMERS.ZIP
/
TIMER2.ASM
< prev
next >
Wrap
Assembly Source File
|
1993-03-02
|
12KB
|
325 lines
TITLE TIMER.ASM
;Author: Charles R. Grosvenor Jr.
;Date Written: Novemeber 11-12, 1992
;Purpose: Utility for BBS
; This allows me to break out of the autoexec.bat loop file
; before the stupid thing loads the BBS, helpful if the modem
; is having problems or if I want to run a program other than
; the BBS
;Why Assembly: C and Pascal created huge, psycho hose beast programs of
; about 30K (ok, it's miniscule anyways) but this is a little
; over 2K, think of ALL that SPACE I save... >grin<
; it does seem to exit it out of the loop quicker.
;Inputs: string of numbers, i.e. timer 10
; where the number (here 10) would count down to 1
;Outputs: MS-DOS ErrorLevel=0 if timeout occurs,
; MS-DOS ErrorLevel=(ascii code of key hit) if it's aborted
; Timer to count from 5 to 1 is default
; 32767 is the maximum, strange I know, probably cause it's signed
; that's about 9 hours, which is too long to leave the thing waiting anyways
; This is my FIRST program that I have written with a purpose, granted,
; it has taken me 10 hours or so, so the code at this point is anything
; but neat. Two days in the making, and I only lifted ONE procedure
; from somewhere else, that was the bin16asc, it's a it tough for me
; right now. Hopefully not at the end of the month
INCLUDE timer.mac
DOSSEG
.MODEL SMALL
.STACK 10h
.DATA
keyHit EQU 255
cr EQU 0dh
lf EQU 0ah
eos EQU 0
blanks DB " ",eos
prompt DB "Count down from ",eos
intStr DB 10(?)
.CODE
main proc near
readPSP:
call _CUROFF
mov cx,05h
mov bx,80h ; charcater count of command tail
xor dh,dh
mov dl,BYTE PTR [bx]
and dx,dx
jne strip
mov cx,05h ; we didn't get a parameter, default
jmp start
inc dx
strip: inc bx ; find the start of the numbers
dec dx
and dx,dx ; make sure we haven't searched the
; whole command line
je start
cmp BYTE PTR [bx], 30h
jl strip
cmp BYTE PTR [bx], 39h
jg strip
push bx
call getDec ; let's see what we can get
mov cx,ax ; converted number goes into dx
and cx,cx ; make sure we got something
jg start ; we did!
mov cx,05h ; we didn't!
start:
initRegs
; xor ax,ax
; int 10h
push cx
push dx
mov ah, 2ch
int 21h
mov bh, dh ; store starting seconds in bh
pop dx
pop cx
main endp
EnterLoop:
push cx
push dx
mov ah,2ch
int 21h
cmp bh, dh
je pastInc ; time hasn't changed
; backup 5
backup 25
mov bh,dh ; time has changed, store new time
pop dx
pop cx
dec cx ; subtract one from amount of seconds to go
push ax ; save ax
mov ax,OFFSET prompt
push ax
call showStr
pop ax ; restore ax
; print out the number
push bx
lea bx, intStr
push ax
push ax
mov ax, cx
inc ax
push ax
call putDec
call showStr
mov ax,OFFSET blanks
push ax
call showStr
pop bx
jmp keyPress
pastInc:
pop dx
pop cx
keyPress:
mov AH,0Bh ; Check Keyboard Stats
int 21h
cmp al, keyHit ; if there's been a keypress
je EndZero ; Exit with a zero if keypressed
cmp cx, 0
jl EndOne
jmp EnterLoop
EndZero:
; mov ah,00h
; mov al,02h
; int 10h
call _CURON
mov ah,08h ; Read in keyboard
int 21h ; input goes into al, which is error code!
mov AH,4Ch ; Terminate
int 21h ; We're history!
EndOne:
; mov ah,00h
; mov al,02h
; int 10h
call _CURON
mov AH,4Ch ; Terminate
mov AL,01 ; DOS exit code = 1
int 21h ; Cya L8r!
;******************************** PROCEDURES ********************************
showStr proc near ; procedure to display a string
push bp
mov bp,sp ; bp will point to last value of
; the item pushed onto stack
; before procedure call
push ax
push bx
push cx
push dx
mov bx, [bp + 4] ; bx will now point to the string on
; the stack
xor cx,cx ; need to determine length of string
startCount: mov dl,[bx] ; move current character position into
; dl
and dl,dl ; compare dl to zero
je endLoop ; if the zero is found, jump out of the
; loop
inc bx ; not zero, add one to the count
inc cx
jmp startCount ; continue the count!
endLoop: mov dx, [bp + 4] ; bx will now point to the string on
; the stack
mov ah,40h ; print string
mov bx,0001h ; display to the screen
int 21h ; execute the character display int.
pop dx ; reinstate the value of dx from before
; the display procedure
pop cx
pop bx
pop ax
pop bp
ret 2 ; return out of the procedure and kill
; last byte pushed onto stack
showStr endp
getDec proc near ; procedure to get a hex number
; from a string
push bp
mov bp,sp ; bp will point to last value of
; the item pushed onto stack
; before procedure call
push bx
push cx ; we're not going to save ax
push dx ; becuase we're passing back the
; value through it
push si
mov bx, [bp + 4] ; the string
xor ax,ax ; initalize the total
mov si,10 ; make si the base, this could be
; changed to say, 2 if we wanted to
; enter binary numbers
DecLoop: cmp BYTE PTR[bx],30h; make sure it's not too low
jl endDecLoop ; it's too small
cmp BYTE PTR[bx],39h; make sure it's not too big
jg endDecLoop ; it's too large to be decimal
mul si ; multiply everything by 10
mov cl,BYTE PTR[bx]
sub cl,30h ; make it a number 0 - 9
xor ch,ch ; make the ch zero, not used
add ax,cx ; add it to the total
inc bx
jmp DecLoop
endDecLoop:
pop si
pop dx
pop cx
pop bx
pop bp
ret 2 ; return out of the procedure and kill
; last byte pushed onto stack,
; this gets rid of the items passed to
; the procedure
getDec endp
putDec proc near ; procedure to make a string from a
; binary number
push bp
mov bp,sp ; bp will point to last value of
; the item pushed onto stack
; before procedure call
push ax
push bx
push cx
push dx
push di
mov bx, [bp + 6] ; buffer to store value in
mov ax, [bp + 4] ; the VALUE
xor cx,cx ; make cx the counter 0
mov di,0Ah ; make di the base, this could be
; changed to say, 2 if we wanted to
; output binary numbers
xor cx,cx
putLoop: xor dx,dx
div di ; divide everything by 10
add dx,30h ; make it an ASCII 0 - 9
push dx
inc cx
and ax,ax
jne putLoop ; if not all numbers converted yet
makeString: pop dx
mov [bx],dl
inc bx
dec cx
and cx,cx
jne makeString
mov [bx],cl ; terminate the string
pop di
pop dx
pop cx
pop bx
pop ax
pop bp
ret 4
putDec endp
_CURON PROC NEAR ; for small model
PUSH BP ; save stackframe
MOV BP,SP
MOV AH,3 ; get current cursor
XOR BX,BX
INT 10h
AND CH,1fh ; force to ON condition
MOV AH,1 ; set new cursor value
INT 10h
POP BP
RET
_CURON ENDP
_CUROFF PROC NEAR ; for small model
PUSH BP ; save stackframe
MOV BP,SP
MOV AH,3 ; get current cursor
XOR BX,BX
INT 10h
OR CH,20h ; force to OFF condition
MOV AH,1 ; set new cursor values
INT 10h
POP BP
RET
_CUROFF ENDP
END main
END main