
code            segment byte public
                assume  cs:code, ds:code
		org	100h
com             proc    far

start:          jmp     main
include         toolbox.asm
                _compile
flags           dw 0
flag2           dw 0
temp            dw 0
ascii           db 0
scan            dw 0
scan2           dw 0
ctrlalt         db 'CTRL ALT PRESSED',0ffh,0
main:

ctrl            equ  0100b                        ;bit map for ctrl key
alt             equ  1000b                        ;bit map for alt key

in_key:
                mov ah, 2    ; keyboard flags
                int 16h
                xor ah, ah
                mov flags, ax
                cmp ax, flag2   ; same as before?
                jne nflag
                mov ah, 1
                int 16h
                jnz showcode

nflag:
                mov flag2, ax
                and al, ctrl+alt                  ;clear non relevant bits
                cmp al, ctrl+alt                  ;compare to our map
                jne go_ahead                     ;NO CTRL+ALT keys pressed
                _print ctrlalt, 1
              ; call putbin
              ; _newline
go_ahead:
                jmp in_key
showcode:
                call readkey
                mov  temp, ax
                xor  ah, ah
                mov  ascii, al
                mov  ax, temp
                xchg ah, al     ; scancode in AL
                xor  ah, ah
                mov  scan, ax
                cmp  ax, scan2
                je   exit       ; stop on double key
                mov  scan2, ax
                mov  ax, scan
                call putnum
                _echo ' '
                mov  ax, scan
                call put_hex
                _echo 'h'
                _echo ','
                _echo ' '
                xor ax, ax
                mov  al, ascii
                call putnum
                _echo ' '
                mov  al, ascii
                call put_hex
                _echo 'h'
                _echo ' '
                _newline
                jmp  in_key

exit:           call dosexit
                int 20h      

com             endp

code            ends

ProgramEnd      EQU $-01h

		end	start
