use32
        ORG   0x200000          ; where our program is loaded to
        jmp   start             ; jump to the start of program.
        db    'DEX1'            ; We check for this, to make shore it a valid Dex4u file.

 ;----------------------------------------------------;
 ; Start of program.                                  ;
 ;----------------------------------------------------;

start:
        mov   ax,18h            ; set ax to nonlinear base
        mov   ds,ax             ; add them to ds
        mov   es,ax             ; and es.

 ;----------------------------------------------------;
 ; Get calltable address.                             ;
 ;----------------------------------------------------;

        mov   edi,Functions     ; this is the interrupt
        mov   al,0              ; we use to load the DexFunction.inc
        mov   ah,0x0a           ; with the address to dex4u functions.
        int   40h 

 ;----------------------------------------------------;
 ; print string.                                      ;
 ;----------------------------------------------------;

        mov   esi,WaitMessage
        call  [PrintString]     ; this call the print function.
 ;----------------------------------------------------;
 ; start the IR stuff.                                ;
 ;----------------------------------------------------;
        call  ComPort
 ;----------------------------------------------------;
 ; AsciiKeys.                                         ;
 ;----------------------------------------------------;
GetAnotherChar:
        call  GetKey
 ;----------------------------------------------------;
 ; Esc pressed ?.                                     ;
 ;----------------------------------------------------;                           
        cmp   [AsciiKey],27 
        je    Exit
 ;----------------------------------------------------;
 ; 1 pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x31
        jne   AscKey1
        call  Port1
        call  ComPort
        jmp   GetAnotherChar
AscKey1:
 ;----------------------------------------------------;
 ; 2 pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x32
        jne   AscKey2
        call  Port2
        call  ComPort
        jmp   GetAnotherChar
AscKey2:
 ;----------------------------------------------------;
 ; 3 pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x33
        jne   AscKey3
        call  Port3
        call  ComPort
        jmp   GetAnotherChar
AscKey3:
 ;----------------------------------------------------;
 ; 4 pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x34
        jne   AscKey4
        call  Port4
        call  ComPort
        jmp   GetAnotherChar
AscKey4:
 ;----------------------------------------------------;
 ; a pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x61
        jne   AscKey5
        mov   esi,Apacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey5:
 ;----------------------------------------------------;
 ; A pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x41
        jne   AscKey6
        mov   esi,Apacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey6:
 ;----------------------------------------------------;
 ; b pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x62
        jne   AscKey7
        mov   esi,Bpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey7:
 ;----------------------------------------------------;
 ; B pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x42
        jne   AscKey8
        mov   esi,Bpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey8:
 ;----------------------------------------------------;
 ; c pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x63
        jne   AscKey9
        mov   esi,Cpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey9:
 ;----------------------------------------------------;
 ; C pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x43
        jne   AscKey10
        mov   esi,Cpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey10:
 ;----------------------------------------------------;
 ; d pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x64
        jne   AscKey11
        mov   esi,Dpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey11:
 ;----------------------------------------------------;
 ; D pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x44
        jne   AscKey12
        mov   esi,Dpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey12:
 ;----------------------------------------------------;
 ; e pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x65
        jne   AscKey13
        mov   esi,Epacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey13:
 ;----------------------------------------------------;
 ; E pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x45
        jne   AscKey14
        mov   esi,Epacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey14:
 ;----------------------------------------------------;
 ; f pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x66
        jne   AscKey15
        mov   esi,Fpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey15:
 ;----------------------------------------------------;
 ; F pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x46
        jne   AscKey16
        mov   esi,Fpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey16:
 ;----------------------------------------------------;
 ; g pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x67
        jne   AscKey17
        mov   esi,Gpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey17:
 ;----------------------------------------------------;
 ; G pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x47
        jne   AscKey18
        mov   esi,Gpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey18:
 ;----------------------------------------------------;
 ; h pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x68
        jne   AscKey19
        mov   esi,Hpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey19:
 ;----------------------------------------------------;
 ; H pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x48
        jne   AscKey20
        mov   esi,Hpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey20:
 ;----------------------------------------------------;
 ; i pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x69
        jne   AscKey21
        mov   esi,Ipacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey21:
 ;----------------------------------------------------;
 ; I pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x49
        jne   AscKey22
        mov   esi,Ipacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey22:
 ;----------------------------------------------------;
 ; j pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x6a
        jne   AscKey23
        mov   esi,Jpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey23:
 ;----------------------------------------------------;
 ; J pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x4a
        jne   AscKey24
        mov   esi,Jpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey24:
 ;----------------------------------------------------;
 ; k pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x6b
        jne   AscKey25
        mov   esi,Kpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey25:
 ;----------------------------------------------------;
 ; K pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x4b
        jne   AscKey26
        mov   esi,Kpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey26:
 ;----------------------------------------------------;
 ; l pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x6c
        jne   AscKey27
        mov   esi,Lpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey27:
 ;----------------------------------------------------;
 ; L pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x4c
        jne   AscKey28
        mov   esi,Lpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey28:
 ;----------------------------------------------------;
 ; m pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x6d
        jne   AscKey29
        mov   esi,Mpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey29:
 ;----------------------------------------------------;
 ; M pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x4d
        jne   AscKey30
        mov   esi,Mpacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey30:
 ;----------------------------------------------------;
 ; n pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x6e
        jne   AscKey31
        mov   esi,Npacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey31:
 ;----------------------------------------------------;
 ; N pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x4e
        jne   AscKey32
        mov   esi,Npacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey32:
 ;----------------------------------------------------;
 ; o pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x6f
        jne   AscKey33
        mov   esi,Opacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey33:
 ;----------------------------------------------------;
 ; O pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x4f
        jne   AscKey34
        mov   esi,Opacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey34:
 ;----------------------------------------------------;
 ; p pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x70
        jne   AscKey35
        mov   esi,Ppacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey35:
 ;----------------------------------------------------;
 ; P pressed ?.                                       ;
 ;----------------------------------------------------;
        cmp   [AsciiKey],0x50
        jne   AscKey36
        mov   esi,Ppacket
        call  SendPacket
        jmp   GetAnotherChar
AscKey36:
        jmp   GetAnotherChar
 ;----------------------------------------------------;
 ; Exit back to CLI.                                  ;
 ;----------------------------------------------------;
Exit:
        ret
 ;----------------------------------------------------;
 ; Data.                                              ;
 ;----------------------------------------------------;
WaitMessage: DB '    Dex4u Furby prog test, Press a key from A-P ',13,0
Port   dw  0x03e8
include 'IR.inc'
include 'DexFunctions.inc'