flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Two scancodes being sent after keypress?

Author
Thread Post new topic Reply to topic
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
I have my interrupts working in my 32-bit OS, however is it normal for two scancodes to be sent from the keyboard? The first one is the key I pressed, but the second one seems to be a random byte value.

If I type in "HELLO WORLD" it will come out like this:

"H ErLnLnO dWrOdRjL D"
as an example.

Here's code:

os1.asm
Code:
org 7C00h

BootStart:
xor ax, ax
mov ds, ax
mov ss, ax
mov sp, 9C00h

; Set up VESA text mode 10Ch (132x60)
mov ax, 4F02h
mov bx, 10Ch
int 10h

mov ax, 0060h
mov es, ax
xor bx, bx
mov ah, 02h
mov al, 0Ah
mov cl, 02h
mov ch, 00h
mov dh, 00h
int 13h
jmp 0000h:0600h

times 510-($-$$) db 0
dw 0AA55h

org 0600h
Begin:
;push cs
;push cs
;pop ds
;pop ss
mov ax, 0
mov ds, ax
mov ss, ax

; Used for testing.
;pop cs
;pop ax
;mov bx, 0B800h
;mov es, bx
;xor bx, bx
;sub al, '0'
;mov [es:bx], al

; Enables A20 line
;call EnableA20

jmp Start

; Data Goes Here
  WelcomeStr db "Welcome to TR2-DOS!",0

  gdt:
  db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; NULL SEGMENT
  db 0FFh, 0FFh, 00h, 00h, 00h, 10011010b, 11001111b, 00h ; CODE SEGMENT
  db 0FFh, 0FFh, 00h, 00h, 00h, 10010010b, 11001111b, 00h ; DATA SEGMENT
  gdt_end:

  ;Global Descriptor Table Descriptor is set up as follows:
  ; -------------------------
  ;| DESCRIPTION  |  SIZE    |
  ;|------------------------ |
  ;| SIZE         |  WORD    |
  ;| TABLE        |  DWORD   |
  ; -------------------------
  gdt_desc: dw gdt_end - gdt - 1
            dd gdt
; Data Ends Here

Start:

; Clear interrupts for move to 32-bit mode
cli

;Load Global Descriptor Table (GDT) Register
lgdt [gdt_desc]

;Set up control register to get into Protected Mode
mov eax, cr0
or al, 1
mov cr0, eax

;Do far jump to first (filled in) selector - the code selector.
jmp 8h:Start32

; Welcome to the world of 32-Bit mode! =-D
use32
Start32:
; Start off by setting the data segment to the data selector.
xor bx, bx
mov bx, 10h
mov ds, bx
mov es, bx
mov ss, bx
mov esp, 90000h

; Print Welcome Message
mov si, WelcomeStr
call PrintF

; Reroute PICS so that an exception doesn't occur every time an interrupt is called!
call Reroute_PICs

; Load Interrupt Descriptor Table
lidt [idtp]

; Enable Interrupts! =D
push ax
mov al, 1b ;Enable all except for IRQ0 - The timer.
out 0A1h, al
out 21h, al
sti
pop ax

call CmdPrintFunc

Hang:
jmp Hang

include "interrupts.inc"
;times 1474560-512-($-$$) db 0
    


interrupts.inc
Code:
;INTERRUPTS!!! YAY
EnableA20:
cli
mov al, 0ADh
out 64h, al
mov al, 0D0h
out 64h, al
in al, 60h
push ax
mov al, 0D1h
out 64h, al
pop ax
or al, 02h
out 60h, al
mov al, 0AEh
out 64h, al
sti
ret

PrintF:
push ebx
push eax
mov ebx, 0B8000h
PutCh:
lodsb
cmp al, 0
je Done
mov ah, [TxtClr]
mov word [ds:ebx], ax
add bx, 2
jmp PutCh

Done:
pop eax
pop ebx
ret

;Side data for PrintF
TxtClr db 2

Done2:
        ret

ClrScrn:
        mov ax, 10h
        mov ds, ax
        mov ebx, 0B8000h
        mov ax, 0
        clrloop:
                cmp ax, 2000
                je Done2
                mov byte [ds:ebx], ' '
                inc ebx
                mov byte [ds:ebx], 1Bh
                inc ebx
                inc ax
                jmp clrloop

