flat assembler
Message board for the users of flat assembler.

Index > Windows > Fastest hex text file to Byte file

Author
Thread Post new topic Reply to topic
Fastestcodes



Joined: 13 Jun 2022
Posts: 75
Fastestcodes
'00'=00h...'ff'=ffh
Post 15 Jun 2022, 22:33
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 652
Location: Russia
macomics
Code:
format binary as "bin"
virtual at 0
translate::
db $30 dup $80
.A db $0A dup $ - .A
db $07 dup $80
.B db $06 dup $ + $0A - .B
db $1A dup $80
.C db $06 dup $ + $0A - .C
db $9A dup $80
store byte $F0 at $09
store byte $F0 at $0A
store byte $F0 at $0D
store byte $F0 at $20
end virtual
virtual at 0
text::
match text, INPUT_FILE { file `text }
text.Length = $
end virtual
value = 0
index = 0
while index < text.Length
  load alpha byte from text:index
  load digit byte from translate:alpha
  if digit and $F0 = $F0
    if value and $1100 >= $0100
      db value and $FF
      value = 0
    end if
  else if digit and $80 = 0
    value = value shl 4 or digit or $100
    if value and $1100 = $1100
      db value and $FF
      value = 0
    end if
  else
    break
  end if
  index = index + 1
end while
if index < text.Length
  display "Error symbol '", alpha, "' at "
  digit = $0A
  while digit < index
    digit = digit * $0A
  end while
  while digit > 1
    digit = digit / $0A
    display (index / digit) mod $0A + $30
  end while
  display "!", $0D, $0A
  err
else if value and $1100 >= $0100
  db value and $FF
end if    
Uses: fasm ./source.asm [output] [-m limit] -d INPUT_FILE=\"<hexadec.txt>\"
or
fasm.exe .\source.asm [output] -d INPUT_FILE="<hexadec.txt>"
where:
source.asm - current code
[output] - output file name
[-m limit] - memory limit, kb
<hexadec.txt> - input: hexadecimal text
Post 15 Jun 2022, 23:13
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18846
Location: In your JS exploiting you and your system
revolution
If you have WSL then:
Code:
xxd -r -p <teh-hex-codez.txt >teh-binory-codez.bin    
Post 16 Jun 2022, 04:14
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.