News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Input

Started by HiddenDragon, December 12, 2010, 12:31:08 AM

Previous topic - Next topic

HiddenDragon

First off, do I need an actual window to accept keyboard input? I've looked at Iczelion's tutorials and he did but a window shouldn't be necessary right? How do I accept keyboard input then? Right now I have

include \masm32\include\masm32rt.inc

.data
    PromptOne db "Enter a 0 or 1",0
    PromptTwo db "Enter another 0 or 1",0
    Yes db "Yes",0
    No db "No",0

.data?
    InputOne db ?
    InputTwo db ?

.code
start:  push 0
        push offset PromptOne
        push offset PromptOne
        push 0
        call MessageBoxA

        ;get input here

        push 0
        push offset PromptTwo
        push offset PromptTwo
        push 0
        call MessageBoxA

        ;get second input

        OR InputOne,InputTwo
        mov eax,offset Yes
        jnz done
        mov eax,offset No
done:   push 0
        push eax
        push eax
        push 0
        call MessageBoxA
        push 0
        call ExitProcess
end start


I don't really care about limiting my input to just 0 or 1 right now, just getting the input.

redskull

Generally speaking, you must have a window to get any input.  This window, however, can be a pre-built dialog box, a console window, a task dialog, a "hidden" window that only responds to key events, etc.  Even a message box is still a "window", in the technical sense
Strange women, lying in ponds, distributing swords, is no basis for a system of government

HiddenDragon

Well I was meaning a window in the sense of a sizable, minimize/maximize/exit window. So I can get keyboard input with just a messagebox?

hutch--

3 choices, a console app that handles input and output, a dialog application that has a text box to input data or a normal Window that has a text box to enter text.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

HiddenDragon

What about Iczelion's tutorial 6? It has no textbox.

How would I get started in making windows without all the macros? I don't really like using them.

hutch--

> I don't really like using them.

Thats simple, write the code yourself. There are plenty of examples around. In the masm32 example code, have a look at the example masm1k. If you want a window written in lower level again, look at the axample POASM1k.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

if you find a macro you want to replace - the code is in the macros folder
figuring out how the macro works will also help you understand how to write them   :U

HiddenDragon

Thanks hutch. I'm thinking I'll use the POASM1k one and see if I can make any sense of it.

From there, what do I do to get the input? I know I can add a textbox but what other options are there?

And thanks for the tip dave.

dedndave

there is a nice example...
C:\masm32\examples\exampl02\qikpad

is that what you are looking for ?

HiddenDragon

I was really just trying to have the user enter 2 single bit numbers and make a half adder or full adder just for fun.

dedndave

so - you want an edit control...

C:\masm32\examples\bcraven\popinfo

you can combine it with the one in the middle of this demo if you want all the bells and whistles   :P

C:\masm32\examples\bcraven\controls

HiddenDragon

Thanks dave, that should be helpful once I understand how to make a window. Sometimes I just feel  :dazzled:

dedndave

one step at a time

HiddenDragon

start:
    push ebp                                ; set up a stack frame
    mov ebp, esp

    sub esp, 96                             ; create stack space for locals

    xor edi, edi


At the xor edi,edi part there isn't anything in edi yet. Does that just set it to 0 to get it ready?

dedndave

well - yes
the question is - get it ready for what
you'll have to see how EDI is used in the rest of the code
it probably ought to be pushed, too   :P

but...
QuoteAt the xor edi,edi part there isn't anything in edi yet.
there is always something in EDI