flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How is the "load" directive supposed to work?

Thread Post new topic Reply to topic

Joined: 30 Jul 2013
Posts: 339
Location: Asia, Singapore
sid123 20 Feb 2015, 12:22

I'm currently trying to generate a basic checksum from a given range of data, (not much really, just a sum of all the bytes in that range), I've come up with a macro like this:

macro generate_checksum begin, end {
local current_pos, size, key, x
current_pos = begin
size = end - begin
repeat size
load x byte from current_pos
key = key + current_char
current_pos = current_pos + 1
end repeat
dd key

As far as I understand, the above is going to keep looping until size is 0, and keep loading a byte from "current_pos", and then add it to the key variable. Finally, it will place the checksum at that position.

Unfortunately, FASM errors out with:
flat assembler  version 1.71.22  (16384 kilobytes memory
<file name> [line]:
                load x byte from current_pos
error: invalid macro arguments.


I've checked the manual, and it says:

The load directive allows to define constant with a binary value loaded from the already assembled code. This directive should be followed by the name of the constant, then optionally size operator, then from operator and a numerical expression specifying a valid address in current addressing space. The size operator has unusual meaning in this case - it states how many bytes (up to 8 ) have to be loaded to form the binary value of constant. If no size operator is specified, one byte is loaded (thus value is in range from 0 to 255). The loaded data cannot exceed current offset.

It talks about the "current addressing space", but I'm not sure what that means.


"Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X
Post 20 Feb 2015, 12:22
View user's profile Send private message Reply with quote

Joined: 23 Oct 2009
Posts: 881
l_inc 20 Feb 2015, 12:49
Aside from having lots of deficiencies the code is incomplete, and the error message is incorrectly presented. It doesn't make sense to discuss the deficiencies without the full source code.

Faith is a superposition of knowledge and fallacy
Post 20 Feb 2015, 12:49
View user's profile Send private message Reply with quote
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 19099
Location: In your JS exploiting you and your system
revolution 20 Feb 2015, 12:52
You didn't show all your code so we don't know what you did. Naughty boy.

You can start by putting brackets around the arguments:
size = (end) - (begin)    
And then you can post your code to show us where you have used 'segment' or 'section' or 'virtual'. All of those change the addressing space.
Post 20 Feb 2015, 12:52
View user's profile Send private message Visit poster's website Reply with quote

Joined: 19 Mar 2008
Posts: 1651
baldr 20 Feb 2015, 19:59
error: invalid *macro* arguments.    
Didn't it ring the bell?
Post 20 Feb 2015, 19:59
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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.