flat assembler
Message board for the users of flat assembler.

Index > Main > a small idea for FASM

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi,
i am thinking about expanding the @@ feature,
coz we only be able to jmp @b or @f, but usually, we wanna jmp more than that.
Code:
01: @@:
02:        jmp @f             ;will jmp to line 06
03:        jmp @ff            ;will jmp to line 10
04:        jmp @f1            ;will jmp to line 10 too
05:        jmp @fff           ;will jmp to line 14
06: @@:
07:        jmp @b             ;will jmp to line 06
08:        jmp @bb            ;will jmp to line 01
09:
10: @@:
11:
12:
13:
14: @@:
15:        jmp @bbbb          ;will jmp to line 01
16: @@:
17:        jmp @b5            ;will jmp to line 01 too
    


i don't know how fasm internally works, but i guess such approach is caching the address of @@: whenever fasm encounter it, so why don't we have a cache of 5 addresses :p

i guess the idea of using @@: is to save namespace coz maybe we just use it one time or two times, so by implementing such (idea!) i guess, we could save some unneeded or not so important naming process.


sincerely,
vbVeryBeginner d(0=0)b
Post 01 Oct 2004, 05:21
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Maybe this would make anonymous albels a bit more powerful, but think about code readability... I think that @f and @b is just enough.
Post 01 Oct 2004, 06:51
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
You should write programs instead of thinking about this.
jmp [offset] is far enough for programming
and additionally you directly tell your machine to jump to that code.

if you have an idea like that, you must been thinking of this:
jmp global.randomlabel or
jmp runtime.randomlabel
jmp label1 label2 label3 [bx] - do we need this function too?

where global.randomlabel is generated at compile time and jumps to a random label. Smile

Where runtime.randomlabel is using a table or making a randomize while your code is rrunning and jumps there.

but currently the only purpose of these functions' might be making a random thing to happen like after someone entered a wrong code in an internal use program you know Smile

MATRIX
Post 01 Oct 2004, 10:39
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
decard wrote:

but think about code readability

i did think about the issue of code readability, imho, i guess the use of jmp @@fff usually function as short jmp, (could be easily trace within 40 lines of code, about a screen page in 800x600)

fasm manual wrote:

The "@@" name means anonymous label, you can have defined many of them in the source. Symbol "@b" (or equivalent "@r") references the nearest preceding anonymous label, symbol "@f" references the nearest following anonymous label. These special symbol are case-insensitive.

i guess, the purpose of label is there to help us to get the address. to jmp easily to somewhere
Post 01 Oct 2004, 11:06
View user's profile Send private message Visit poster's website Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
S.T.A.S.
Aren't (already allowed) labels like .1 .2 .3 .... enough? Wink
Post 01 Oct 2004, 11:42
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Quote:
Aren't (already allowed) labels like .1 .2 .3 .... enough?


When did FASM start supporting lables with names like .1? Last time I tried to use them (a couple versions back), they weren't allowed.
Post 01 Oct 2004, 12:14
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
<imho>
The use of @nnonimous labels is a false timesaving feature. You save some seconds while writing them the first time because you don't need to think in a meaningful name. But you will pay it each time you access further to the source in readability and in terms of fatigue (your mind needs to process the search). But there is also a problem of reusability of the code i.e. if you cut'n paste from one place to another, you will have to revise upstream and downstream to avoid nasty bugs. Lesser risk if you have used meaningful labels.

The use of meaningful labels avoids also boring overcommented sources.
</imho>
Post 01 Oct 2004, 13:14
View user's profile Send private message Yahoo Messenger Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
IMO there are cases when anonymous labels are quite natural. See following code:
Code:
        invoke  IsDlgButtonChecked, [.hwnd],fdlgSearchInRadioID    ; search in current source file?
        or      eax,eax
        jz      @f
        jmp     .range_ok
    @@: inc     ebx
        invoke  IsDlgButtonChecked, [.hwnd],fdlgSearchInRadioID+1  ; search in whole current file?
        or      eax,eax
        jz      @f
        jmp     .range_ok
    @@: inc     ebx
        invoke  IsDlgButtonChecked, [.hwnd],fdlgSearchInRadioID+2  ; search in all opened files?
        or      eax,eax
        jz      @f
        jmp     .range_ok
    @@: inc     ebx    

it checks state of some checkboxes and sets some flags according to them. In this case anonymous labels are a natural choice, and they don't break the readability, as that distance between "@@" and "@f" is really short.
Post 01 Oct 2004, 13:23
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
Quote:

The use of meaningful labels avoids also boring overcommented sources.

i agree with you, pelaillo

Code:
jmp @ff
jmp @f3
    

i did understand this idea does has some drawback, coz we might need to modify all the jmp @f or @b when we add a new @@: between them.

i am thinking how we could solve this issue Confused until then, maybe,

decard wrote:

I think that @f and @b is just enough.


holds true Wink

sincerely,
vbVeryBeginner
Post 01 Oct 2004, 13:40
View user's profile Send private message Visit poster's website Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
S.T.A.S.
crc wrote:
Last time I tried to use them (a couple versions back), they weren't allowed.
Yes, some time ago such simbols were considered as floating-point numbers..
But later this was considered as a bug, and now it's just normal local label, starting with dot (thank to vid for pointing to this).
_______________

IMHO all these L2, ND, STRT and other weird names comes from ancient times when computers had very small amount of memory (say 32K or less) for a source file.. Of cource, @@ is useful sometimes, so it survived, but long names may work better than comments.
Post 01 Oct 2004, 14:07
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i would like allowing access to second anonymous label forward / backward.

you may use them at small if-else and loop constructs:
Code:
cmp eax,0
jz @f
call EAX_z
jmp @ff
@@:
call EAX_nz
@@:
    

or
Code:
cmp ecx,0
jz @ff ;skip loop
@@:
...
dec ecx
jnz @b
@@:
    

etc.

Assembly code is unreadable anyway, if it isn't written readable. If it is, then things like that one is more readable than with another label i think. And if someone wants to use @fffff then he wouldnt write rest of code readble anyway.
Post 04 Oct 2004, 10:28
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
But writing unreadable code shouldn't be encouraged in any way Sad
Post 04 Oct 2004, 13:28
View user's profile Send private message Yahoo Messenger Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
It was already encouraged by @F and @B. I think it is a good feature to add.
Post 04 Oct 2004, 14:17
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
vid wrote:

And if someone wants to use @fffff then he wouldnt write rest of code readble anyway.


Laughing
Post 04 Oct 2004, 15:25
View user's profile Send private message Visit poster's website 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.

Powered by rwasa.