flat assembler
Message board for the users of flat assembler.

Index > Main > The final product code

Author
Thread Post new topic Reply to topic
Mino



Joined: 14 Jan 2018
Posts: 163
Mino 24 Feb 2018, 15:12
Hello Smile ,
I have 3 questions, but I'm only going to create one post, because they are more or less related (I think). So without further ado:

    - What are "passes"? I mean, when we compile, a small dialog box (under the fasm IDE) displays us, for example: "2 passes, 1536 bytes". I would like to know exactly what these passes are.
    - How do I retrieve the final code that was produced by the compiler (if I'm not mistaken, it's x86-64, or directly from "binary"instructions)?
    - How to make variables ('. data' section) belong to a label? So that they can't be used any other way? This question is to my liking, the most "eccentric", but basically: I would like to see if it is possible to do as in the higher-level languages, create a variable/block membership (labels in this case).


I already thank you for your help:)
Have a pleasant end of the day!

_________________
The best way to predict the future is to invent it.
Post 24 Feb 2018, 15:12
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 25 Feb 2018, 10:51
Mino wrote:
What are "passes"? I mean, when we compile, a small dialog box (under the fasm IDE) displays us, for example: "2 passes, 1536 bytes". I would like to know exactly what these passes are.

http://flatassembler.net/docs.php?article=manual#1.1
http://flatassembler.net/docs.php?article=design
https://en.wikipedia.org/wiki/Multi-pass_compiler

Mino wrote:
How do I retrieve the final code that was produced by the compiler (if I'm not mistaken, it's x86-64, or directly from "binary"instructions)?

Disassemble the output, I guess.
Post 25 Feb 2018, 10:51
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 25 Feb 2018, 10:58
ManOfSteel wrote:
Mino wrote:
What are "passes"? I mean, when we compile, a small dialog box (under the fasm IDE) displays us, for example: "2 passes, 1536 bytes". I would like to know exactly what these passes are.

http://flatassembler.net/docs.php?article=manual#1.1
http://flatassembler.net/docs.php?article=design
https://en.wikipedia.org/wiki/Multi-pass_compiler
I have recently written a short text that discusses the multi-pass assembly in detail: https://board.flatassembler.net/topic.php?t=20249
Post 25 Feb 2018, 10:58
View user's profile Send private message Visit poster's website Reply with quote
Mino



Joined: 14 Jan 2018
Posts: 163
Mino 25 Feb 2018, 11:59
Thank you very much for your links, I have now understood the principle of multiple pass compilation.
Otherwise, for the disassembler, it doesn't really correspond to my needs, but it's true that I can deal with it.
PS: You still don't have any ideas for variable belonging to a label Very Happy ?
Post 25 Feb 2018, 11:59
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2568
Furs 25 Feb 2018, 13:20
Mino wrote:
PS: You still don't have any ideas for variable belonging to a label Very Happy ?
There is no such thing. A label is just a reference to a memory location, it doesn't exist in the compiled executable. (you won't see it when disassembled, probably the disassembler will give you a "placeholder" label, with a generated name like L42)
Post 25 Feb 2018, 13:20
View user's profile Send private message Reply with quote
Mino



Joined: 14 Jan 2018
Posts: 163
Mino 25 Feb 2018, 14:56
Yes, indeed, after a disassembly of the executable, the label does not exist, as you said, it is only a "marker" of position in the memory. But I'd like to know if there's a trick to make it look like it is.
After that, I could probably do it, but in a pretty "poofy"way. That's why I would like to know if there is a standard, or a better way to achieve a similar result:)
Post 25 Feb 2018, 14:56
View user's profile Send private message Reply with quote
donn



Joined: 05 Mar 2010
Posts: 321
donn 25 Feb 2018, 15:00
There is also the LISTING.inc tool in the fasm TOOLS dir, may provide some more insight. The README provides a description of LISTING.inc and its usage.
Post 25 Feb 2018, 15:00
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 25 Feb 2018, 17:12
Quote:
PS: You still don't have any ideas for variable belonging to a label


Code:
Label1:
    .myLabel dq 0
Label2:
    .myLabel dd 4

mov rax,[Label1.myLabel]
mov ebx,[Label2.myLabel]    
Post 25 Feb 2018, 17:12
View user's profile Send private message Visit poster's website Reply with quote
Mino



Joined: 14 Jan 2018
Posts: 163
Mino 25 Feb 2018, 17:35
When I do this (using a valid code), it tells me that your line 6 is an illegal instruction.
Is that normal?
Post 25 Feb 2018, 17:35
View user's profile Send private message Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 414
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 25 Feb 2018, 17:52
"rax" is 64-bit register available only in 64-bit mode. you must define bitness of code using directive "use64" (default code bitness in fasm is 16-bit).
Code:
use64
... ;your 64-bit code    

_________________
smaller is better


Last edited by CandyMan on 25 Feb 2018, 17:56; edited 1 time in total
Post 25 Feb 2018, 17:52
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie 25 Feb 2018, 17:55
Because you're using 32-bit code. Snippet above is for 64-bit. But regardless, that's what you meant by "variable belonging to a label".
Post 25 Feb 2018, 17:55
View user's profile Send private message Visit poster's website Reply with quote
Mino



Joined: 14 Jan 2018
Posts: 163
Mino 26 Feb 2018, 16:30
Thank you very much for all your answers:)
I would like to know one last thing, what changes from 16-bit mode to 64-bit mode? Apart from, of course, the use of some registers or other...
Post 26 Feb 2018, 16:30
View user's profile Send private message Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 414
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 26 Feb 2018, 17:29
Post 26 Feb 2018, 17:29
View user's profile Send private message Reply with quote
Mino



Joined: 14 Jan 2018
Posts: 163
Mino 26 Feb 2018, 17:50
Thank you for everything Smile
Post 26 Feb 2018, 17:50
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.