How make a program transfer asm to hex

Status
Not open for further replies.

ss-0à

New Member
hello
i want to programming a program transfer asm file of pic 16F84 to hex file if tere is someone have an idea or know a site teach me
thank you for your help
 
thank you for your help
i think there is miss understand iwant to built my own small program to transfer asm to hex, if someone have an idea
 
thank you for your help
i think there is miss understand iwant to built my own small program to transfer asm to hex, if someone have an idea

It's called an assembler - and it's not going to be that small (not if you want it to be any use).
 
It's called an assembler - and it's not going to be that small (not if you want it to be any use).

THANK YOU Nigel Goodwin FOR YOUR REPLY
Is it yours WinPicProg ?
How can I programming such as WinPicProg?(an assembler like what you said), i want to make a program like WinPicProg but for pic 16F84 ONLY FOR THE MOMMENT Teach me how to do this?
 
Last edited:
You would need to translate the ASM into opcodes, and figure out what kind of memory you are transferring, and figure out the registers and the addresses for each one.
You would need to do code / data allocation and reference direct memory addresses for each one.
You would then need to optimise your output based on the memory stack and chip model, figure out the port / peripheral feature offset addresses.

I wrote a 16 bit dos and 32 bit win32 assembler which output to direct machine code, took me 2 years to get them both working correctly, after a lot of bits and bytes and direct, indirect, memory addressing.

I cant remember 99% of it now though!

It's too time consuming to re-invent the wheel!

Wilksey
 
THANK YOU Nigel Goodwin FOR YOUR REPLY
Is it yours WinPicProg ?
How can I programming such as WinPicProg?(an assembler like what you said), i want to make a program like WinPicProg but for pic 16F84 ONLY FOR THE MOMMENT Teach me how to do this?

WinPicProg is a programmer, NOT an assembler - the assembler is MPASM - as provided free by MicroChip. MPASM converts the source code to HEX, WinPicProg then transfers the HEX file to the target PIC.
 
If you're interested in programming your own assembler, I would recommend googling "how to write an assembler".

There is lots of information out there; one link I found quickly was this: How To Write An Assembler - comp.lang.asm.x86 | Google Groups

Ultimately, however, this is a programming question in an electronics forum--there is lots on programming in here, but mostly centred around programming microcontrollers, not necessarily programming the tools used to program microcontrollers. You may have better luck searching in some programming forums.


Good luck,

Torben
 

Thank you for these informations
you mean it's difficult to make an assembler

WinPicProg is a programmer, NOT an assembler - the assembler is MPASM - as provided free by MicroChip. MPASM converts the source code to HEX, WinPicProg then transfers the HEX file to the target PIC.

i understand now thank you , WinPicProg is a programmer and disassembler too could you tell me how make a programmer for pic16F84 only or it's difficult too


thank you Torben it's a good informations
 
Unless you understand how an assembler works, then yes, it is very very difficult to construct one.

If you can work at a very low level of code, then it is easier, it is not "simple" though.

Wilksey
 
INSTRUCTION SET SUMMARY

Each PIC16CXX instruction is a 14-bit word divided into an OPCODE which specifies the instruction type and one or more operands which further specify the operation of the instruction. The PIC16CXX instruction set summary in Table 9-2 lists byte-oriented, bit-oriented, and literal and control operations. Table 9-1 shows the opcode field descriptions.

For byte-oriented instructions, ’f’ represents a file register designator and ’d’ represents a destination designator. The file register designator specifies which file register is to be used by the instruction. The destination designator specifies where the result of the operation is to be placed. If ’d’ is zero, the result is placed in the W register. If ’d’ is one, the result is placed in the file register specified in the instruction.

For bit-oriented instructions, ’b’ represents a bit field designator which selects the number of the bit affected by the operation, while ’f’ represents the number of the file in which the bit is located.

For literal and control operations, ’k’ represents an eight or eleven bit constant or literal value.

The instruction set is highly orthogonal and is grouped into three basic categories:

• Byte-oriented operations

• Bit-oriented operations

• Literal and control operations

