int 16 Question

Hello All,

I have a question regarding function 2, int 16h. I have a 16-bit dos-based text editor which I'm trying to add menu's that can be access with -, - and - I'm having a real difficult time getting this to work. Essentially I'm using:

mov ah, 2h
int 16h
mov FLAGS, al

to read the flags, store them in a BYTE variable so that I can reference the flags at a latter time. How do I go about integrating this into my application and allowing for these keystroke combonations to be used?

Any suggestions would be greatly appreciated.

Thanks,

Joe

Comments

  • : Hello All,
    :
    : I have a question regarding function 2, int 16h. I have a 16-bit dos-based text editor which I'm trying to add menu's that can be access with -, - and - I'm having a real difficult time getting this to work. Essentially I'm using:
    :
    : mov ah, 2h
    : int 16h
    : mov FLAGS, al
    :
    : to read the flags, store them in a BYTE variable so that I can reference the flags at a latter time. How do I go about integrating this into my application and allowing for these keystroke combonations to be used?
    :
    : Any suggestions would be greatly appreciated.
    :
    : Thanks,
    :
    : Joe
    :
    [blue]Simply test bits in FLAGS variable:
    [code]
    ALT_KEY_BIT equ 4
    CTRL_KEY_BIT equ 8
    ALT_AND_CTRL_BOTH equ (ALT_KEY_BIT or CTRL_KEY_BIT)

    ; I may be mistaken here ^^^, so swap the values if
    ; it will not work properly, but I know for sure that one of them
    ; is 8 and other one is 4 - I just not sure which one - DOS is
    ; covered with dust for me now.

    MOV AL, FLAGS

    TEST AL, ALT_KEY_BIT
    JNZ AltKeyPressed

    TEST AL, CTRL_KEY_BIT
    JNZ CtrlKeyPressed

    AND AL, ALT_AND_CTRL_BOTH
    CMP AL, ALT_AND_CTRL_BOTH
    JE BothAltAndCtrlPressed
    [/code]
    [/blue]
  • : : Hello All,
    : :
    : : I have a question regarding function 2, int 16h. I have a 16-bit dos-based text editor which I'm trying to add menu's that can be access with -, - and - I'm having a real difficult time getting this to work. Essentially I'm using:
    : :
    : : mov ah, 2h
    : : int 16h
    : : mov FLAGS, al
    : :
    : : to read the flags, store them in a BYTE variable so that I can reference the flags at a latter time. How do I go about integrating this into my application and allowing for these keystroke combonations to be used?
    : :
    : : Any suggestions would be greatly appreciated.
    : :
    : : Thanks,
    : :
    : : Joe
    : :
    : [blue]Simply test bits in FLAGS variable:
    : [code]
    : ALT_KEY_BIT equ 4
    : CTRL_KEY_BIT equ 8
    : ALT_AND_CTRL_BOTH equ (ALT_KEY_BIT or CTRL_KEY_BIT)
    :
    : ; I may be mistaken here ^^^, so swap the values if
    : ; it will not work properly, but I know for sure that one of them
    : ; is 8 and other one is 4 - I just not sure which one - DOS is
    : ; covered with dust for me now.
    :
    : MOV AL, FLAGS
    :
    : TEST AL, ALT_KEY_BIT
    : JNZ AltKeyPressed
    :
    : TEST AL, CTRL_KEY_BIT
    : JNZ CtrlKeyPressed
    :
    : AND AL, ALT_AND_CTRL_BOTH
    : CMP AL, ALT_AND_CTRL_BOTH
    : JE BothAltAndCtrlPressed
    : [/code]
    : [/blue]
    :
    Here are the bits:
    bit 0 - right shift pressed
    bit 1 - left shift pressed
    bit 2 - ctrl pressed
    bit 3 - alt pressed
    bit 4 - scroll lock on
    bit 5 - num lock on
    bit 6 - caps lock on
    bit 7 - insert on

    You can also get the flags directly from 40h:17h without interrupts.
    I think this should be faster:

    [code]PUSH ds ;Save the segment
    PUSH 40h
    POP ds
    MOV si,17h
    LODSB
    MOV FLAGS,al
    POP ds[/code]
    then you can start testing the bits and stuff.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories