flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > suggestion: anonymous label extension Goto page 1, 2 Next |
Author |
|
vid 26 Jan 2006, 11:50
i was also pushing Tomasz to allow also @ff (second anoymous label forward) and @bb. It would be very useful in small if-else constructs, where i everytime have to think about label name. And in some cases such constructs are inavoidable even when coing asm-style.
|
|||
26 Jan 2006, 11:50 |
|
Tomasz Grysztar 26 Jan 2006, 12:38
Inavoidable? I would recommend not using anonymous labels at all!
I will consider adding support for things like @ff or @bbb, but I'm still a bit afraid of them being overused. |
|||
26 Jan 2006, 12:38 |
|
vid 26 Jan 2006, 15:35
I didn't say aninymous labels are inavoidable, i said small if-else constructs are inavoidable. For example this from FASMLIB:
Code: ;push share mode depending on [.mode] cmp [.mode], 0 ;read jne @f push 1 ;FILE_SHARE_READ jmp .sharemode_done @@: push 0 .sharemode_done: What this block code does is clear from comment (or from preceding label in your style of "commenting"), and reader usually doesn't need to look how is it done (only what is done). So I think it generally doesn't decrease readability if you have it this way (but saves you from thinking about new names): Code: ;push share mode depending on [.mode] cmp [.mode], 0 ;read jne @f push 1 ;FILE_SHARE_READ jmp @ff @@: push 0 @@: Block is so small that scoping where @ff is no problem, and when acting outside such small block anonymous labels really shouldn't be used. Quote: I would recommend not using anonymous labels at all! Of course it will be overused, but as i said some time ago, if somebody doesn't know how to write readable code, any restricting him from doing so wouldn't help. It is like OOP, which forces you to write "proper" code, at cost of possibilities. btw, @ff and @bb are pretty enough, i can't imagine small "block" (explainable with simple-sentence comment) which would require 3 levels. And this if-else is only thing where i need 2, otherwise 1 is enough. |
|||
26 Jan 2006, 15:35 |
|
revolution 26 Jan 2006, 15:54
I like to use very short labels like ".a", ".b" etc. instead of local labels. I find that is very clear about where the code goes. So using your example it would look similar to this:
Code: cmp [.mode], 0 ;read jne .a push 1 ;FILE_SHARE_READ jmp .b .a: push 0 .b: |
|||
26 Jan 2006, 15:54 |
|
vid 26 Jan 2006, 16:38
revolution: this won't work very well in bigger procs. Image you have some 200 lines with such labelling, and then you want add something to the middle. You must get at the end of proc to look which letter to continue, or try some two-letters, whch may or may be not used elsewhere etc. It's somewhat non-systematic, which means it can work nice with small codes, but surely not in bigger.
|
|||
26 Jan 2006, 16:38 |
|
Tomasz Grysztar 26 Jan 2006, 17:03
But when you want to insert some new anonymous label in the middle of proc that is already using anonymous labels, it's even worse than that.
|
|||
26 Jan 2006, 17:03 |
|
Tommy 26 Jan 2006, 17:12
I vote for implementing @ff- and @bb-like naming support... that would be a nice addition to fasm..
|
|||
26 Jan 2006, 17:12 |
|
Tomasz Grysztar 26 Jan 2006, 17:16
But if I implement just @ff and @bb as vid proposes, I bet people will soon start to ask why @fff is not allowed.
|
|||
26 Jan 2006, 17:16 |
|
decard 26 Jan 2006, 17:22
IMHO anonymous labels are good only in some places when they are relatively close to @f or @b symbols, for example here:
Code: test eax,eax ; if eax contains NULL, then create new string jnz @f stdcall StrNew @@: In this snippet use of anonymous label is quite obvious: it is used for skipping some code (if skip is needed). I'm using them in such situations. But, when symbols like @fff or @bbbb were allowed, and used extensively, reading code would require counting (!!) @@s in order to understand what's going on. Have you ever seen any RosAsm code? It doesn't allow local names to be any identifier, but one from between 'A0'..'Z9' (or something like this). Belive me it is totally unreadable at first sight, despite it has similar opcodes. Of course I have nothing against RosAsm, but I wouldn't like fasm sources end like this |
|||
26 Jan 2006, 17:22 |
|
vid 26 Jan 2006, 17:30
Quote: But when you want to insert some new anonymous label in the middle of proc that is already using anonymous labels, it's even worse than that. I've shown you how i code. Code is divided to (mostly independent) blocks of code, each beginning with description of what that block does. So you most of time don't need to look at other code, only into block you are interested in. For me, the scope of anonymous labels will be only inside such block, for example if i need to skip 2 instructions. IT will never be used across such blocks. And i never "insert" something into block, i either "edit" it or "divide" to two (independent) blocks and insert another one between them. Quote: But if I implement just @ff and @bb as vid proposes, I bet people will soon start to ask why @fff is not allowed. Surely. Answer is: "because such complicated constructs, which such complicated branching, shouldn't be done with anonymous labels for readability of code". btw, even most of times when you need @ff are too complicated to be suitable for it, but that if-else is exception, and i hate thinking how-to-name-that-label. In my coding style, labels should be used only to mark beginning of block, not inside it. This way i have two sorts of labels, one local-to-block, and one above-block. |
|||
26 Jan 2006, 17:30 |
|
Borsuc 26 Jan 2006, 19:23
Tomasz Grysztar wrote: But if I implement just @ff and @bb as vid proposes, I bet people will soon start to ask why @fff is not allowed. ok, then just add @f3 meaning 3 labels forward, etc... i know, really bad idea |
|||
26 Jan 2006, 19:23 |
|
revolution 27 Jan 2006, 00:42
Quote: Image you have some 200 lines with such labelling, and then you want add something to the middle. Code: xor eax,eax cmp [.mode], 0 ;read setz al ;eax=1 for read, eax=0 otherwise push eax ;FILE_SHARE_READ |
|||
27 Jan 2006, 00:42 |
|
RedGhost 27 Jan 2006, 00:47
The_Grey_Beast wrote: ok, then just add @f3 meaning 3 labels forward, etc... i know, really bad idea as for a bad idea, thats along the lines of what im thinking currently like vid says, i would probably only need it for 'ff' or 'bb', but other cases going 2+ forward is a maybe i don't think the code is any less readable TBH, mostly considering about 80% of the sub-labels (of a procedure style label) i make are anonymous unless i have to name it because of the current limitation, and the only person usually reading my code is me Tomasz Grysztar wrote: But if I implement just @ff and @bb as vid proposes, I bet people will soon start to ask why @fff is not allowed. i also agree ff/bb would be a bad syntax, but if you can code a self compiling assembler in assembler from scratch, i believe you can think up a good syntax for this extension (i have faith, just check the angel in my sig ) _________________ redghost.ca |
|||
27 Jan 2006, 00:47 |
|
vid 27 Jan 2006, 09:53
revolution: but i need to think forward, i may want to add more modes. From my experiences using such non-straightforward codes leads to problem with editing code. At least you need to think longer what it does.
|
|||
27 Jan 2006, 09:53 |
|
vbVeryBeginner 27 Feb 2006, 04:03
actually, i proposed something like this before.
check this. http://board.flatassembler.net/topic.php?t=2357 the nice about jmp @f and @b is you put a @@ and two of them could reffer to it. the problem with .v1: .v2: .v3: and ... is, you need to (identify or check) on the number of that particular .v(x): in order for you to jmp. for @@: you could access it easily like @f <- u know you would jmp to/back to the next/prev @@: (@@ is big and noticeable) so. imho, jmp @fff <- actually wouldn't work or (user friendly) in long run. we want the computer able to knows (exactly) where we want to jump. but the problem is, we wish to only give it like "jmp @f" and it knows how many deepth level it needs to jmp. frankly speaking, i hate labeling. i hate to name variable, label, procedure coz it is not an easy task. i hardly satisfied with the names i gave to variable. wndH, winH, win.h, wnd.H, WND.h i predict, the next gen of assembler/compiler would be so self-aware that it knows what users mean when they put jmp @@ sorry for long nag. just my hpov. |
|||
27 Feb 2006, 04:03 |
|
vbVeryBeginner 27 Feb 2006, 04:36
i just lay down on bed and think again.
if assembler/compiler could so self-aware that it knows where to jmp... maybe u and i no need to code it anymore. lol. |
|||
27 Feb 2006, 04:36 |
|
vbVeryBeginner 27 Feb 2006, 04:45
ok, i thought of this, (a stack based idea)
Code: (0)##: (1)@@: jmp @f (2) jmp @f (3) jmp @b (1) jmp @b (0) jmp @b (0) (2)@@: @f jmp @f (4) @f jmp @f (6) jmp @o (0) <- original (3)@@: @b @b jmp @b (1) (4)@@: jmp @b (4) @f @f jmp @f (6) <- @f last at 6, wouldn't reach 7 coz 7 is ## (original point) (5)@@: (6)@@: (7)##: |
|||
27 Feb 2006, 04:45 |
|
RedGhost 27 Feb 2006, 06:20
vbVeryBeginner wrote: ok, i thought of this, (a stack based idea) might be a little hard to keep track of, but probably the best idea so far a preprocessor 'push/pop' with an invisible stack, i like it _________________ redghost.ca |
|||
27 Feb 2006, 06:20 |
|
shoorick 27 Feb 2006, 12:06
i think at least one additional kind of anonimous label would be usefull (in kind of @@@/@@f/@@b as suggested in another thread): this will let easy implement if/then/else or case switching via jumps.
|
|||
27 Feb 2006, 12:06 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.