Category : Utilities for DOS and Windows Machines
Archive   : ARP.ZIP
Filename : ARP02.ASM

 
Output of file : ARP02.ASM contained in archive : ARP.ZIP

page ,132
title Another Raw Program - v1.02 - (or ARP for short)

;------------------------------------------------------------------------
;
; Another Raw Program - Bill Gibson
; Lathrup Village, Mi
;
; Ver. 1.00 - Initial version, very primitive. - (not rlsed)
;
; Ver. 1.01 - Parameter comparisons from the PSP @ 5Dh - 12/22/86
; - code efficiencies - 12/27/86
;
; * Ver. 1.02 - Table driven comparisons from the PSP @ 5Dh - 12/22/86
; - code efficiencies - 12/27/86
;
; Ver. 1.03 - Table driven comparisons from the PSP @ 80h - 01/02/87
;
; The idea came from Chris Dunford's program called RAW.ARC.
; One major point, this program does not include the
; support for PCED that is incorporated into the original RAW program.
;
;
; For Public Domain Use
;
;------------------------------------------------------------------------
COMMENT *

Routine to turn DOS's RAW mode
on or off.

Usage:
ARP [on | off] -> toggle between modes
ARP -> current mode status
ARP ? -> program info
*

;------------------------------------------------------------------------
; Equates
;------------------------------------------------------------------------
blank EQU 20h ;ascii space code
cr EQU 0Dh ;carriage return
lf EQU 0Ah ;line feed

;------------------------------------------------------------------------
; Macros
;------------------------------------------------------------------------
@write MACRO text?
LOCAL around,msg
JMP SHORT around
msg DB text?
around:
MOV DX,OFFSET msg
MOV CX,around-msg
MOV BX,1
MOV AH,40h
INT 21h
ENDM

;------------------------------------------------------------------------
code SEGMENT
ASSUME CS:code,DS:code

ORG 5Dh
buffer LABEL BYTE ;buffer
buffer_len EQU $-buffer ;buffer length

ORG 100h
start:
JMP SHORT begin
DB 'ARP, 12.27.86 v1.02.1 by Bill Gibson'
begin:
CALL chk_ver
CALL scan
CALL decode
JNC b_1
CALL help_cmd
b_1:
CALL done

;--------------------------------------------------------------------------
; Sub-Routines:
; chk_ver - verify DOS 2.0 or later
; cur_mode - test for current raw mode
; decode - decode cmdline against table of commands
; done - exit with return code of zero
; help_cmd - program information
; scan - check for blank
; turn_on_cmd - turn raw mode ON
; turn_off_cmd - turn raw mode OFF
;--------------------------------------------------------------------------
chk_ver PROC
MOV AH,30h ;verify DOS 2.0 or later
INT 21h
CMP AL,2
JAE SHORT chk_ok
MOV DX,OFFSET v_msg
MOV AH,9 ;use old MS-DOS string output
INT 21h ;function
MOV AH,0 ;exit via function 0
INT 21h
chk_ok:
RET
chk_ver ENDP

;--------------

scan PROC ;check for parameter @ 5Dh
MOV AL,[buffer]
CMP AL,blank ;anything ?
JZ s_1 ;test if raw on/off
RET
s_1:
CALL cur_mode
CALL done
scan ENDP

;--------------

decode PROC
MOV SI,OFFSET cmd_table ;decode input against
d_1: ;the cmd_table
CMP BYTE PTR [SI],0 ;is command table exhausted
JE d_7 ;jump end of table found
MOV DI,OFFSET buffer ;no, DI = addr of input
d_2:
CMP BYTE PTR [DI],blank ;scan off leading blanks
JNE d_3
INC DI
JMP d_2
d_3:
MOV AL,[SI] ;get next cmd char
OR AL,AL ;check if end of string
JZ d_4 ;jump. entire string matched
CMP AL,[DI] ;compare to next char
JNZ d_6 ;jump. found mismatch
INC SI ;go to next char string
INC DI
JMP d_3
d_4:
CMP BYTE PTR [DI],cr ;ensure same length
JE d_5 ;next char
CMP BYTE PTR [DI],blank ;must be blank or cr
JNE d_6
d_5:
CALL WORD PTR [SI+1] ;run the command
CLC ;then return carry flag=false
RET ;as successful flag
d_6:
LODSB ;look for this command string
OR AL,AL
JNZ d_6 ;not end yet, loop
ADD SI,2 ;skip over cmd routine offset
JMP d_1 ;try to match next cmd
d_7:
STC ;no match on cmd, exit.
RET ;with carry flag=true
decode ENDP

;--------------

cur_mode PROC
MOV AX,4400h ;"device information", using
INT 21h ;handle for standard output
TEST DL,20h ;is raw on or off ?
JNZ SHORT raw_on
@write <'Raw Mode is OFF - Use ARP ? for more info',cr,lf>
JMP SHORT finsh
raw_on:
@write <'Raw Mode is ON - Use ARP ? for more info',cr,lf>
finsh:
RET
cur_mode ENDP

;--------------

help_cmd PROC
MOV DX,OFFSET h_msg
MOV CX,OFFSET h_msg_len-OFFSET h_msg
MOV BX,1
MOV AH,40h
INT 21h
RET
help_cmd ENDP

;--------------

turn_on_cmd PROC
MOV AX,4400h ;get current device info
MOV BX,1 ;std output
INT 21h
MOV DH,0 ;force DH=0
OR DL,20h ;set raw mode bit for ON
MOV AX,4401h ;set current information
INT 21h
@write <'Raw Mode has been turned ON',cr,lf>
RET
turn_on_cmd ENDP

;--------------

turn_off_cmd PROC
MOV AX,4400h ;get current device info
MOV BX,1 ;std output
INT 21h
AND DL,0DFh ;set raw mode bit for OFF
XOR DH,DH ;force DH=0
MOV AX,4401h ;set current information
INT 21h
@write <'Raw Mode has been turned OFF',cr,lf>
RET
turn_off_cmd ENDP

;--------------

done PROC
MOV AX,4C00h ;DOS terminate function
INT 21h ;with return code of zero
done ENDP

;---------------------------------------------------------------------
; data definitions
;---------------------------------------------------------------------
cmd_table EQU $
DB '?',0
DW help_cmd
DB 'ON',0
DW turn_on_cmd
DB 'OFF',0
DW turn_off_cmd
DB 0


h_msg DB cr,lf,'Another Raw Program v1.02 - WDG 1986'
DB cr,lf
DB cr,lf,' Usage: ARP [on | off]'
DB cr,lf
DB cr,lf,'No parameters displays current RAW mode'
DB cr,lf
h_msg_len LABEL BYTE


v_msg DB cr,lf,'Incorrect DOS version, use DOS 2.0 or greater'
DB cr,lf


code ENDS
END start