CmdPrintFunc:
        mov ax, 10h
        mov es, ax
        mov edi, 0B8000h
        xor eax, eax
        cmdloop:
                cmp [ScanCode], 00h
                je cmdloop
                cmp [ScanCode], 1Ch
                je Done2

                ;Put character on the screen
                mov si, KeyBoard
                mov al, [ScanCode]
                cbw ; Convert Byte (AL) to Word (AX)
                add si, ax
                lodsb ; Takes the byte that's at the address in SI and puts it into AL
                mov ah, [TxtClr]
                mov [es:edi], byte al
                inc edi
                mov [es:edi], byte ah
                inc edi

                ;Reset ScanCode
                mov [ScanCode], 00h
                jmp cmdloop

Reroute_PICs:
        ;send ICW1(Interrupt Control Word1)
        mov al, 11h
        ;out PIC1, ICW1
        out 20h, al
        ;out PIC2 ICW1
        out 0A0h, al

        ;send ICW2
        mov al, 20h
        ;out PIC1 + 1, IRQ0 start point
        out 21h, al
        mov al, 28h
        ;out PIC2 + 1, IRQ8 start point
        out 0A1h, al

        ;send ICW3
        ;IRQ2 to Connection to Slave PIC
        mov al, 04h
        out 21h, al
        mov al, 02h
        out 0A1h, al

        ;send ICW4
        mov al, 01h
        out 21h, al
        out 0A1h, al

        ret

isr0:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err00
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr1:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err01
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr2:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err02
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr3:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err03
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr4:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err04
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr5:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err05
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr6:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err06
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr7:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err07
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr8:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err08
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr9:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err09
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr10:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err10
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr11:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err11
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr12:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err12
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr13:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err13
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr14:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err14
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr15:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err15
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr16:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err16
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr17:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err17
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr18:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, Err18
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr19:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr20:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr21:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr22:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr23:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr24:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr25:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr26:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr27:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr28:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr29:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr30:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

isr31:
        pusha
        push gs
        push fs
        push ds
        push es
        mov si, ErrRes
        call PrintF
        cli
        hlt
        pop es
        pop ds
        pop fs
        pop gs
        popa
        iret

irq0:
        cli
        mov si, TimerEnabled
        call PrintF
        mov al, 20h
        out 20h, al
        sti
        iret

irq1:
        cli
        push eax
        push ebx
        push es
        push ds

        xor eax, eax
        in al, 60h
        mov byte [ScanCode], al

        ;in al, 61h
        ;mov ah, al
        ;or al, 80h
        ;out 61h, al
        ;xchg ah, al
        ;out 61h, al

        mov al, 20h
        out 20h, al

        pop ds
        pop es
        pop ebx
        pop eax
        sti
        iret

