flat assembler
Message board for the users of flat assembler.

Index > Windows > Learning fasm from masm

Goto page Previous  1, 2, 3, 4, 5, 6  Next
Author
Thread Post new topic Reply to topic
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 03 Oct 2012, 14:59
I would like to know a good system for making local labels. Sometimes @@ is practical and just jump back or forward. But sometimes it is not practical because you need to jump beyond the @@ label.

Using .labelname can then be used. But I would like to know if there is a preferred method to use all the time and also I'd like some input on good naming convention. I sometimes just use names like
.x1: .l1: etc.. Using too long labels is somewhat frustrating.
Post 03 Oct 2012, 14:59
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1694
Location: Toronto, Canada
AsmGuru62 03 Oct 2012, 16:09
Yet using a long labels makes readable code.
Also, a good editor will auto-complete long labels, names, etc.
Post 03 Oct 2012, 16:09
View user's profile Send private message Send e-mail Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 03 Oct 2012, 23:11
I have a question about optimization. I have a suspicion that jumping with an immediate is faster than jumping to the content of a register because the processor cannot tell what the register contains at the time the jump is done.

like:

jmp dword [eax]

or

jmp immediate

which is faster?
Post 03 Oct 2012, 23:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20520
Location: In your JS exploiting you and your system
revolution 04 Oct 2012, 00:22
nmake wrote:
which is faster?
We can't know the answer. This type of question is incredibly complex to model. I suggest that you code up different solutions and see if you can measure a difference. In most program this will never make any difference. Many people waste their time trying to gain an extra nanosecond by spending days coding alternatives.
Post 04 Oct 2012, 00:22
View user's profile Send private message Visit poster's website Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 07 Oct 2012, 10:58
If I pass a string to a macro call, how can I access character 2 in that string from within the macro?
Post 07 Oct 2012, 10:58
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 07 Oct 2012, 11:00
I don't know if I already asked this, in one situation I understand the difference between rept and repeat but in another situation I don't understand the difference between the two. Maybe it is the purpose I don't understand, in addition you have the times directive. Could anyone (in simple terms) explain the major difference between rept, repeat and times once and for all. I would highly appreciate it, I think other people who are new to fasm will appreciate it also.

I understand that times deals with a single instruction only.
Post 07 Oct 2012, 11:00
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20520
Location: In your JS exploiting you and your system
revolution 07 Oct 2012, 11:05
rept is a preprocessor directive.
repeat is an assembly time directive.

rept uses {} to delimit blocks.
repeat uses end repeat to finish blocks.

Anyhow it is all in the manual.
http://flatassembler.net/docs.php
Post 07 Oct 2012, 11:05
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20520
Location: In your JS exploiting you and your system
revolution 07 Oct 2012, 11:08
nmake wrote:
If I pass a string to a macro call, how can I access character 2 in that string from within the macro?
Use virtual and place the string with db, and then load to read characters.

And with the new namespace capability you can also read the string characters outside of the virtual block.
Post 07 Oct 2012, 11:08
View user's profile Send private message Visit poster's website Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 07 Oct 2012, 11:39
The virtual directive is pretty cool. I like how it can be used to load generated code too, quite useful thing to have.

Could you give a specific example of a very simple situation where rept and repeat differs and the difference would matter. Although I now understand the definitive difference, I want to see this difference in a practical sample. Thanks Smile
Post 07 Oct 2012, 11:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20520
Location: In your JS exploiting you and your system
revolution 07 Oct 2012, 11:58
rept can generate new labels, something that repeat can't do.

repeat can do complex computations and generate bytes for the output, something that rept can't do.

It is all tied the to the preprocessor/assembler separation paradigm.
Post 07 Oct 2012, 11:58
View user's profile Send private message Visit poster's website Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 07 Oct 2012, 17:12
Can you give an example of using namespace?
Post 07 Oct 2012, 17:12
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 07 Oct 2012, 18:19
I am confused about local labels in macros. Am I forced to use double-dots?

