flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > fasmg question how transform output?

Author
Thread Post new topic Reply to topic
Pashkov



Joined: 02 Dec 2023
Posts: 3
Pashkov 02 Dec 2023, 14:03
Is there a way to take all the previously generated data and transform it?
Like that
Code:
macro format.xorer?
        local code
        code::
        
        postpone
                restartout
                pos=0
                repeat sizeof code
                        load by:byte from code:pos
                        db by, by xor pos
                        pos = pos + 1
                end repeat
        end postpone
end macro

format xorer

org 0
        data_section:
        rb 256
        code_section:

section 0x0000
        db 12
        db 32 + data_section

section $+code_section
        dw 123 + $
    
Post 02 Dec 2023, 14:03
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 02 Dec 2023, 16:46
ORG and SECTION begin new addressing spaces, and the "code::" label applies only to the first one of these areas.

You could try something like:
Code:
macro format.xorer?
        local code
        postpone
                load code.content:$% from :0
                virtual at 0
                    code:: db code.content
                end virtual
                restartout
                repeat sizeof code, pos:0
                        load by:byte from code:pos
                        db by, by xor pos
                end repeat
        end postpone
end macro    
But if your data length does not actually change, I recommend to just rewrite it in place:
Code:
macro format.xorer?
        local code
        postpone
                repeat $%, pos:0
                        load by:byte from :pos
                        store by xor pos:byte at :pos
                end repeat
        end postpone
end macro    
Post 02 Dec 2023, 16:46
View user's profile Send private message Visit poster's website Reply with quote
Pashkov



Joined: 02 Dec 2023
Posts: 3
Pashkov 02 Dec 2023, 17:17
Thanks. Load from nothing is interesting.


SIZEOF doesn't work on label.
Fixed code
Code:
macro format.xorer?
        local code
        postpone
                load code.content:$%% from :0
                virtual at 0
                    code:: db code.content
                    code.length = $
                end virtual
                restartout
                repeat code.length, pos:0
                        load by:byte from code:pos
                        db by, by xor pos
                end repeat
        end postpone
end macro 
    
Post 02 Dec 2023, 17:17
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 02 Dec 2023, 17:33
Pashkov wrote:
SIZEOF doesn't work on label.
It should work. I tested my macro before posting, and the size was processed correctly there. Perhaps you have something else interfering?
Post 02 Dec 2023, 17:33
View user's profile Send private message Visit poster's website Reply with quote
Pashkov



Joined: 02 Dec 2023
Posts: 3
Pashkov 03 Dec 2023, 13:00
Problem finded in versions. I used jz27. SIZEOF return 0. After update to k4v8 SIZEOF work normaly
Post 03 Dec 2023, 13:00
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8354
Location: Kraków, Poland
Tomasz Grysztar 03 Dec 2023, 13:47
This feature was added in k0v2.
Post 03 Dec 2023, 13:47
View user's profile Send private message Visit poster's website 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.