flat assembler
Message board for the users of flat assembler.

Index > Main > A Questions about keys

Author
Thread Post new topic Reply to topic
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
Hey, all. What are the hexadecimal for the direction keys, example:
Left, Up, Right, Down

And how do I implement them in the following code:
Code:
...
xor ax,ax
int 16h

;check for keys
 cmp ('direction key up here'),al
 je MOVE_UP
 cmp ('direction key down here'),al
 je MOVE_DOWN
...
    


Im planning to use them in my CLI(Shell). And also, is there a possible way (in DOS) to determine where the mouse is on the screen and if so, when the user right clicks, a command is executed on that pre-determined area.
Can someone help me in both questions
??Sad??

_________________
meshnix
Post 04 Mar 2010, 21:45
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Post 04 Mar 2010, 22:22
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
Fn 0 Int 0x16 returns the following values on Arrow key press:
UP: AX = 0x4800
DOWN: AX = 0x5000
RIGHT: AX = 0x4B00
LEFT: AX = 0x4D00

you can use smth like
Code:
.wait_key:
    xor ax, ax
    int 0x16
    cmp ax, 0x5000  ;down arrow key?
    jz short .down
    cmp ax, 0x4800  ;up arrow key?
    jz short .up
    . . .
    cmp al, 13  ;enter key pressed?
    jnz short .wait_key
.process:
 . . . enter key pressed
    jmp
    
Post 04 Mar 2010, 22:22
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
mov ax,3
int 33h
mov [mouse.x],ecx
mov [mouse.y],edx
mov [status],bl ;bit 0=left bit 1=right
Post 04 Mar 2010, 22:31
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
Thanks guys!!
I have 2 questions (again)
Zhak, why did u use a short jump? (i never understood the short jump)
Edfed, why did you use 32-bit registers, instead of 16-bit?
Post 04 Mar 2010, 22:41
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
i use short prefix to control code size. i want my Jcc instructions to be 2-bytes long. also, sometimes i need my code to be compatible with 8086 until i perform cpu check, and that cpus don't support near jumps (4-byte opcodes)
Post 04 Mar 2010, 23:07
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
Ahhh, i see. thanks.
Post 04 Mar 2010, 23:13
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
because it is my personnal way to code. 16 bits is dead.

of course,x & y are not 32bits but 16bits in cx and dx
Post 05 Mar 2010, 06:16
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
That is sort of true, but I still prefer 16-bit coding, as I am just a beginner of assembly programming
Post 05 Mar 2010, 14:01
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
32 bit is easier than 16 bit. Smile
Post 05 Mar 2010, 14:29
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit
ohhh...
Post 05 Mar 2010, 22:25
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.