Code:
macro fastmessage [msgstring]
{
        local ..label
        jmp ..label
        A=$
        db msgstring,0
        ..label:
        invoke MessageBox,[hwnd],A,A,MB_OK
}
    
Post 07 Oct 2012, 18:19
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 07 Oct 2012, 22:17
Quite a few questions today. hehe. Why do some programs use this:

Code:
somevar dd ?    


and some programs use

Code:
somevar rd 1    


Isn't both doing the same thing?
Post 07 Oct 2012, 22:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20520
Location: In your JS exploiting you and your system
revolution 08 Oct 2012, 01:53
nmake wrote:
Can you give an example of using namespace?
http://board.flatassembler.net/topic.php?t=14608
nmake wrote:
I am confused about local labels in macros. Am I forced to use double-dots?

Code:
macro fastmessage [msgstring]
{
        local ..label
        jmp ..label
        A=$
        db msgstring,0
        ..label:
        invoke MessageBox,[hwnd],A,A,MB_OK
}
    
local makes each name name unique so there is no need to use double or single dots if you don't want to. The only difference is whether you want the label to be a new base name or for subsequent labels with single dots.
nmake wrote:
Quite a few questions today. hehe. Why do some programs use this:
Code:
somevar dd ?    
and some programs use
Code:
somevar rd 1    
Isn't both doing the same thing?
Same thing, doesn't matter which you use.


Last edited by revolution on 08 Oct 2012, 13:20; edited 1 time in total
Post 08 Oct 2012, 01:53
View user's profile Send private message Visit poster's website Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 08 Oct 2012, 11:46
revolution, I have previously been coding direct3d9 in masm and I had the include files for it but the only include files for d3d9 i've found for fasm i found it in _FASMW64_3-28-2012.zip but it doesn't work if you don't use the entire package at once, which I don't want to do. If I copy the include files from that package into my fasm folder, they contain many inconsistencies and refuse to compile. Do you know where I can find pure and clean d3d9 include and equate files for fasm only? Google is not much help here.
Post 08 Oct 2012, 11:46
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20520
Location: In your JS exploiting you and your system
revolution 08 Oct 2012, 13:20
This maybe?

https://encrypted.google.com/search?num=100&as_qdr=all&gbv=1&q=site:board.flatassembler.net%20d3d9

If you posted some code someone might be able to help you to get it working.
Post 08 Oct 2012, 13:20
View user's profile Send private message Visit poster's website Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 08 Oct 2012, 17:07
There were two zip files in that thread, I downloaded both and settled for the zip file called d3d9.zip as it was newer and seem to contain an example which is useful. Tell me if I should use the other one instead because I have no idea what the difference is between the two, they are both created by two different individuals and they seem to contain more or less the same data in the include files.
Post 08 Oct 2012, 17:07
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 08 Oct 2012, 17:38
If you have 2 different kind of work-sets to do in your program. Would you recommend creating 4 new threads for each work-set or do you recommend creating only 4 threads in total and do both work-sets in each thread? Do you recommend creating 4 separate threads for each new work set? When is too many threads too many? When you are done executing one work set, you sleep the threads of course using a mutex or some other synchronization object. But do you recommend creating 16 threads if you have 4 different kind of work-sets?

Assuming you have 4 cores in your processor.
Post 08 Oct 2012, 17:38
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 08 Oct 2012, 22:14
I would be happy to also find the include files for d3d9x, the extension library to d3d9, used for loading textures from files, sprites etc. Smile if anyone know where to find them.
Post 08 Oct 2012, 22:14
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1694
Location: Toronto, Canada
AsmGuru62 09 Oct 2012, 14:31
What I often see in multi-threading products is the ability to set the number of worker threads
by a command line parameter (or with GUI 'Options' dialog), so it will be flexible and on more cores
the product can run with more threads.
Obviously, running with a lot of threads on one core is counter productive, because
of thread switching overhead.
Post 09 Oct 2012, 14:31
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6  Next

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.