home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
batch
/
library
/
batutl2
/
send.asm
< prev
next >
Wrap
Assembly Source File
|
1988-04-20
|
8KB
|
357 lines
TITLE SEND 1-2-86 [4-16-88]
;Toad Hall Disassembly, tweak
LF EQU 0AH
CR EQU 0DH
;
;INITIAL VALUES : CS:IP 0000:0100
; SS:SP 0000:FFFF
CodeSeg SEGMENT
ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
ORG 100H
SEND proc near
JMP SHORT Start
wkday_array DB 'Sun',0,'Mon',0,'Tue',0,'Wed',0,'Thu',0,'Fri',0,'Sat',0
wconst_0A dw 0AH ;a constant
wconst_64 dw 64H ;a constant
Start: MOV DI,81H ;PSP cmd line
MOV BL,[DI-1] ;snarf cmd line length byte
xor bh,bh ;clear msb
mov byte ptr [bx+di],0 ;stuff AsciiZ 0 in cmd line
Lup130: CALL Get_CmdLine_Char
JZ Exit_140 ;0 means done
CMP AL,' ' ;space?
JZ Lup130 ; yep, gobble spaces
CMP AL,9 ;tab?
JZ Lup130 ; yep, gobble them too
JMP SHORT Process_Char_147 ;something else, go process it
Exit_140:
INT 20H ;back to DOS, wherever
Send endp
Lup142 proc near
CALL Get_CmdLine_Char ;get next cmd line char
JZ Exit_140 ;0 means done
Process_Char_147:
CMP AL,'^' ;ctrl char?
JNZ Not_Ctrl ; nope
CALL Get_CmdLine_Char ; yep, get Ctrl char
JNZ Make_Ctrl ;wasn't 0, go process it
MOV AL,'^' ; hmmm, display actual caret
Endit_152:
CALL CharOut ;display the char
INT 20H ;terminate
Make_Ctrl:
AND AL,1FH ;de-Asciify it
Disp159:CALL CharOut
JMP SHORT Lup142
Not_Ctrl:
CMP AL,'$' ;dollar sign?
JNZ Disp159 ;nope, display it, reloop
CALL L0167 ;process rest of cmd line
JMP SHORT Lup142
Lup142 endp
L0167 proc near
CALL Get_CmdLine_Char ;get next cmd line char
JNZ L0170 ; got one
MOV AL,'$'
JMP SHORT Endit_152 ;display, terminate
L0170: CMP AL,'t' ;wants time?
JNZ L019C ; nope
MOV AH,2CH ;get DOS system time
INT 21H
MOV AL,CH ;display hours
CALL Show_space_byte ;space-padded
MOV AL,':' ;display colon after hours
CALL CharOut
MOV AL,CL ;display minutes
CALL Show_zero_byte ;0-padded
MOV AL,':' ;display colon after minutes
CALL CharOut
MOV AL,DH ;display seconds
CALL Show_zero_byte ;0-padded
MOV AL,'.' ;display decimal after seconds
CALL CharOut
MOV AL,DL ;display deciseconds
CALL Show_zero_byte ;0-padded
RET
L019C: CMP AL,'d' ;wants weekday name?
JNZ L01D1 ; nope
MOV AH,2AH ;get DOS system date
INT 21H ;day of week returned in AL
xor ah,ah ;clear msb
MOV SI,OFFSET wkday_array ;weekday array base
ADD AX,AX ;*2
ADD AX,AX ;*4
ADD SI,AX ;add to offset
CALL StrOut_2E1 ;display AsciiZ string
MOV AL,' ' ;display space
CALL CharOut
MOV AL,DH ;display month
CALL Show_space_byte ;space-padded
MOV AL,'-' ;display dash
CALL CharOut
MOV AL,DL ;display day
CALL Show_zero_byte ;0-padded
MOV AL,'-' ;display dash
CALL CharOut
MOV AX,CX ;show year as integer
CALL Show_word
RET
L01D1: CMP AL,'p' ;wants directory name?
JNZ L01D9 ; nope
CALL Show_DirName_2A3 ;show directory name
RET
L01D9: CMP AL,'P' ;want directory name?
JNZ L01EA ; nope
CALL Show_DirName_2A3 ;show directory name
or al,al ;?
JZ L01E9 ; just return
MOV AL,'\' ;backslash after subdir name
CALL CharOut
L01E9: RET
L01EA: CMP AL,'v' ;wants version nr?
JNZ L0206 ; nope
MOV AH,30H ;Get DOS version nr
INT 21H
PUSH AX ;save version
xor ah,ah ;clear msb, lsb is major version
CALL Show_word
MOV AL,'.' ;display period
CALL CharOut
POP AX ;restore version
MOV AL,AH ;lsb is minor version
xor ah,ah ;clear msb
CALL Show_word ;show as integer
RET
L0206: CMP AL,'n' ;wants current drive?
JNZ L020E ; nope
CALL Show_Drive ;show current drive
RET
L020E: CMP AL,'g' ;wants greater than?
JNZ L0218 ; nope
MOV AL,'>' ;display > char
CALL CharOut
RET
L0218: CMP AL,'l' ;wants less than?
JNZ L0222 ; nope
MOV AL,'<' ;display < char
CALL CharOut
RET
L0222: CMP AL,'b' ;wants vertical bar?
JNZ L022C ; nope
MOV AL,7CH ;display '|' char
CALL CharOut
RET
L022C: CMP AL,'q' ;?
JNZ L0236 ; nope
MOV AL,'=' ;display equal sign
CALL CharOut
RET
L0236: CMP AL,'h' ;wants backspace?
JNZ L0240 ; nope
MOV AL,8 ;display backspace char
CALL CharOut
RET
L0240: CMP AL,'e' ;wants Escape char?
JNZ L024A ; nope
MOV AL,1BH ;display Esc char
CALL CharOut
RET
L024A: CMP AL,'_' ;wants new line?
JNZ L0259 ; nope
MOV AL,CR ;display Cr
CALL CharOut
MOV AL,LF ; .. and LF
CALL CharOut
RET
L0259: CMP AL,'M' ;wants Month?
JNZ L0267 ; nope
MOV AH,2AH ;get date
INT 21H
MOV AL,DH ;month into AL
CALL Show_zero_byte
RET
L0267: CMP AL,'D' ;wants Day?
JNZ L0275 ; nope
MOV AH,2AH ;get date
INT 21H
MOV AL,DL ;day into AL
CALL Show_zero_byte
RET
L0275: CMP AL,'Y' ;wants Year?
JNZ L028C ; nope
MOV AH,2AH ;get date
INT 21H
MOV AX,CX ;year into AX
xor dx,dx ;clear remainder
DIV WORD PTR wconst_64 ;constant / 64H
MOV AX,DX ;show remainder
CALL Show_zero_byte ;0-padded
RET
L028C: CMP AL,'T'
JNZ L029F
MOV AH,2CH ;get time
INT 21H
MOV AL,CH ;display hours
CALL Show_zero_byte ;0-padded
MOV AL,CL ;display minutes
CALL Show_zero_byte ;0-padded
RET
L029F: CALL CharOut ;just show the char
RET
L0167 endp
Show_DirName_2A3 proc near
CALL Show_Drive ;display current drive char
MOV AL,':' ;display colon
CALL CharOut
MOV AL,'\' ;and subdir backslash
CALL CharOut
MOV AH,47H ;get current directory
xor dl,dl ;drive ID (current drive)
;use our stack to provide room for the directory name
; SUB SP,41H ;back down the stack a bit
MOV SI,SP ;pointer to AsciiZ string
sub si,41H ;back down the stack a little
INT 21H
CALL StrOut_2E1 ;display directory name
MOV AL,[SI] ;snarf first char again
; ADD SP,41H ;correct SP
RET
Show_DirName_2A3 endp
Show_Drive proc near
MOV AH,19H ;report current drive
INT 21H
ADD AL,41H ;asciify
CALL CharOut ;display drive char
RET
Show_Drive endp
Get_CmdLine_Char proc near
MOV AL,[DI] ;snarf cmd line char
; OR AL,AL ;terminating zero? (set ZFlag)
; JZ L02D5 ; yep
INC DI ; bump cmd line ptr
or al,al ;set Zflag in case of terminating 0
L02D5: RET
Get_CmdLine_Char endp
CharOut proc near
PUSH AX
PUSH DX
MOV DL,AL ;need char in DL
MOV AH,2 ;display output
INT 21H
POP DX
POP AX
RET
CharOut endp
StrOut_2E1 proc near
PUSH SI ;preserve text pointer
Lup2E2: MOV AL,[SI] ;snarf text byte
or al,al ;zero means done
JZ L02EE ;done
CALL CharOut ;display char
INC SI ;bump text ptr
JMP SHORT Lup2E2
L02EE: POP SI ;restore text pointer
RET
StrOut_2E1 endp
Show_word proc near
or ax,ax ;value = 0?
JNZ Check_10 ; nope
CALL Show_Digit ;just show a '0'
RET
Check_10:
CMP AX,wconst_0A ;< 10?
JNB L0307 ; nope
Show_Digit:
PUSH AX ;save value
ADD AL,30H ;asciify decimal digit
CALL CharOut ;display
POP AX ;restore value
RET
L0307: PUSH DX ;save dx
xor dx,dx ;clear remainder
DIV WORD PTR wconst_0A
PUSH DX ;save remainder
CALL Check_10 ;show 10's digit if any
POP AX ;restore remainder
CALL Show_Digit ;show 1's digit
POP DX
RET
Show_word endp
;Display byte in AL, with leading 0 if < 10
Show_zero_byte proc near
MOV BL,'0' ;lead with '0' if < 10
JMP SHORT L0320 ;skip
Show_zero_byte endp
;display byte with leading space if < 10
Show_space_byte proc near
MOV BL,' ' ;lead with space if < 10
L0320:
xor ah,ah ;clear msb
DIV BYTE PTR wconst_0A ;/ 10
CMP AL,0 ;remainder?
JG L0332 ; yep
MOV AL,BL ;display '0' or ' '
CALL CharOut
JMP SHORT L0335 ;display 1's, return
L0332: CALL Show_Digit ;show 10's digit
L0335: MOV AL,AH ;show 1's digit
CALL Show_Digit
RET
Show_space_byte endp
CodeSeg ENDS
END SEND