flat assembler
Message board for the users of flat assembler.

Index > Main > flat assembler 1.73.21

Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
This version adds some missing instruction set extensions, but at the same time also brings new features backported from fasmg. It adds $% and $%% built-in variables, and a syntax variant for LOAD/STORE that allows to use output file offsets instead of addresses.

These new features can only be used with (default) binary output format. If you use FORMAT directive with anything other than BINARY setting, you are not going to be able to use them.

As a quick demonstration, this snippet reverses the order of all bytes in the assembled output file:
Code:
postpone
{
        repeat $%% shr 1
                load a byte from :%-1
                load b byte from :$%%-%
                store byte a at :$%%-%
                store byte b at :%-1
        end repeat
}    
It should work the same as in fasmg. If you change the braces to END POSTPONE syntax, you should be able to assemble it with fasmg for the same result.
Post 05 Dec 2019, 12:25
View user's profile Send private message Visit poster's website Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 314
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan
I found yet few new instructions that are still missing, such as VDPBF16PS and similar.
https://software.intel.com/en-us/download/intel-architecture-instruction-set-extensions-programming-reference

_________________
smaller is better
Post 05 Dec 2019, 18:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17467
Location: In your JS exploiting you and your system
revolution
Tomasz Grysztar wrote:
It adds $% and $%% built-in variables ...
For those that don't know fasmg's workings, what do these variables do? From the example code it looks like $%% is the emitted code length.
Post 05 Dec 2019, 19:02
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
CandyMan wrote:
I found yet few new instructions that are still missing, such as VDPBF16PS and similar.
https://software.intel.com/en-us/download/intel-architecture-instruction-set-extensions-programming-reference
I refrain from adding instructions documented as future extensions, because their details sometimes change before the finally go into the main SDMs.

revolution wrote:
For those that don't know fasmg's workings, what do these variables do? From the example code it looks like $%% is the emitted code length.
They are documented in one of the initial paragraphs of section 2.4 of fasm's manual.
Post 05 Dec 2019, 19:11
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: 17467
Location: In your JS exploiting you and your system
revolution
What is the difference between the "current offset" from $% and the "actual offset" from $%%? How does "current" or "actual" differ from the $ value?
Post 05 Dec 2019, 19:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
revolution wrote:
What is the difference between the "current offset" from $% and the "actual offset" from $%%? How does "current" or "actual" differ from the $ value?
$ is the address within the current addressing space, as defined in 2.2.4. Starting a new addressing space (with directive like ORG or VIRTUAL) changes the addressing, and $ is counting generated bytes starting from $$ within that area.

$%, on the other hand, is just the raw offset in the output, this is the offset in the output file where you're going to find the bytes that you generate at this point in program (as long as they actually go into the output - the ones in VIRTUAL block have no effect at all).

And $%% is the actual offset, that is: the number of bytes that have already been "committed" to the output. Uninitialized data (like "db ?") is normally not written into output, unless it is followed by some initialized values. $%% is therefore the offset that does not count any uninitialized data at the end of so far generated output. In fasmg this is a little more complex, with directives like SECTION also affecting these values - you can see these things explained with examples in the introductory part of my file formats tutorial.
Post 05 Dec 2019, 19:57
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: 17467
Location: In your JS exploiting you and your system
revolution
So in most circumstances $% and $%% give the same value? But when there are uninitialised data at the current position then $% and $%% will have different values?
Post 05 Dec 2019, 20:05
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
revolution wrote:
So in most circumstances $% and $%% give the same value? But when there are uninitialised data at the current position then $% and $%% will have different values?
Yes.
Post 05 Dec 2019, 20:07
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: 17467
Location: In your JS exploiting you and your system
revolution
I very happy that I finally managed to realise that "data" is a plural noun. Haha, that never made sense to me before, but now I get it.

Byte ---> bytes
Datum ---> data
But not: Data ---> datas

"Here is some data" Wrong.
"Here are some data" Correct.

[/offtopic]
Post 05 Dec 2019, 20:14
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 774
Location: Belarus
DimonSoft
Tomasz Grysztar wrote:
It adds $% and $%% built-in variables, and a syntax variant for LOAD/STORE that allows to use output file offsets instead of addresses.

These new features can only be used with (default) binary output format. If you use FORMAT directive with anything other than BINARY setting, you are not going to be able to use them.

