flat assembler
Message board for the users of flat assembler.

Index > Main > [solved] using virtual i get 'value out of range'

Author
Thread Post new topic Reply to topic
pepe



Joined: 26 Feb 2015
Posts: 18
pepe 01 Apr 2024, 12:41
Hello, kinda feeling stupid asking all the time but:
Code:
;fasm 1
output:
        dw 0 dup 0x100

virtual at 0x10000000
V::
v:
dw 0x100 dup ($)
.Size = $-$$
end virtual

repeat v.Size
load  x byte from V:v + %-1
store byte x at output+%-1        ;value out of range
end repeat
    


i get 'value out of range' at the store line.
In fact, i would like to move the load-store before the definition of the virtual block but then i get 'Symbol 'V' out of scope' (i have a bunch of these and would prefer doing all the copy ops at one place of the source and define the virtuals later, for readability)
what would be the correct way of doing this?
thx a lot,
pepe
Post 01 Apr 2024, 12:41
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 913
Location: Russia
macomics 01 Apr 2024, 13:15
Code:
;fasm 1
output:
        dw 0x100 dup 0 ; 0 dup 0x100

virtual at 0x10000000
V::
v:
dw 0x100 dup ($-$$) ; 0x10000000 + x > 0xFFFF
.Size = $-$$
end virtual

repeat v.Size
load  x byte from V: ( v + % - 1 )
store byte x at ( output + % - 1 )        ;value out of range
end repeat    
Post 01 Apr 2024, 13:15
View user's profile Send private message Reply with quote
pepe



Joined: 26 Feb 2015
Posts: 18
pepe 01 Apr 2024, 14:37
thx, macomics.
i wrote dw coz i am using fasmarm, where dw is 32bits (dh is 16bits), but yeah, for better understanding it should be dd. sorry.
doh, thx for correcting that dup, stupid mistake. Embarassed
and it effectively did the sample code work indeed, even without the parentheses.
however, now i need to find out why it does not work in my project, writing things similarly (there is no such stupid dup mistake in there Smile.

any idea how to make it work like this:

Code:

output:
        dw 0x100 dup 0

load  x byte from V:v    ; V is out of scope here
store byte x at output
;... more loads and stores to output...

virtual at 0x10000000
V::
v:
dw 0x100 dup ($)
.Size = $-$$
end virtual  
; ...more virtuals to load from ...
       


or i need move the 'output' and the copy stuff to the end of the file... Rolling Eyes
Post 01 Apr 2024, 14:37
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 913
Location: Russia
macomics 01 Apr 2024, 15:12
Code:
output:
        dw 0x100 dup 0

postpone (
    load  x byte from V:v    ; V is out of scope here
    store byte x at output
    ;... more loads and stores to output...
}

virtual at 0x10000000
V::
v:
dw 0x100 dup ($)
.Size = $-$$
end virtual  
; ...more virtuals to load from ...    
Post 01 Apr 2024, 15:12
View user's profile Send private message Reply with quote
pepe



Joined: 26 Feb 2015
Posts: 18
pepe 03 Apr 2024, 20:45
thank you for your time. I rearranged the source and moved the 'output:' and the copy macros to the end of the file, gonna keep in mind postponing for next time.
Post 03 Apr 2024, 20:45
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.