Created
May 11, 2022 19:30
-
-
Save bitRAKE/76a8719eeb29c983a98302322a2815f9 to your computer and use it in GitHub Desktop.
Create data statement from binary file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Make data statements from file (don't use this - just use FILE directive). | |
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 | |
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 | |
else | |
display 'usage: fasmg -i "define FILE ''<filename>''" ',__FILE__,' <outfile>' | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Potential problems with code (ignoring its overall silliness):