CODE SEGMENT
    ASSUME CS:CODE, DS:CODE, ES:CODE, SS:CODE
    ORG 81H
CmdLine:
    ORG 100H
START:
    XOR AX, AX
    MOV DX, AX
    MOV BX, OFFSET CmdLine
SkipSpace:
    MOV DL, [BX]
    INC BX
    CMP DL, ' '
    JE SkipSpace
    CMP DL, '0'
    JNE GetValue
    XOR AX, AX
    JMP SHORT NotDefault
GetValue:
    CMP DL, '0'
    JB CheckValue
    CMP DL, '9'
    JA CheckValue
    SUB DL, '0'
    SHL AX, 1
    MOV CX, AX
    SHL CX, 1
    SHL CX, 1
    ADD AX, CX
    ADD AX, DX
    MOV DL, [BX]
    INC BX
    JMP SHORT GetValue
CheckValue:
    OR AX, AX
    JNZ NotDefault
    MOV AL, 4
NotDefault:
    MOV COUNT, AX
ReadChar:
    MOV AH, 6
    MOV DL, 0FFH
    INT 21H
    OR AL, AL
    JZ EndProc
    MOV DL, AL
    MOV AH, 2
    CMP DL, 9
    JNZ NotTab
    MOV DL, ' '
    MOV CX, COUNT
DispSpace:
    OR CX, CX
    JZ ReadChar
    INT 21H
    DEC CX
JMP SHORT DispSpace
NotTab:
    INT 21H
    JMP SHORT ReadChar
EndProc:
    MOV AH, 4CH
    INT 21H
COUNT DW ?
CODE ENDS
    END START
