flat assembler
Message board for the users of flat assembler.

Index > Main > forward load

Author
Thread Post new topic Reply to topic
Feggger



Joined: 19 Apr 2006
Posts: 8
Feggger 21 Sep 2006, 12:32
It's about "load" instruction.

Code:
macro   jmp     arg
{
        jmp     arg
        load x byte from arg
        if      x = 0xEB
                load y byte from arg+1
                store byte ((arg+y)-$+2) and 0xFF at $-1
        end if
}    


This code works fine only if jmp tryes to jmp on before assembled code. I.e.
Code:
main:
        nop
l1:     jmp     main
        nop
        jmp     l1
    

This will produse jmp on main, not on l1.

But if i try to do "forward" jmp
Code:
main:
        jmp l1
        nop
l1:     jmp l2
        nop
l2:     hlt
    
- I have an error. "error: value out of range."

I think, that if I will detect first assemble pass, and on this pass I simple do jmp arg, but on next pass I do load - it will be work. Is it correct?

And how i can detect first assembly pass?
Post 21 Sep 2006, 12:32
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 21 Sep 2006, 12:42
You can only load from the code already generated in current pass, thus you cannot load the values of instructions that are later in code.
Post 21 Sep 2006, 12:42
View user's profile Send private message Visit poster's website Reply with quote
Feggger



Joined: 19 Apr 2006
Posts: 8
Feggger 21 Sep 2006, 13:57
Thank you.
Post 21 Sep 2006, 13:57
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.