Comment | Common included routines for YYYYMMD, YYMMD and HHMM | ; end of comment ;============================================================== SaySep proc near ; displays / on screen using BIOS push dx lea dx,Separator mov AH,09h int 21h pop dx ret SaySep endp ;============================================================== SayNDigits proc NEAR ; call with unsigned number in AX, CX counts how many digits you want ; converts it to ASCII and displays it on the screen ; leading 0's are NOT suppressed. ; Field is exactly wide enough to hold the number. ; No leading or trailing spaces. DISPLAYED IN DECIMAL ; ; Method is to repeatedly divide by 10. The remainder at ; each stage is one digit of the result, working right to left. ; Preserves all registers Data segment PAD db 15 dup (0) ; where build the output string PADend db '$' ; terminator for Say Data ends push ax push bx push cx push dx push di ; preserve di mov bx,10d lea di,padEnd ; point at $ trailing the PAD ; work right to left building digits at PAD ; CX counts number of digits NumLoop: ; loop once for each digit ; number so far is in dx:ax mov bx,10 sub dx,dx ; clear out high order part of DX:AX div bx ; dx=remdr ax=quot add dl,'0' ; convert digit to ASCII dec di ; work right to left mov [di],dl ; save digit loop NumLoop mov dx,di ; start of ascii string, terminated by $ mov AH,09h ; BIOS put string terminated by $ int 21h pop di ; restore caller's registers pop dx pop cx pop bx pop ax ret SayNDigits endp ;============================================ ; Scan the command line for a separator char, default /, e.g. /, n=none. GetSep proc near ; counted string at HEX 80 ; contains command line. ; It has no trailing null. ; String we want may be ; preceded and followed by ; unwanted spaces. mov BX,81h ; start of string xor CH,CH mov CL,DS:80h ; length of string call MLEADING ; get rid of leading blanks jcxz useDef ; jump if command line empty, leave default / mov al, byte ptr DS:[bx] cmp al,'n' ; check for N, none None je none cmp al,'N' je none cmp al,'s' je space cmp al,'S' je space mov Separator,al ; use whatever char provided. ret space: mov Separator,' ' ; space ret none: mov Separator,'$' ; end of string char useDef: ret GetSep endp ;============================================================== ; REMOVE LEADING BLANKS FROM A STRING MLeading proc near ; on entry BX is addr of string, CX its length. ; Trims off any leading blanks, leaving result in BX CX ; Length may also be 0 or 1, but not -ve ; If the entire string is blank the result is the null string mov DI,BX mov AL,20h ; AL = blank -- the search char jcxz MLEADING2 ; jump if null string repe SCASB ; scan ES:DI forwards till hit non blank ; DI points just after it (wrap ok) ; CX is one too small, or 0 if none found je MLEADING1 ; jump if entire string was blank inc CX ; CX is length of remainder of string MLEADING1: dec DI ; DI points to non-blank MLEADING2: mov BX,DI ; put address back ret MLeading endp ;============================================