idt_start:

        ;Interrupt Example
        ; dw start_address
        ; dw code_selector where ISR is being held
        ; dw type_settings for ISRs
        ; dw start_address2(bits 31-16)
        ; start_address2 should be 0 because the
        ; start address should be no more than 1
        ; word value.


        ;FOR HISTORIC REFERENCE PURPOSES ONLY
        ;Original ISRS looked like the following
        ;
        ;dw 0h000
        ;dw 0h8
        ;dw 8E00h
        ;dw 0h8
        ;
        ;END OF HISTORIC REFERENCE

        ;SERVICE REQUEST INTS
        ;int0
        dw isr0
        dw 08h
        dw 8E00h
        dw 0h
        ;int1
        dw isr1
        dw 08h
        dw 8E00h
        dw 0h
        ;int2
        dw isr2
        dw 08h
        dw 0E00h
        dw 0h
        ;int3
        dw isr3
        dw 08h
        dw 8E00h
        dw 0h
        ;int4
        dw isr4
        dw 08h
        dw 8E00h
        dw 0h
        ;int5
        dw isr5
        dw 08h
        dw 8E00h
        dw 0h
        ;int6
        dw isr6
        dw 08h
        dw 8E00h
        dw 0h
        ;int7
        dw isr7
        dw 08h
        dw 8E00h
        dw 0h
        ;int8
        dw isr8
        dw 08h
        dw 8E00h
        dw 0h
        ;int9
        dw isr9
        dw 08h
        dw 8E00h
        dw 0h
        ;int10
        dw isr10
        dw 08h
        dw 8E00h
        dw 0h
        ;int11
        dw isr11
        dw 08h
        dw 8E00h
        dw 0h
        ;int12
        dw isr12
        dw 08h
        dw 8E00h
        dw 0h
        ;int13
        dw isr13
        dw 08h
        dw 8E00h
        dw 0h
        ;int14
        dw isr14
        dw 08h
        dw 8E00h
        dw 0h
        ;int15
        dw isr15
        dw 08h
        dw 0E00h
        dw 0h
        ;int16
        dw isr16
        dw 08h
        dw 0E00h
        dw 0h
        ;int17
        dw isr17
        dw 08h
        dw 0E00h
        dw 0h
        ;int18
        dw isr18
        dw 08h
        dw 0E00h
        dw 0h
       ;int19
        dw isr19
        dw 08h
        dw 0E00h
        dw 0h
       ;int20
        dw isr20
        dw 08h
        dw 0E00h
        dw 0h
       ;int21
        dw isr21
        dw 08h
        dw 0E00h
        dw 0h
       ;int22
        dw isr22
        dw 08h
        dw 0E00h
        dw 0h
       ;int23
        dw isr23
        dw 08h
        dw 0E00h
        dw 0h
       ;int24
        dw isr24
        dw 08h
        dw 0E00h
        dw 0h
       ;int25
        dw isr25
        dw 08h
        dw 0E00h
        dw 0h
       ;int26
        dw isr26
        dw 08h
        dw 0E00h
        dw 0h
       ;int27
        dw isr27
        dw 08h
        dw 0E00h
        dw 0h
       ;int28
        dw isr28
        dw 08h
        dw 0E00h
        dw 0h
       ;int29
        dw isr29
        dw 08h
        dw 0E00h
        dw 0h
       ;int30
        dw isr30
        dw 08h
        dw 0E00h
        dw 0h
       ;int31
        dw isr31
        dw 08h
        dw 0E00h
        dw 0h

       ;HARDWARE INTERRUPT REQUESTS
       ;int32
        dw irq0
        dw 08h
        dw 8E00h
        dw 0h
       ;int33
        dw irq1
        dw 08h
        dw 8E00h
        dw 0h

idt_end:

idtp:
        dw idt_end - idt_start - 1
        dd idt_start

TimerEnabled db "Timer Interrupt Enabled!", 0
KeyPressed db "Keyboard Key pressed!", 0
Err00 db "Error 00 - Division By Zero",0
Err01 db "Error 01 - Debug",0
Err02 db "Error 02 - Non Maskable Interrupt",0
Err03 db "Error 03 - Breakpoint Exception",0
Err04 db "Error 04 - Into Detected Overflow",0
Err05 db "Error 05 - Out of Bounds",0
Err06 db "Error 06 - Invalid Opcode",0
Err07 db "Error 07 - No Coprocessor",0
Err08 db "Error 08 - Double Fault",0
Err09 db "Error 09 - Coprocessor Segment Overrun",0
Err10 db "Error 10 - Bad TSS",0
Err11 db "Error 11 - Segment Not Present",0
Err12 db "Error 12 - Stack Fault",0
Err13 db "Error 13 - General Protection Fault",0
Err14 db "Error 14 - Page Fault",0
Err15 db "Error 15 - Unknown Interrupt",0
Err16 db "Error 16 - Coprocessor Fault",0
Err17 db "Error 17 - Alignment Check",0
Err18 db "Error 18 - Machine Check",0
ErrRes db "Error - Reserved",0

KeyBoard db 0, 0, "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", 0, 0, "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", 0, 0, "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", "`", 0, "\", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", 0, "*", 0
ScanCode db 0
ScreenPos dd 0B8000h
    


Any help would be greatly appreciated. Thanks
Post 22 Nov 2007, 02:04
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
this comes from david jurgens's HELPPC reference
Code:
^INT 9 - Hardware Keyboard Make/Break Codes

%     Key          Make  Break                Key    Make  Break

      Backspace     0E    8E                  F1      3B    BB
    Caps Lock     3A    BA                  F2      3C    BC
    Enter         1C    9C                  F3      3D    BD
    Esc           01    81                  F4      3E    BE
    Left Alt      38    B8                  F7      41    C1
    Left Ctrl     1D    9D                  F5      3F    BF
    Left Shift    2A    AA                  F6      40    C0
    Num Lock      45    C5                  F8      42    C2
    Right Shift   36    B6                  F9      43    C3
    Scroll Lock   46    C6                  F10     44    C4
    Space         39    B9                  F11     57    D7
    Sys Req (AT)  54    D4                  F12     58    D8
    Tab           0F    8F

