assembly FASM汇编程序,同时单击两个Shift键并使大写字母

w8ntj3qf  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(84)

我在FASM汇编程序中有这样一个程序,我想让它们大写,当我输入字母dfghjkl时,当我同时单击左移和右移时,目前它的工作方式是,即使我单击右移,它们也会大写,我只想在我同时单击时才使用它们。

format MZ
stack stk:256
entry text:main

macro delay time
{
local ext,iter,end
      push cx
      mov cx, time
ext:
     in al,60h
     cmp al,01h
     je end
     push cx
     mov cx, 0FFFFh
iter:

     loop iter
     pop cx
     loop ext
     pop cx
end:
    pop cx

}
segment data_16 use16
_stare08 dw ?
         dw ?
_stare09 dw ?
_program dw ?
params   dw ?
         dw ?
mark_08  dw 0
time_08  db 0

mark_09 dw 320
znakim db 'dfghjkl'
znakid db 'DFGHJKL'
atryb db 71h
flagashift db 0      ;lewyshift-->2ah
flagashiftp db 0

segment text use16
moje08:
        push ax
        push bx
        push es
        test [time_08],03
        jnz skip
        mov ax,0B800h
        mov es,ax
        mov al,21h
        mov ah,71h
        mov bx,[mark_08]
        mov [es:bx],ax
        add [mark_08],2
skip:
        inc [time_08]
        pop es
        pop bx
        pop ax
        jmp dword [ds:_stare08]
moje09:
        push ax
        push bx
        push es
        in AL,60h

        cmp AL,42
        jne sprawdzPrawyShift
        mov byte [ds:flagashift],1
        jmp sprawdzPrawyShift

sprawdzPrawyShift:
    cmp AL, 54
    jne dalej3
    mov byte [ds:flagashiftp], 1

    ; Sprawdzenie, czy zarówno Shift lewy, jak i prawy shift jest wcisniety
    cmp byte [ds:flagashift], 1
    jne dalej3

dalej3:
        cmp AL,170
        jne dalej4
        mov byte [ds:flagashift],0
        mov byte [ds:flagashiftp],0
        jmp dalej4
Nieklik:
        cmp AL, 0BAh
        jne dalej4
        mov byte [ds:flagashiftp], 0
        jmp dalej4

dalej4:
        cmp AL,80h
        ja dalej
        sub AL,2
        cmp AL,09h
        ja dalej1
        inc AL
        cmp AL,80h
        jne xx
        sub AL,80h

xx:     add AL,30h
yy:
        mov AH,[atryb]
        mov BX,[mark_09]
        push ax
        mov ax,0B800h
        mov es,ax
        pop ax
        mov [ES:BX],AX
        add [mark_09],2
        jmp dalej
dalej1:
        sub al,30
        cmp al,6
        ja dalej
        mov ah,0
        mov bx,znakim
        add bx,ax
        mov al,byte [ds:flagashift]
        mov al,byte [ds:flagashiftp]
        test al,0FFh
        jz dalej5
        add bx,7

dalej5:
        mov al,[bx]
        jmp yy

dalej:
        in AL,61h
        or AL,80h
        out 61h,AL
        and AL,7Fh
        out 61h,AL

        mov AL,20h
        out 20h,AL

        pop es
        pop bx
        pop ax
        iret

moje10:
        push ax
        push bx
        push es
        in al,60h
        cmp AL,54
        jne asd
        mov byte [ds:flagashiftp],1
        jmp asd
asd:
        pop es
        pop bx
        pop ax
        iret

main:
        mov ax,data_16
        mov ds,ax
        mov ax,stk
        mov ss,ax
        mov sp,256

        cli
        xor ax,ax
        mov es,ax
        les bx,[es:(8 shl 2)]
        mov [_stare08+2],es
        mov [_stare08],bx
        mov es,ax
        mov word[es:(8 shl 2)],moje08
        mov word[es:(8 shl 2)+2],text

        mov es,ax
        les bx,[es:(9 shl 2)]
        mov [_stare09+2],es
        mov [_stare09],bx
        mov es,ax
        mov word[es:(9 shl 2)],moje09
        mov word[es:(9 shl 2)+2],text
        sti

        delay 60000

        cli
        xor ax,ax
        les cx,dword[ds:_stare08]
        mov ds,ax
        mov [ds:(8 shl 2)],cx
        mov [ds:(8 shl 2)+2],es

        mov ax,data_16
        mov ds,ax
        les cx,dword[ds:_stare09]
        xor ax,ax
        mov ds,ax
        mov [ds:(9 shl 2)],cx
        mov [ds:(9 shl 2)+2],es

        mov ax,data_16
        mov ds,ax
        sti

        mov ah,1
        int 21h
        mov ax,4c00h
        int 21h

        ret

....
segment stk use16
        db 256 dup (?)


    mov ah,1h
    int 21h
    
    mov ax,0003h
    int 10h
    
    mov ax,4c00h
    int 21h

字符串
我提供的代码显示了我的尝试。

5n0oy7gb

5n0oy7gb1#

目前它的工作方式是,即使我点击右移,它们也会变成大写,
无论何时按下L-shift,您都执行mov byte [ds:flagashift], 1,无论何时按下R-shift,您都执行mov byte [ds:flagashiftp], 1
虽然决定大写的代码读作 flagashift,但它也会立即用另一个标志覆盖它!没有办法让它依赖于左移位键。

mov al,byte [ds:flagashift]
mov al,byte [ds:flagashiftp]     <<< is overwriting AL
test al,0FFh
jz dalej5
add bx,7

字符串
只有当我同时点击的时候我才需要它们。
同时按下两个键将转换为它们的标志之和为2。因此:

mov al, [ds:flagashift]  ; [0,1]
add al, [ds:flagashiftp] ; [0,1]
cmp al, 2
jne dalej5               ; Keep small caps
add bx, 7                ; Capitalize

相关问题