flat assembler
Message board for the users of flat assembler.

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

Author
Thread Post new topic Reply to topic
sid123



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

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:
Quote:

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:
Code:
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:
Quote:

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.

-sid123

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



Joined: 23 Oct 2009
Posts: 881
l_inc 20 Feb 2015, 12:49
sid123
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
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20340
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:
Code:
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
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 20 Feb 2015, 19:59
sid123,
Code:
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.