Author Topic: Axe-Storing Hex to string  (Read 2666 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Axe-Storing Hex to string
« on: August 29, 2010, 05:55:26 pm »
How exactly, in Axe, would I be able to get the hex that makes up an asm executable and output it into a string, a string which I would then be free to copy into a new program or appvar or use in some other manner. You can post code here, as this has nothing to do with any contest.

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Axe-Storing Hex to string
« Reply #1 on: August 29, 2010, 08:37:16 pm »
I assume it would be done like this, though i haven't tested it.

Code: [Select]
"0123456789ABCDEF"->Str1
GetCalc("prgmASM")->P  .P is a pointer to the start of the data of the program ASM
GetCalc("Str1",{P-2}^r*2)->S   .S is a pointer to the start of the data of OS var Str1
For(Z,0,{P-2}^r-1
{{P+Z}->A/16+Str1}->{Z*2+S}
{A^16+Str1}->{Z*2+1+S}
End

know that i'm not 100% sure this will work.. it should probably be tested on an emulator first. i tested it on a few basic programs though, which came with seemingly correct results. with a basic program having only 01234 as its first line, my program gave me the string 3031323334, which are the ASCII character codes of 0-4.

edit: this didn't work for an asm program i had. it might be better just to give the asm program an axe header, use axe's back-up feature to make an appvar of the program. then you have it in an appvar for your use.
« Last Edit: August 29, 2010, 09:42:45 pm by nemo »


Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Axe-Storing Hex to string
« Reply #2 on: August 30, 2010, 08:16:21 am »
Well, actually, what I'm going for is a conversion utility. I know that some people, including myself, have had circumstances in which typing in hex by hand is their only feasible option in running assembly. I'm trying to make a utility that takes any program and displays its hex, so that I can, say, tell a friend what to type in to a program.

But thanks for that.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Axe-Storing Hex to string
« Reply #3 on: August 30, 2010, 01:27:04 pm »
Here's what I have so far. You input the file name (MUST INCLUDE THE TOKEN) and it gives you a byte-by-byte of the variable.