; (c) Erdogan TAN 2011
; Doschar, prints character codes via INT 21h Function AH= 7h
; 05/09/2011
		PAGE    60,132



;ÄÄÄÄÄÄÄÄÄÄ CODE_SEG_1  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
CODE_SEG_1	segment para public
		assume  CS:CODE_SEG_1, DS:CODE_SEG_1, SS:CODE_SEG_1, ES:CODE_SEG_1

		org	100h

;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
;±
;±		ENTRY POINT
;±
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±

;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
;±
;±		PROCEDURE proc_start
;±
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±

proc_start	proc	far

start:
                mov     si,offset BossMsg
                call    proc_printmsg
again:
                mov     Byte Ptr [Character],20h
                mov	AH,7
		int	21h			; Character input without echo

                cmp     AL,0h
                jz      pass_enter
                cmp     AL,0Dh
                jz      pass_enter
                mov     Byte Ptr [Character],AL
pass_enter:    
                push    AX
                call    proc_hex
                mov     Word Ptr [Reg_Code],AX
                mov     SI,offset ScancodeMsg
                call    proc_printmsg
                pop     AX
                cmp     AL,0Dh
                jnz     short again
                int     20h

proc_start	endp

;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; From binary (byte) to hexadecimal (character) converter    ;
;                                                            ;
; input -> AL = byte (binary number) to be converted         ;
; output -> AL = First character of hexadecimal number       ;
; output -> AH = Second character of hexadecimal number      ;
;                                                            ;
; (c) Erdogan TAN  1998                                      ;
;............................................................;

proc_hex        proc    near
                mov     ah,al
                and     ah,0Fh
                add     ah,30h
                cmp     ah,39h
                jna     short pass1
                add     ah,07h
pass1:
                shr     al,1
                shr     al,1
                shr     al,1
                shr     al,1
                add     al,30h
                cmp     al,39h
                jna     short pass2
                add     al,07h
pass2:
                retn

proc_hex        endp

proc_printmsg   proc near

loc_print:          
		lodsb				; Load byte at DS:SI to AL
                and     AL,AL            
                je      short loc_return        ; If AL = 00h then retry
		mov	AH,0Eh			
                mov     BX,07h             
		int	10h			; BIOS Service func ( ah ) = 0Eh
						; Write char as TTY
						;AL-char BH-page BL-color
                jmp     short loc_print           
loc_return:
                retn

proc_printmsg   endp

BossMsg:
                db 0Dh,0Ah
                db '[ (c) Erdogan TAN  2011 ]  Press a key to gte char code...'
                db 0Dh,0Ah
                db 0Dh,0Ah,0h
ScancodeMsg:
                db 'Character : '
Character:      db ?
                db '     Code : '
Reg_Code: 	dw ?
                db 'h'
                db 0Dh,0Ah,0h
CODE_SEG_1	ends
		end	start
