Full Version: Convert x86 Assembly Code to QBasic
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Create a program to take a file written x86 Assembly Language and convert it to a QBasic .bas file.

  • 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).
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.
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?
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?
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.
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.
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
A = A + 1

Is equal to:
FOR A = 0 TO 10

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

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

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
Oh well. I thought it might be interesting.