Qbasicnews.com
Convert x86 Assembly Code to QBasic - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: QbasicNews.Com (http://qbasicnews.com/newforum/forum-3.html)
+--- Forum: Challenges (http://qbasicnews.com/newforum/forum-10.html)
+--- Thread: Convert x86 Assembly Code to QBasic (/thread-7909.html)



Convert x86 Assembly Code to QBasic - JasonSG - 08-18-2005

Challenge:
Create a program to take a file written x86 Assembly Language and convert it to a QBasic .bas file.

Requirements:
  • accept any ASCII format text file
  • outputs an ASCII format file (with either .txt or .bas extension)
  • supports all commands in the x86 assembly language
  • will use Call Interrupt for any code not recognized as QBasic based
  • must be written in QB (not FB)

Judging is based on similarity to the origional .bas file.

If you want a refrence for what QB keywords translate into what asm commands, compile a program with the /zi option, put cv.exe in the same folder as the compiled .exe, go into command prompt, use chdir to change the directory to the one that your program is in, and type "cv [progname]" where [progname] is the name of your program (with the .exe extension).


Convert x86 Assembly Code to QBasic - DrV - 08-18-2005

That's rather impossible - QB statements usually don't translate into just one assembler instruction, and QB only uses a small subset of the possible range of x86 instructions.


Convert x86 Assembly Code to QBasic - JasonSG - 08-18-2005

Anything that wasn't generated by QB could be placed into QB by using DATA, READ, and CALL INTERRUPT, right? And wouldn't the same set of QB commands always translate into the same set of assembler instructions, and wouldn't the reverse be true too? If not, how does the QB compiler work?


Convert x86 Assembly Code to QBasic - relsoft - 08-18-2005

debug.com


Convert x86 Assembly Code to QBasic - JasonSG - 08-18-2005

The idea still holds, if it can be done, the reverse should be able to be done (at least in this case--I think). However command.com assembles the code from the .bas file, the reverse should be able to be done, at least to some extent. You should be able to take qb generated assembly code, and turn it back into qb commands, right?


Convert x86 Assembly Code to QBasic - Moneo - 08-19-2005

Wrong. It's kinda like Humpty Dumpty...... and all the kings horses and all the kings men cannot put Humpty Dumpty together again.

In a university research enviromment, given enough time and resources, you could conceive of this kind of reverse-engineering project being achieved. But it is definitely not material for a challenge on this forum to be implemented by one person in a finite amount of time.
*****


Convert x86 Assembly Code to QBasic - MystikShadows - 08-19-2005

I have to agree with Moneo here. In QB all instructions are not tranlated to Assembler, but rather to B$MNEMONIC which are in themselves series of assembly code. best that could be done is a translation to those B$MNEMONICS so to speak.


Convert x86 Assembly Code to QBasic - Z!re - 08-19-2005

All variable and function names are lost when you compile in QB

DO, LOOP; WHILE, WEND; FOR, NEXT; LABEL:, GOTO all translate to almost the same.

For example:
A = 0
DO
A = A + 1
LOOP WHILE A < 10

Is equal to:
FOR A = 0 TO 10
NEXT

Or:
A = 0
Label:
A = A + 1
IF A < 10 THEN GOTO Label

Or even:
A = 0
WHILE A < 10
A = A + 1
WEND

They dont result in the same, ASM output, but you have no real way of knowing what the user did.


In the end, too much work for a challenge


Convert x86 Assembly Code to QBasic - JasonSG - 08-21-2005

Oh well. I thought it might be interesting.