%             Keypad Keys                Make   Break

                 Keypad 0  (Ins)             52      D2
              Keypad 1  (End)             4F      CF
              Keypad 2  (Down arrow)      50      D0
              Keypad 3  (PgDn)            51      D1
              Keypad 4  (Left arrow)      4B      CB
              Keypad 5                    4C      CC
              Keypad 6  (Right arrow)     4D      CD
              Keypad 7  (Home)            47      C7
              Keypad 8  (Up arrow)        48      C8
              Keypad 9  (PgUp)            49      C9
              Keypad .  (Del)             53      D3
              Keypad *  (PrtSc)           37      B7
              Keypad -                    4A      CA
              Keypad +                    4E      CE

%            Key    Make  Break              Key    Make  Break

               A      1E    9E                 N      31    B1
             B      30    B0                 O      18    98
             C      2E    AE                 P      19    99
             D      20    A0                 Q      10    90
             E      12    92                 R      13    93
             F      21    A1                 S      1F    9F
             G      22    A2                 T      14    94
             H      23    A3                 U      16    96
             I      17    97                 V      2F    AF
             J      24    A4                 W      11    91
             K      25    A5                 X      2D    AD
             L      26    A6                 Y      15    95
             M      32    B2                 Z      2C    AC

%               Key    Make  Break              Key    Make  Break

               1      02    82                 -      0C    8C
             2      03    83                 =      0D    8D
             3      04    84                 [      1A    9A
         4      05    85                 ]      1B    9B
         5      06    86                 ;      27    A7
             6      07    87                 '      28    A8
            7      08    88                 `      29    A9
             8      09    89                 \      2B    AB
            9      0A    8A                 ,      33    B3
             0      0B    8B                 .      34    B4
                                             /      35    B5

^Enhanced Keyboard Keys (101/102 keys)

%  Control Keys              Make            Break

 Alt-PrtSc (SysReq)        54              D4
        Ctrl-PrtSc                E0 37           E0 B7
     Enter                     E0 1C           E0 9C
     PrtSc                     E0 2A E0 37     E0 B7 E0 AA
       Right Alt                 E0 38           E0 B8
     Right Ctrl                E0 1D           E0 9D
     Shift-PrtSc               E0 37           E0 B7
     /                         E0 35           E0 B5
     Pause                     E1 1D 45 E1 9D C5  (not typematic)
        Ctrl-Pause (Ctrl-Break)   E0 46 E0 C6        (not typematic)

    - Keys marked as "not typematic" generate one stream of bytes
       without corresponding break scan code bytes (actually the
       break codes are part of the make code).


%                      Normal Mode or
%                     Shift w/Numlock
%    Key              Make    Break     ÚÄÄÄÄÄ Numlock on ÄÄÄÄÄÄ¿
%                                        Make          Break
   Del              E0 53   E0 D3     E0 2A E0 53   E0 D3 E0 AA
        Down arrow       E0 50   E0 D0     E0 2A E0 50   E0 D0 E0 AA
        End              E0 4F   E0 CF     E0 2A E0 4F   E0 CF E0 AA
        Home             E0 47   E0 C7     E0 2A E0 47   E0 C7 E0 AA
        Ins              E0 52   E0 D2     E0 2A E0 52   E0 D2 E0 AA
        Left arrow       E0 4B   E0 CB     E0 2A E0 4B   E0 CB E0 AA
        PgDn             E0 51   E0 D1     E0 2A E0 51   E0 D1 E0 AA
        PgUp             E0 49   E0 C9     E0 2A E0 49   E0 C9 E0 AA
        Right arrow      E0 4D   E0 CD     E0 2A E0 4D   E0 CD E0 AA
        Up arrow         E0 48   E0 C8     E0 2A E0 48   E0 C8 E0 AA

%   Key           ÚÄÄLeft Shift PressedÄÄ¿      ÚÄÄRight Shift PressedÄÄ¿
%                   Make          Break          Make          Break
   Del           E0 AA E0 53   E0 D3 E0 2A    E0 B6 E0 53   E0 D3 E0 36
        Down arrow    E0 AA E0 50   E0 D0 E0 2A    E0 B6 E0 50   E0 D0 E0 36
        End           E0 AA E0 4F   E0 CF E0 2A    E0 B6 E0 4F   E0 CF E0 36
        Home          E0 AA E0 47   E0 C7 E0 2A    E0 B6 E0 47   E0 C7 E0 36
        Ins           E0 AA E0 52   E0 D2 E0 2A    E0 B6 E0 52   E0 D2 E0 36
        Left arrow    E0 AA E0 4B   E0 CB E0 2A    E0 B6 E0 4B   E0 CB E0 36
        PgDn          E0 AA E0 51   E0 D1 E0 2A    E0 B6 E0 51   E0 D1 E0 36
        PgUp          E0 AA E0 49   E0 C9 E0 2A    E0 B6 E0 49   E0 C9 E0 36
        Right arrow   E0 AA E0 4D   E0 CD E0 2A    E0 B6 E0 4D   E0 CD E0 36
        Up arrow      E0 AA E0 48   E0 C8 E0 2A    E0 B6 E0 48   E0 C8 E0 36
        /             E0 AA E0 35   E0 B5 E0 2A    E0 B6 E0 35   E0 B5 E0 36


        - The PS/2 models have three make/break scan code sets.  The first
    set matches the PC & XT make/break scan code set and is the one
         listed here.  Scan code sets are selected by writing the value F0
   to the keyboard via the ~8042~ (port 60h).  The following is a brief
        description of the scan code sets (see the PS/2 Technical Reference
     manuals for more information on scan code sets 2 and 3):

      ù  set 1, each key has a base scan code.  Some keys generate
          extra scan codes to generate artificial shift states.  This
         is similar to the standard scan code set used on the PC and XT.
  ù  set 2, each key sends one make scan code and two break scan
        codes bytes (F0 followed by the make code).  This scan code
         set is available on the IBM AT also.
     ù  set 3, each key sends one make scan code and two break scan
        codes bytes (F0 followed by the make code) and no keys are
          altered by Shift/Alt/Ctrl keys.
  ù  typematic scan codes are the same as the make scan code

     - Some Tandy 1000's do not handle Alt key combinations when multiple
         shift keys are pressed.  The Alt-Shift-H combination loses the Alt.
       - extended keys like (F11, F12) can only be read with systems that
    have extended keyboard BIOS support (or ~INT 9~ extensions);  to
    read these special keys on these systems ~INT 16,10~ must be used

       - see  ~SCAN CODES~   ~KB FLAGS~  ~KEYBOARD COMMANDS~
    


hope/think/believe it is helpfull!
Post 22 Nov 2007, 02:18
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
you can increase clrscrn's speed:
Code:
ClrScrn: 
        push ecx ebx eax ds
        mov ax,10h 
        mov ds,ax 
        mov ebx,0B8000h 
        mov eax,499 
        mov ecx,1B201B20h
@@: 
        mov [ebx+eax*4],ecx  
        dec eax 
        jl @b
        pop ds eax ebx ecx
        ret
    


and less space

Code:
cls:
        push eax ebx ds
        mov ax,screenB8
        mov ds,ax
        mov eax,499
        mov ebx,1B201B20h
@@:
        mov [eax*4],ebx
        dec eax
        jnl @b
        pop ds eax ebx
    
Post 22 Nov 2007, 02:38
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Thanks! That really does help. 80h is added to each scancode when the key is up.
Post 22 Nov 2007, 03:26
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
not 80h added

bit 7 set to 1 for break code

but be carefull
there are a lot of extra codes
like E0h EEh C0h etc thats indicate the scancode is a multiple scancode

you must save these "unsused" codes for the next read
Post 22 Nov 2007, 03:31
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
bit 7 out of 0-7 or bit 7 out of 1-8?
Post 22 Nov 2007, 04:24
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Okay... so now I'm trying to store my scancode value in an unused register (BL), and then OR the contents of BL with 80h (10000000b) then store the result into a variable, and it's giving me an invalid opcode error.
Post 22 Nov 2007, 04:39
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Nevermind, I got it working.
Post 22 Nov 2007, 04:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.