As a quick demonstration, this snippet reverses the order of all bytes in the assembled output file:
Code:
postpone
{
        repeat $%% shr 1
                load a byte from :%-1
                load b byte from :$%%-%
                store byte a at :$%%-%
                store byte b at :%-1
        end repeat
}    

Wow, couldn’t even dream about them being backported and backported this fast. Will help me make my current project (that is planned to be finished till the end of the year) code a bit more readable.

Well, for certain definitions of “readable”, ’cause, y’know, $%%, but there aren’t much alternatives to choose from anyway that would not break some existing code somewhere. So, thanks a lot.
Post 06 Dec 2019, 07:03
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
DimonSoft wrote:
Well, for certain definitions of “readable”, ’cause, y’know, $%%, but there aren’t much alternatives to choose from anyway that would not break some existing code somewhere. So, thanks a lot.
Keep in mind that if you need just an offset in file where your piece of code/data is going to be put, you should use $%. And $%% is needed only for very specific purposes when you need to know the size of already defined data.
Post 06 Dec 2019, 13:42
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 774
Location: Belarus
DimonSoft
Tomasz Grysztar wrote:
DimonSoft wrote:
Well, for certain definitions of “readable”, ’cause, y’know, $%%, but there aren’t much alternatives to choose from anyway that would not break some existing code somewhere. So, thanks a lot.
Keep in mind that if you need just an offset in file where your piece of code/data is going to be put, you should use $%. And $%% is needed only for very specific purposes when you need to know the size of already defined data.

Yes, I looked through the docs. This one just looked a bit more bizarre.
Post 06 Dec 2019, 17:00
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
DimonSoft wrote:
Yes, I looked through the docs. This one just looked a bit more bizarre.
For syntactical symmetry it probably should have been $@% or $%@, but these just look like expletives. Wink So staying with no more than two symbols per name felt like a safer choice.
Post 06 Dec 2019, 18:24
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 774
Location: Belarus
DimonSoft
Tomasz Grysztar wrote:
DimonSoft wrote:
Yes, I looked through the docs. This one just looked a bit more bizarre.
For syntactical symmetry it probably should have been $@% or $%@, but these just look like expletives. Wink So staying with no more than two symbols per name felt like a safer choice.

What is the policy for using symbols like that? Things related to addresses and generated data seem to start with $. As far as I can tell, we only have two things starting with %: % itself in loops and %t for current timestamp—some general purpose integer stuff. Am I missing something else? @ is used in anonymous labels. But what are the rules for new features?
Post 07 Dec 2019, 17:02
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
DimonSoft wrote:
What is the policy for using symbols like that? Things related to addresses and generated data seem to start with $. As far as I can tell, we only have two things starting with %: % itself in loops and %t for current timestamp—some general purpose integer stuff. Am I missing something else? @ is used in anonymous labels. But what are the rules for new features?
The main rule is that when there already exists something with a similar function in another popular language, I try to re-use the keyword/syntax, to introduce some familiarity. I borrowed a lot from TASM, but also a few things from NASM (like $$ symbol) and even from some HLLs. And when I need to invent something completely new, I try to continue patterns of existing (borrowed) syntax. But, because borrowings came from various different languages and dialects, there are several distinct patterns with no clear super-rule above them.

All symbols starting with $ are related to current address/offset tracking. One that I could not easily backport from fasmg is $@, but all others are now shared with fasm 1.

I actually feel that %t was a wrong choice for the timestamp, and it became apparent in the fasmg's implementation, where % and %% are special parameters and %t is just a regular built-in variable. It is more akin to __SOURCE__, __FILE__ and __LINE__ - I still consider at least giving it an alias like __TIME__.
Post 07 Dec 2019, 17:35
View user's profile Send private message Visit poster's website Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 724
guignol
revolution wrote:

"Here is some data" Wrong.
"Here are some data" Correct.

[/offtopic]
here is some data is not wrong.
Post 10 Dec 2019, 17:22
View user's profile Send private message Reply with quote
Calanor



Joined: 19 Jul 2015
Posts: 1
Location: Sweden
Calanor
Thanks for the update, Tomasz! Speaking of backporting fasmg features, is there any chance that we'll get support for case-insensitive matching in fasm? That would be tremendously useful!
Post 13 Dec 2019, 09:00
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
I did not seriously consider it before. It definitely would be a challenge. I'm not saying it's impossible, though.
Post 13 Dec 2019, 09:50
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. Also on YouTube, Twitter.

Website powered by rwasa.