flat assembler
Message board for the users of flat assembler.

Index > Main > Labels in procedures

Author
Thread Post new topic Reply to topic
MattDiesel



Joined: 31 Oct 2010
Posts: 34
Location: England
MattDiesel
First a quick note, I'm on holiday at the moment with my only wifi access being the occasional mcdonalds. Sorry if I don't reply immediately.

I want to create a lookup table for use within a procedure (using the win32a includes proc macro). It worked when I was not using a procedure. I have tried:
• Using the procedure name as a label, so MyProc.Label etc
• using a global label within the procedure, and also that with the proc name prepended

Thanks for any help, I could declare the lookup table inside the procedure (after the term statement would be easiest) but it's a pain that it doesn't work as I would expect.

Matt Diesel

_________________
Cogito Cogito Ergo Essum
Post 05 Aug 2011, 17:35
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
you mean
Code:
proc y
label1:
ret
enp
proc x
jmp y.label1
    
Post 05 Aug 2011, 19:21
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
mmm, odd, you should be able to define a label like ".LUT:" and use it (which would be also accessible from outside using procname.LIT), however, if it still fails then put at the beginning of the source "dummy = procname", just in case that conditional compilation is screwing things up (but everything should be OK if the LUT is accessed from the proc only).

Please post some minimal code showing the problem.
Post 05 Aug 2011, 20:58
View user's profile Send private message Reply with quote
MattDiesel



Joined: 31 Oct 2010
Posts: 34
Location: England
MattDiesel
Thanks guys, i have been testing on a small sample but I'm posting from an iPhone at the moment. Off the top of my head it's:

Code:
format PE console
Entry start

Include 'win32a.inc'

Section '.text' code readable

Start:
Call testProc.lbl
Invoke ExitProcess,0

proc testProc
.lbl:
Invoke MessageBox,0,0,0,0
Term
Endp

Section imports for user32 and kernel31
    


That won't compile as the iPhone capitalises thinking it's helping.

I'll post the exact code when I get the chance. It shouldn't matter that the proc is defined after the usage as my understanding of the fast multiuser system is that order of definition doesn't matter.[/code]

_________________
Cogito Cogito Ergo Essum


Last edited by MattDiesel on 07 Aug 2011, 14:31; edited 1 time in total
Post 06 Aug 2011, 19:59
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
MattDiesel, then if your code above is accurate enough, your problem is that you are accessing the internal label directly but never accessing the main label (testProc). Since proc macro uses conditional compilation, you don't get defined your ".lbl:" and nothing inside the proc because there is no reference to testProc. As I've told you earlier, use "dummy = testProc" to cause a reference to be detected and force the conditional compilation to include the proc's code (note that "dummy = testProc" incurs in no run-time costs as it is a compile-time only thing).
Post 06 Aug 2011, 22:09
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
what if you do this
Code:
proc x
x1:
ret
endp

proc y
call x:x1
ret
endp
    
Post 06 Aug 2011, 22:19
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Placing this macro after including the include files will disable conditional compilation (and I hope it won't introduce problems)
Code:
macro proc [args]
{
common
local ref
   match name any, args any\{ref = name\}

   proc args
}    


typedef, it doesn't even compile when "y" is referenced.
Post 06 Aug 2011, 22:28
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
^^@lol... I didn't try it at all I just thought of it. Very Happy.. Well we learned something there
Post 06 Aug 2011, 22:44
View user's profile Send private message Reply with quote
MattDiesel



Joined: 31 Oct 2010
Posts: 34
Location: England
MattDiesel
Thanks LocoDelAssembly, conditional compilation being the problem would make sense, though I had no idea that fasm had it though so it never occured to me.

I will try the dummy method and see if that works. It's not ideal as there is a reason I'm going for a lookup table rather than cmp ... je.

Matt

_________________
Cogito Cogito Ergo Essum
Post 07 Aug 2011, 14:30
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger 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.