1

Someone knows Why the RightKeyUp aren't Going To exit and the other keys are Going ?
its in Tasm Turbo Assembler

When i clear the buffer (mov ah,0ch mov al,07h int 21h)

For some reason I don't get a key release

For example This Code(RightUp is Never Accepted):

  IDEAL
    MODEL large
    STACK 256
RightUP          equ 11001101b
RightDown        equ 77
LeftDown         equ 75
EscKey           equ 1
    DATASEG
    CODESEG   
    Start:

    mov ax, @data
    mov ds, ax

    mov ax, 0013h
    int 10h

    lop:
    mov ah,0ch
    mov al,07h
    int 21h 

    in ax,060h
    ;push ax   

    cmp al,RightUP
    je lbl1

    cmp al,RightDown
    je lbl2

    cmp al,EscKey
    je lbl1
    cmp al,LeftDown
    je lbl1

    jmp lop

    lbl1:
    jmp exit

    lbl2:
    jmp lop

    Exit:
    mov ah,00h
    mov al,03h
    int 10h
    mov ax,04c00h
    int 21h

    End Start

i Checked more option and I understood that These two commands(mov ah,0,int 16h) do the same But also do not get the release of key i really need help :)

More code that is more tangible:

    IDEAL

MODEL large

STACK 256

    RightUP          equ 11001101b
    RightDown        equ 77
    EscKey           equ 1

DATASEG

    CanClick db 1

CODESEG   

Start:

        mov ax, @data
        mov ds, ax

        mov ah,00h
        mov al,03h
        int 10h

lbl1:
    mov [CanClick],1
lop:
        ;mov ah,0ch
        ;mov al,07h
        ;int 21h    
        ;in al,060h
        mov ah,0
        int 16h

        cmp ah,RightDown
        je lbl2

        cmp ah,RightUP
        je lbl1

        cmp ah,EscKey
        je lbl1
jmp lop

lbl2:
    cmp [CanClick],1
    jne lop

    mov ah,0eh
    mov al,97
    mov BH,0
    mov BL,0
    int 10h
    mov [CanClick],0
jmp lop

Exit:
        mov ax,04c00h
        int 21h

End Start
Gad
  • 154
  • 8
  • Did you try single-stepping in a debugger and seeing what value you actually get in AL for that keypress? If not, do that. Also, your branching is overcomplicated. Just put `lbl2` in the same place as `lop` instead of jumping to another `jmp`. Lay out your branches so you don't need as many total, especially unconditional branches. Easier to follow in your head, and to debug. – Peter Cordes Apr 12 '20 at 07:01
  • I tried to check in a debugger but I didn't I succeeded Do you have any idea to solve it? – Gad Apr 12 '20 at 07:21
  • Double-check your definitions of `RightUP` and other constants that they match what you see in AL with a debugger. Add info that you find with a debugger to your question. AL==RightDown is doing `je lbl2` while the others are jumping to `lbl1`. Is that the difference you were looking for. It's not even clear what you're saying is happening vs. what you want to happen. See [mcve]. – Peter Cordes Apr 12 '20 at 07:24
  • the definitions of RightUP are Ok the problem is that i dont understand why with this three commends(mov ah,0ch mov al,07h int 21h) its dont working and without them it is...... To Working i mean that When RightUp Pressed jump To Exit – Gad Apr 12 '20 at 07:29
  • Ok, I think I might understand what you're saying now. I don't know the answer, but use a debugger to see what value you get in a register with/without that code. I wonder if there's a key-release event in the keyboard buffer from letting go of the return key when your program starts? Could `in` be reading that? Your last comment explains it slightly better than the text in the question so you should edit it to make sure it's clear what happens in both cases vs. what you *want* to happen. – Peter Cordes Apr 12 '20 at 08:25
  • I edited the post ,I'd be happy that you to take a look ,Do you have any idea? – Gad Apr 12 '20 at 08:58
  • Your key mappings are wrong. IE RightUp = 0x49 (73) and RightDown = 0x51 (81). I've tested this on a system running DOS 6.22 and I would suspect DOSBOX or other emulators will return the same result. – Shift_Left Apr 12 '20 at 17:15

1 Answers1

2
mov ah,0ch
mov al,07h
int 21h 
in ax,060h

With the above code when you press Right, DOS first returns a zero in the AL register and expects you to issue another invocation of function 07h in order to receive the actual scancode which will be 4Dh or 77 in decimal. Your use of reading port 60h could be considered that 2nd invocation but it will never return any keyboard release code like the 11001101b that you seem to expect.

 mov ah,0
 int 16h

The BIOS.WaitKeystroke function in your second program will also never return keyboard release codes.

For an example of using port 60h that might help you see Faster keyboard scan code detection in 8086 assembly

Sep Roland
  • 33,889
  • 7
  • 43
  • 76