- MLENGTH=128
- ;
- DSEG SEGMENT
- BUFF DB MLENGTH
- DB ?
- DB MLENGTH DUP (?)
- MESS0 DB 'Please input: $'
- MESS1 DB 'Length = $'
- MESS2 DB 'X = $'
- MESS3 DB 'Y = $'
- DSEG ENDS
- ;
- CSEG SEGMENT
- assume cs:CSEG, ds:DSEG
- START: MOV AX,DSEG
- MOV DS,AX
- MOV DX,OFFSET MESS0
- CALL DISPMESS
- MOV DX,OFFSET BUFF
- MOV AH,10
- INT 21H
- CALL NEWLINE
- MOV BH,0
- MOV BL,0
- MOV CL,BUFF+1
- MOV CH,0
- JCXZ COK
- MOV SI,OFFSET BUFF+2
- AGAIN: MOV AL,[SI]
- INC SI
- CMP AL,'0'
- JB NEXT
- CMP AL,'9'
- JA NODEC
- INC BH
- JMP SHORT NEXT
- NODEC: OR AL,20H
- CMP AL,'a'
- JB NEXT
- CMP AL,'z'
- JA NEXT
- INC BL
- NEXT: LOOP AGAIN
- ;
- COK: MOV DX,OFFSET MESS1
- CALL DISPMESS
- MOV AL,BUFF+1
- XOR AH,AH
- CALL DISPAL
- CALL NEWLINE
- ;
- MOV DX,OFFSET MESS2
- CALL DISPMESS
- MOV AL,BH
- XOR AH,AH
- CALL DISPAL
- CALL NEWLINE
- ;
- MOV DX,OFFSET MESS3
- CALL DISPMESS
- MOV AL,BL
- XOR AH,AH
- CALL DISPAL
- CALL NEWLINE
- ;
- MOV AX,4C00H
- INT 21H
- ;
- DISPAL PROC
- MOV CX,3
- MOV DL,1010B
- DISP1: DIV DL
- XCHG AH,AL
- ADD AL,'0'
- PUSH AX
- XCHG AH,AL
- MOV AH,0
- LOOP DISP1
- MOV CX,3
- DISP2: POP DX
- CALL ECHOCH
- LOOP DISP2
- RET
- DISPAL ENDP
- ;
- DISPMESS PROC
- MOV AH,9
- INT 21H
- RET
- DISPMESS ENDP
- ;
- ECHOCH PROC
- MOV AH,2
- INT 21H
- RET
- ECHOCH ENDP
- ;
- NEWLINE PROC
- PUSH AX
- PUSH DX
- MOV DL,0DH
- MOV AH,2
- INT 21H
- MOV DL,0AH
- MOV AH,2
- INT 21H
- POP DX
- POP AX
- RET
- NEWLINE ENDP
- CSEG ENDS
- END START