📄 rxdosprm.asm
字号:
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Convert AX To 4 Char Decimal ;
;...............................................................;
ConvTo4CharDecimal:
push cx
add di, 4
push di
__4CharDecimal_04:
xor dx, dx
mov cx, 10
div cx
dec di
or dl, '0'
mov byte ptr [ di ], dl
or ax, ax
jnz __4CharDecimal_04
pop di
pop cx
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Format Date String ;
;...............................................................;
formatCurrentDate:
Entry
defbytes _countryInfo, sizeCOUNTRYINFO
push si
push di
mov si, offset RxDOSIntl_DateTemplate
call _CopyString
; eventually, make this international
lea dx, offset [ _countryInfo ][ bp ]
Int21 CountryDependentInfo, 00 ; get country info
Int21 GetDate
pop di
xor ah, ah
mov si, ax
add si, si
add si, ax ; offset to day of week text
add si, offset RxDOSIntl_DayOfWeek
push cx
mov cx, 3
rep movsb ; copy 3 bytes
inc di
mov al, dh ; mon
call ConvTo2CharDecimal
inc di
mov al, dl ; day
call ConvTo2CharDecimal
inc di
pop ax ; year
call ConvTo4CharDecimal
pop si
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Format Time String ;
;...............................................................;
formatCurrentTime:
Entry
defbytes _countryInfo, sizeCOUNTRYINFO
push si
push di
mov si, offset RxDOSIntl_TimeTemplate
call _CopyString
; eventually, make this international
lea dx, offset [ _countryInfo ][ bp ]
Int21 CountryDependentInfo, 00 ; get country info
Int21 GetTime
pop di
mov al, ch ; hours
call ConvTo2CharDecimal
inc di
mov al, cl ; minutes
call ConvTo2CharDecimal
inc di
mov al, dh ; seconds
call ConvTo2CharDecimal
inc di
mov al, dh ; hundreths
call ConvTo2CharDecimal
pop si
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Date [ date ] ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; ss:di Arg Array ;
; ax Number of arguments in array ;
;...............................................................;
_Date:
Entry
def __argarray, di ; args array
defwords _parsedDatePtrs, 3
defbytes _parsedDate, sizeDATE
defbytes _buffer, 128 ; input buffer
defbytes _printbuffer, 128
; call CheckOptOneArg ; see if 1 arg
; ifc _dateInvalid ; if error in args
mov si, word ptr [ di ] ; get first arg
or si, si ; if arg, go parse -->
jnz _date_26
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; display current date
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lea di, offset [ _buffer ][ bp ]
push di ; address of
call formatCurrentDate ; get current date
mov di, offset _ShowCurrentDate
push di
lea di, offset [ _printbuffer ][ bp ]
push di
call _sprintf
add sp, ax ; # args passed
call DisplayLine
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; please enter date
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_date_12:
call DisplayPleaseEnterDate
lea di, offset [ _buffer ][ bp ]
mov byte ptr [ bufMaxLength ][ di ], 128
mov word ptr [ bufActualLength ][ di ], 0
mov dx, di ; where buffer
call _getStdinLine ; read buffer
call CRLF
mov bl, byte ptr [ _buffer. bufActualLength ][ bp ]
and bx, 255
ifz _dateReturn
add bx, bp
mov byte ptr [ _buffer. bufData ][ bx ], 00 ; place a null terminator
lea si, offset [ _buffer. bufData ][ bp ] ; parse text
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; parse arg at [ si ]
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_date_26:
push si ; pointer to start of first arg
lea si, offset [ _parsedDate ][ bp ] ; start of buffer
lea di, offset [ _parsedDatePtrs ][ bp ]
call _GetDateTemplate
pop si
call _GetNumber ; get argument
mov di, word ptr [ _parsedDatePtrs ][ bp ]
mov word ptr ss:[ di ], dx ; store first argument
cmp byte ptr [ si-1 ], '-'
jz _date_28
cmp byte ptr [ si-1 ], '/'
jz _date_28
cmp byte ptr [ si-1 ], '.'
jnz _dateInvalid ; else invalid -->
_date_28:
call _GetNumber ; get argument
mov di, word ptr [ _parsedDatePtrs + 2 ][ bp ]
mov word ptr ss:[ di ], dx ; store second argument
cmp byte ptr [ si-1 ], '-'
jz _date_32
cmp byte ptr [ si-1 ], '/'
jz _date_32
cmp byte ptr [ si-1 ], '.'
jnz _dateInvalid ; else invalid -->
_date_32:
call _GetNumber ; get last argument
mov di, word ptr [ _parsedDatePtrs + 4 ][ bp ]
mov word ptr ss:[ di ], dx ; store third argument
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; parse Year
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov ax, word ptr [ _parsedDate. _YEAR ][ bp ] ; start of buffer
cmp ax, 1980 ; greater than 1980 ?
jnc _date_42 ; valid -->
cmp ax, 80 ; less than 80 ?
jnc _date_36 ;
add ax, 2000 ; must be between 2000 - 2099
_date_36:
cmp ax, 100 ; between 80 and 100 ?
jnc _date_38 ; no -->
add ax, 1900
_date_38:
cmp ax, 1980
jc _dateInvalid ; if invalid -->
cmp ax, 2100
jnc _dateInvalid ; if invalid -->
_date_42:
mov cx, ax ; year
mov dh, byte ptr [ _parsedDate. _MONTH ][ bp ] ; month
mov dl, byte ptr [ _parsedDate. _DAY ][ bp ] ; day
Int21 SetDate
or al, al ; date valid ?
jnz _dateInvalid ; no -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_dateReturn:
Return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; invalid date
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_dateInvalid:
mov dx, offset CmndError_InvalidDate
call DisplayLine
jmp _date_12
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Prompt ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; ss:di Arg Array ;
; ax Number of arguments in array ;
;...............................................................;
_Prompt:
mov si, word ptr [ di ] ; get pointer to arg
or si, si
jnz _prompt_08
mov si, offset RxDOS_DefaultPrompt
_prompt_08:
mov di, offset RxDOS_Prompt
call _CopyString
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; insert prompt=
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov si, offset RxDOS_PromptSpec ; locate PROMPT=
call searchEnvVariable ; env variable located ?
jnz _prompt_12 ; if no arg located -->
call deleteEnvVariable
_prompt_12:
mov si, offset RxDOS_PromptSpec ; insert PROMPT=
call insertEnvVariable
call DisplayOutEnvSpace ; if error, display message
jc _prompt_18 ; if error -->
mov si, offset RxDOS_Prompt
call insertEnvVariable
call DisplayOutEnvSpace ; if error, display message
_prompt_18:
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Time [ time ] ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Usage: ;
; ss:di Arg Array ;
; ax Number of arguments in array ;
;...............................................................;
_Time:
Entry
def __argarray, di ; args array
defbytes _parsedTime, sizeTIME ; time struc
defbytes _buffer, 128 ; input buffer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -