Caps lock

Programming, for all ages and all languages.
Post Reply
chezzestix
Member
Member
Posts: 118
Joined: Mon May 05, 2008 5:51 pm

Caps lock

Post by chezzestix »

I am trying to get capslock to work but the code I have isnt recognizing that capslock is on. Does it look correct? I've only tested this in VirtualBox, could it just be the emulator?

The code is based off the falicy that if the value of al is greater than 64 then capslock is on (reference). I know that this can also be caused by insert but I'm just trying to get this thing to confim that its on. I will use bit masking later.

Code: Select all

A005_capslock:
       mov si,A005_strci
       call print ;prints null terminated string in si
       mov ah,02h
       int 16h ;get shift flags
       cmp al,40h ;if its greater than 40h either capslock is on or insert is
       jl A005_off
       mov si,A005_stron
       call print
       jmp A005_end
       A005_off:
       mov si,A005_stroff
       call print
       A005_end:
       ret

A005_strci   db "Caps Lock is ",0
A005_stron   db "on",0Dh,0Ah,0
A005_stroff  db "off",0Dh,0Ah,0  
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Caps lock

Post by bewing »

AFAIK, the byte in the BDA at physical address 0x497 contains the LED bits/shift state when you are in Real mode. The Caps Lock bit is bit #2, value = 4. So it looks to me like you are doing it the hard way. :wink:
Post Reply