CONVERT TO BAS

Status
Not open for further replies.

stranger82

New Member
hi every one

i am a new member in this forum and begginer in microcontroller

i would like to ask how to convert from assembly lagauge to basic or c langauge
i am using MPLAB

do you have a software which run better than MPLAB

thanks for help
 
There are generally no tools for translating code between languages. Going from assembly to C or BASIC is no exception. These require not only very different instructions but different entirely coding strategies.

What DOES happen is C gets compiled into assembly instructions. So does compiled BASIC. But the reverse is not really possible on any practical level.
 
Yes, you can't recreate high level source code from the resultant assembler code, you no longer have the required information.

Think of it as an omelette! - you can't uncook and seperate the individual ingredients, and you've thrown away the egg shell so that's not even available.

What you can do is treat it as an assembler program, although compilers generally produce VERY unreadable assembler!.
 
thanks to Nigel Goodwin and Oznog for you explanation

another question if never mind

i have an assembly code for PIC16F876

can i convert the code to assembly but for PIC16F84 how?

as you know the registers are different

please help 8)
 
Conversion from 16F876 to 16F84 shouldn't be too difficult. It's only a question of searching where the registers are implemented in 84. Datasheet is very useful here. You might have a problem if you use 876s USART, because 84 doesn't have it, you will have to make a Software emulation (very slow). Also you may run out of I/Os (84 has 13 I/Os, 876 has 22 I/Os).

What is the reason to use obsolete 84 anyways? I am sure 16F628 would be more suitable (has USART).
 
As Jay says, why use the long obselete 16F84?, it was replaced last century by the higher spec and cheaper 16F628.

Obviously, a LOT depends on what facilities the 16F877 program uses, it has a great many more facilities than a 16F84 (or a 16F628).

You mention you have assembler code, was it actually generated by a BASIC compiler?, or don't you know?.

You can use my programmer software WinPicProg to dis-assemble the HEX file and provide assembler source code - you would then need to modify the source code for the new processor - not too big a job, as my dis-assembler inserts register names.

One thing you might find useful?, my tutorials include a section on changing from the 16F628 to the 16F877/6 - as you will see the changes required are quite small.
 
As you mentioned jay i should look at the registers and change the values 16F628 is better

thanks Nigel. your homepage helped me alot specially tour program
but if there is a prog which can change the registers directly would be much better

last question mr. Nigel

can you change the code written in C or basic to assembly?

i am very happy to be with you scholars
 
stranger82 said:
As you mentioned jay i should look at the registers and change the values 16F628 is better

thanks Nigel. your homepage helped me alot specially tour program
but if there is a prog which can change the registers directly would be much better

The registers should be given their names by my disassembler, so when you reassemble it for the new processor they should be correct - the few changes required (not registers) are mentioned in the tutorial (for 16F877 and 16F628, for a 16F84 check the program memory start address!).

If the code isn't long, try posting it here - use the CODE button to surround it, so it formats correctly.

can you change the code written in C or basic to assembly?

It's called a compiler - but the source code tends to be specific to the compiler it was written for.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…