flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fasmg] make DB, obfuscate (why?)

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 3387
Location: vpcmipstrm
bitRAKE
Code:

; Make data statements from file (don't use this).

if definite FILE
virtual at 0
        DAT::
        file FILE
        BYTES := $
end virtual

db '; ',FILE,13,10
repeat 1,D:BYTES
        db 'label dat:',`D,13,10
end repeat
db 'db \',13,10
data_dump BYTES,,db

calminstruction hex_nibble digit*, command: display
        compute digit, 0FFh and '0123456789ABCDEF' shr (digit*8)
        arrange command, command digit
        assemble command
end calminstruction

define _db
calminstruction data_dump bytes*, i:0, cmd:display
        local awk, digit
jj:     arrange         awk, =load =_db:1 =from =DAT:i
        assemble        awk
        arrange         awk, cmd '0x'
        assemble        awk
        compute         digit, (_db shr 4) and 0Fh
        call            hex_nibble, digit, cmd
        compute         digit, _db and 0Fh
        call            hex_nibble, digit, cmd
        compute         i, i + 1
        check           i = bytes
        jyes            done
        arrange         awk, cmd ','
        assemble        awk
        check           i and 0Fh
        jyes            jj
        arrange         awk, cmd '\',13,10
        assemble        awk
        jump            jj
done:   arrange         awk, cmd 13,10
        assemble        awk
end calminstruction

else
        display 'usage: fasmg -i "define FILE ''<filename>''" ',__FILE__,' <outfile>'
end if    

_________________
¯\(°_o)/¯ unlicense.org
Post 11 May 2022, 18:02
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3387
Location: vpcmipstrm
bitRAKE
The nice thing about fixed VHD files is that it's just composed of a footer structure. So, the disk image can usually still be loaded into other tools. Here is a macro to build that footer structure ...

I could have opted to get rid of all the magic numbers, but this is only mildly more readable:
Code:
                virtual at $ - 512
                        footer VHD.Footer
                end virtual
                load sig:sizeof VHD.Footer.Signature from footer.Signature
                load ver:sizeof VHD.Footer.Version from footer.Version
                load met:sizeof VHD.Footer.NextMeta from footer.NextMeta
                load typ:sizeof VHD.Footer.DiskType from footer.DiskType
                if sig = VHD.Cookie \
                & ver = 0x0000_0100 \
                & met = VHD.FixedMeta \
                & typ = ((VHD.DiskType.Fixed) bswap 4)
                        FILE.BYTES = $ - 512
                else ; assume RAW disk image
                        FILE.BYTES = $
                end if    
... my intention is just to tack the footer on files - not to write additional tools for VHD.


Description:
Download
Filename: makevhd.zip
Filesize: 1.99 KB
Downloaded: 5 Time(s)


_________________
¯\(°_o)/¯ unlicense.org
Post 15 May 2022, 22:54
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.