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