All instructions are executed within one single instruction cycle, unless a conditional test is true or the program counter is changed as a result of an instruction. In this case, the execution takes two instruction cycles with the second cycle executed as a NOP. One instruction cycle consists of four oscillator periods. Thus, for an oscillator frequency of 4 MHz, the normal instruction execution time is 1 µs. If a conditional test is true or the program counter is changed as a result of an instruction, the instruction execution time is 2 µs.

**broken link removed**

**broken link removed**
 
Please, pardon my ignorance, but what exactly would you like us to do with this information?

Does anybody actually think it would be worth writing an assembler for the PIC? Would anybody be interested in a "community" type project?

The 14 bit mid range is a good place to start, the high end 16 bit may take some thinking, and then theres consideration of the low end (12 bit) and if they are worth supporting.

The addresses of the registers are already mapped for you in the INC files from Microchip.

Wilksey
 
Unless you understand how an assembler works, then yes, it is very very difficult to construct one.

YES,it is very difficult i think to make an assempler ,that's mean you must build a COMPILER

Please, pardon my ignorance, but what exactly would you like us to do with this information?

I gave you this information because now i changed my mind and i want to make a disassembler and i want you to help me

my first step is i wrote a C code and then i translated it to HEX with MiKroC

code in C

Code:
void main() {
TRISB=0B00000000;
PORTB=0B00000001;
}

Code IN HEX

Code:
:020000001528C1
:0C00060083120D088A000C08820008001C
:1000120003208A110A128000840A8C0A03198D0AAD
:08002200C003031D09280800BA
:0C002A00831686010130831286001A281C
:02400E00FA3F77
:00000001FF

we know that Each PIC16CXX instruction is a 14-bit word

so we must divided the HEX code to 14BIT isn't it?
 
Last edited:
The HEX file format is explained in the MPASM helpfile, under HEX file format in the index.

Code:
This format produces one 8-bit hex file with a low byte, high byte combination. Since each address can only contain 8 bits in this format, all addresses are doubled. 

Each data record begins with a 9-character prefix and ends with a 2-character checksum. Each record has the following format: 

:BBAAAATTHHHH....HHHCC
where:

 BB  A two digit hexadecimal byte count representing the number of data bytes that will appear on the line.  
AAAA  A four digit hexadecimal address representing the starting address of the data record.  
TT  A two digit record type that will always be '00' except for the end-of-file record, which will be '01'.  
HH  A two digit hexadecimal data byte, presented in low byte/high byte combinations.  
CC  A two digit hexadecimal checksum that is the two's complement of the sum of all preceding bytes in the record.
 
Hmmmm,

Might we tell him when the assembler ( edit : or disassembler ) will be ready to use ... Microchip will have stopped its 16F84 production for a while ???

Joking ... I do not think there remain lots of 16F84 in the shops ... 16F84A, may be ...

Technically Obsolete product ... no need to dig around , if this single chip supported !!!

May be some masochist's Homework ???

Alain

Let's add some ( working ... ) old 16F84 disassemblers can be found on the WEB ...
AND of course MPLAB has an excellent disassembler ... in the Program window !!!

This said ... A dissassembler from a High level compiled file will be somewhat uneasy for understanding " compiler dedicated " registers use ...
To me ... opening the VIEW/ View assembly window of YOUR compiler ( Yess ... MikroC ! ) is a very instructive dissassembler ...

But Why make it simple , eh ???
 
Last edited:
Hmmmm,

Might we tell him when the assembler ( edit : or disassembler ) will be ready to use ... Microchip will have stopped its 16F84 production for a while ???

i choose the pic16F84 to work on it because it has only 35 Instructions



i didn't understand you very well
so the instruction Consists of 14bit that's mean 2 byte and the memory of the pic16F84 is only 8bit so the instructon divided in to 2 lines in the memory but the thing which i didn't understand is how i return the hex to assembly instruction could you explain to me how ? from the given example above
 
Last edited:
i choose the pic16F84 to work on it because it has only 35 Instructions

All the 16F series use the same 14 bit core and the same 35 instructions - use a more modern one, the 16F84 was replaced by the superior and cheaper 16F628 last century.


To return the HEX to assembler you need a disassembler, such as included in WinPicProg.

You seem totally confused about what you want to do?, and keep asking entirely different questions.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…