News:

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

Getting Started

Started by Akash, December 31, 2011, 08:33:19 AM

Previous topic - Next topic

Akash

 ::) Hey, maybe I am catching up with Assembly. Okay here is what I have understood. Registers are just places in memory, I need to understand the meaning and significance of the registers and use them accordingly for storing values and use those values by moving them here and there. And I don't get those features I used to get in HLLs and registers are there just so that I can use them for storing suitable values / datas. And, .. and .. well that's it. And, understand certain meanings of the instructions.
So, what I use and when I use is the logic of Assembly. Am I right ?  :8)

avcaballero

Using registers is much more quickly than memory accessing, so you should use registers as much as you can. Also, they are a way to shared data with procedures ... Also they are needed to math operations, etc.

Akash

Its me again but, this time it is not another silly question. I have got the hold of assembly. Seems it is not as hard as I thought it is.  :green2

(1) Each register can not hold more than one values at a time. Am I right ?

(2) And, when I store some value in a register supp. ecx then, if I have some of my own function. What will be the register ecx in it be ? I mean, will the value in it be same as the one I have defined / stored earlier? (Will the value in it be affected by the function I call afterwards ? It won't be like it is in C.) Am I right ?

(3) When I store some value in eax, and then I call some procedure which (I learned,) will store the result (probably) in eax. So, I'm supposed to push it before I call the function so that I don't lose the information I stored in eax. Am I right ?

Thanks   :bg

dedndave

1) correct

2) the value in ECX will remain the same until some instruction changes it
this is true for all code in the current thread - a program may have more than one thread - but, that's an advanced topic

3) this is true
the trick is not to have important values in EAX, ECX, or EDX when you call a function, if practical to do so
those 3 registers are likely to be destroyed - the others are typically preserved in win-32 applications

sometimes, you may want to preserve one of those registers across a call
then use PUSH and POP
notice that you may want to do something with the value that the function returns in EAX, first
there are a few ways to handle this
one way is to PUSH a value from one register (let's use EAX), and POP it into another...
        push    eax
        call    SomeFunction
        pop     edx

the value that was originally in EAX is now in EDX
and the value returned by SomeFunction is in EAX

Akash

Looks like PUSH and POP are the parts of the Assembly's backbone. Thank you, I got it. :U

And, by the way, to create threads, we use the function CreateThread() in MASM32 (just as in any other HLL) or are there any inbuilt methods ?

::)

Thanks

donkey

Quote from: Akash on January 19, 2012, 04:50:02 AM
Looks like PUSH and POP are the parts of the Assembly's backbone. Thank you, I got it. :U

And, by the way, to create threads, we use the function CreateThread() in MASM32 (just as in any other HLL) or are there any inbuilt methods ?

::)

Thanks

CreateThread is part of the Windows API, not MASM32. Windows provides a rich set of functions that allow a programmer to properly interface with it and have it do things like create dialogs and windows, manipulate text and images, manage memory, create and execute threads and thousands of other mundane functions. You can call these functions via a LIB file that wraps the call to the containing DLL. Almost every DLL and OCX you see in System32 makes up a piece of the API, extensions to it can be found in various programs you install. The API is documented at MSDN:

http://msdn.microsoft.com/en-us/library/ff818516.aspx

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Akash

QuoteCreateThread is part of the Windows API, not MASM32. Windows provides a rich set of functions that allow a programmer to properly interface with it and have it do things like create dialogs and windows, manipulate text and images, manage memory, create and execute threads and thousands of other mundane functions. You can call these functions via a LIB file that wraps the call to the containing DLL. Almost every DLL and OCX you see in System32 makes up a piece of the API, extensions to it can be found in various programs you install. The API is documented at MSDN:
 
:eek
Thank you but, that is something which I already know. You misunderstood my question ..

I just wanted to know if the use of CreateThread() function exported by Kernel32.DLL is the only method through which the threads can be created in MASM32 or if there are any inbuilt methods (provided by Assembly Programming Language itself). I myself don't think that there are any Assembly Language inbuilt methods for threads creation but, asked just so.


donkey

Quote from: Akash on January 19, 2012, 01:34:19 PM
I just wanted to know if the use of CreateThread() function exported by Kernel32.DLL is the only method through which the threads can be created in MASM32 or if there are any inbuilt methods (provided by Assembly Programming Language itself). I myself don't think that there are any Assembly Language inbuilt methods for threads creation but, asked just so.

There are none, Assembly has no built in functions though Hutch's MASM32 package might have something it would simply be a wrapper for CreateThread, I haven't looked at the package in many years.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable