flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 13 May 2012, 10:56
In Windows you can't use direct I/O because it is a protected OS.
You have to call some of the API functions like ReadFile. |
|||
![]() |
|
mkng 13 May 2012, 10:58
revolution wrote: In Windows you can't use direct I/O because it is a protected OS. Can you be more precise? How ReadFile could help me with keyboard? |
|||
![]() |
|
revolution 13 May 2012, 11:00
Get the STDIN handle and then use ReadFile to get the characters.
There are already example of code for this on this forum. |
|||
![]() |
|
mkng 13 May 2012, 11:34
Don't think I'm lazy or stupid, but... I can't find any example that could be helpful. Everything I've found is about console applications or dialog boxes. Any clue?
|
|||
![]() |
|
AsmGuru62 13 May 2012, 11:45
Before you start with a keyboard -- what kind of application you will
be controlling? There are two type of applications for Windows: - Console (you just see a black box, like DOS, but it is NOT DOS!) - GUI (you have one or more windows) So, what kind of application it will be? P.S. The keyboard input is programmed DIFFERENTLY for these two app types. |
|||
![]() |
|
Picnic 13 May 2012, 11:50
Hi,
for the specific GUI example simply add a WM_KEYDOWN event Code: cmp [wmsg], WM_KEYDOWN je wmkeydown Code: wmkeydown: ; get WM_KEYDOWN message push [wparam] pop eax ; examine virtual-key code .if (al = VK_LEFT) jmp lineleft .elseif (al = VK_RIGHT) jmp lineright .endif jmp defwndproc ; see also http://msdn.microsoft.com/en-us/library/windows/desktop/hh298359(28v=vs.85).aspx Use arrow keys to scroll, if that is what you want. |
|||
![]() |
|
mkng 13 May 2012, 12:37
@AsmGuru62: GUI.
@Picnic: great, thank you! But... I understand that You gave me a pseudocode, right? Now how should I write the "if" section in assembler? I've tried this: Code: cmp AL, WM_KEYDOWN
je lineleft but I get "value out of range" error. Last edited by mkng on 13 May 2012, 13:45; edited 1 time in total |
|||
![]() |
|
Picnic 13 May 2012, 12:45
WM_KEYDOWN is a 16-bit value while al an 8-bit register.
It's full working code. Replace the line (sorry my bad), Code:
include 'win32w.inc'
with Code:
include 'win32wx.inc'
may be better to start with fasm documentation, learn about windows programming headers here, then read more about windows messages in msdn, before you start writing code. |
|||
![]() |
|
mkng 13 May 2012, 12:59
Wow, that's pretty cool! Thank you!
![]() Looking at the code I wonder why there's jump to defwndproc (just after .endif)? It seems that this jump will never be executed, so there's no need for it to be there. By the way - just to know - this ".if" clauses are equal to what asm code? I mean - if I wanted to write equal if-clause in pure assembler, how should it look? |
|||
![]() |
|
Picnic 13 May 2012, 14:18
Actually the jump will executed every time there is a WM_KEYDOWN event which is not a VK_LEFT or VK_RIGHT.
Code: wmkeydown: ; get WM_KEYDOWN message push [wparam] pop eax ; examine virtual-key code cmp al, VK_LEFT je lineleft cmp al, VK_RIGHT je lineright ; ; jmp defwndproc |
|||
![]() |
|
AsmGuru62 13 May 2012, 14:28
@Picnic: why not 'mov eax, [wparam]'?
|
|||
![]() |
|
shutdownall 13 May 2012, 17:38
AsmGuru62 wrote: @Picnic: why not 'mov eax, [wparam]'? Maybe a personal style of coding. ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.