flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Load directive

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
How do I specify the number of bytes for it to load instead of choosing from just byte/word/dword?

_________________
Post 24 Nov 2009, 10:42
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
No way... FASM doesn't have arbitrary-length compile-time variables. There was a discussion on this limitation long time ago.
Post 24 Nov 2009, 11:45
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
vid wrote:
No way... FASM doesn't have arbitrary-length compile-time variables. There was a discussion on this limitation long time ago.


Well then what happens when I put
Code:
var = 'abc'    
?

I think it makes a 3 byte long var.


I want to load a var with lengths besides 1, 2, and 4 (e.g. load var 3 from addr)... where is the discussion? Can you post a link please? Confused

_________________
Post 24 Nov 2009, 11:50
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
Code:
var: 'abc'    


It's just a pointer to the offset of 'a'.

_________________
Image
Nombre: Aquiles Castro.
Location2: about:robots
Post 24 Nov 2009, 12:00
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
ass0 wrote:
Code:
var: 'abc'    


It's just a pointer to the offset of 'a'.
Huh? What's that supposed to do? Says illegal instruction for me. Did you mean to put
Code:
var: db 'abc'    
?

That would be more analogous to store. I'm asking about load.

_________________
Post 24 Nov 2009, 12:05
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
heeh xD yeah you are rite.

[edit]
No wait!, what do u mean by load?

Because 'load' would be OS dependant to something like:

Code:
push var
call [someLoaderAPI]
    

_________________
Image
Nombre: Aquiles Castro.
Location2: about:robots


Last edited by ass0 on 24 Nov 2009, 12:55; edited 1 time in total
Post 24 Nov 2009, 12:50
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
The load directive described here.
Post 24 Nov 2009, 12:53
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
You can use something like this:

Code:
macro load_array var,src,n
 {
        rept n i:0
        \{
                match j,i
                \\{
                        load var\\#j byte from src+i
                \\}
        \}

        match i,n \{ var#_length equ i \}
 }

macro store_array var
 {
        n equ var#_length

        rept n i:0
        \{
                match j,i
                \\{
                        db var\\#j
                \\}
        \}
 }


dinp db 'my example data.'
;            ^
;          dinp+4

load_array myVar,dinp+4,5
; myVar0 = 'x'
;      1 = 'a'
;      2 = 'm'
;      3 = 'p'
;      4 = 'l'
; myVar_length = 5


gap db 'myVar = '

dout:
    db '0'+myVar_length,':'
store_array myVar
; This should print:
; myVar = 5:xampl    

Hope that helps.
Post 24 Nov 2009, 15:25
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu
Thanks Very Happy

It works perfectly.

_________________
Post 24 Nov 2009, 15:45
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number 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 GitHub, YouTube, Twitter.

Website powered by rwasa.