; (c) Erdogan TAN 1998
; Scancode, prints character codes
; 1/2/1998 
		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,10h
		int	16h			; BIOS Service func ( ah ) = 10h
						; Keyboard service
                push    AX
                cmp     AL,0h
                jz      pass_enter
                cmp     AL,0Dh
                jz      pass_enter
                mov     Byte Ptr [Character],AL
pass_enter:    
                mov     AL,AH
                call    proc_hex
                mov     Word Ptr [Reg_ScanCode],AX
                pop     AX
                push    AX
                call    proc_hex
                mov     Word Ptr [Reg_AsciiCode],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  1998 ]  Press a key to scan code...'
                db 0Dh,0Ah
                db 0Dh,0Ah,0h
ScancodeMsg:
                db 'Character : '
Character:      db ?
                db '     Scan Code : '
Reg_ScanCode:   dw ?
                db 'h'
                db '     ASCII Code : '
Reg_AsciiCode:  dw ?
                db 'h'
                db 0Dh,0Ah,0h
CODE_SEG_1	ends
		end	start