PDA

View Full Version : Newbie Question - Info Please



ehoskins
- 29th September 2006, 18:01
Just starting to get involved with programming PICS, actually first time programming anything and dived in to start work with PIC Basic. (If I tried working in Assembler I would be sure to fail. That stuff is total gobbledegook to me). So here's the question. I have an understanding of the process of going from BASIC a high level language to an Assembler file that gets assembled and converted into an object file (Intel Hex). But what are all the different files you can get that are associated with the assembler? You get an ASM file, a LST file and a MAC file. I'm I correct that the LST file is what a programmer would type in if he was programming in Assembler level language? So what do the ASM and MAC files do? Sorry to be so dense but I really am new at this and want to learn so if someone is willing to spend a little time giving the background on these definitions it would be appreciated.
TIA

sayzer
- 29th September 2006, 19:11
Hi ehoskins,

I have been using only HEX file and never ever needed to know about the others; and I have been able to accomplish quite succesfull projects without knowing anything about them. I do not think that I will also ever need to know about them.

But, if of course someone explains what they are, the information will be somewhere in my mind.

ErnieM
- 29th September 2006, 22:19
OK, ready? Here we go:

The compiler (PBP itself) makes:

The .asm file is how the program would look if you wrote it in assembler yourself. That's one thing the compiler generates for you. The next is:

The .mac file, basically a collection of macros that the .asm file needs. A macro is a canned set of insteuctions that an assembler can use to look up sections of code.

These are then handed off to the assembler. I use Microchips assembler, I understand that ME Labs provides one also (that may be faster), but I like to be extra careful and use the manufacturer's (as some of my work gets used in patient connected medical devices, I need to be extra sure).

The .hex file is a map of the program memory, plus any special locations (such as config bits), and EEPROM values if you used any.

The .lst file is the listing of the .asm and .mac code, every line of memory and every register used in the machine code program.

The .cod file contains symbol and debug info. You can use that in MPLAB along with the .hex file to get a pretty good picture of the maching code itself. IMPORT both those files and the simulator in MPLAB will then run a simulation of your code and let you know the lables and register names you're using.

ehoskins
- 29th September 2006, 23:54
ErnieM. That's terrific. What a great summary!
So at the end when you mention you can do importing into MPLABS to get a pretty good picture of the machine code, the machine code I presume is the binary 1's and 0's? I always thought the HEX code was a hexadecimal notation version of the binary info the machine runs on. NO? I must be missing something then? After all the HEX code gets transferred to the chip memory but is that not the binary program the machine runs on?

ErnieM
- 2nd October 2006, 14:50
[quote]I always thought the HEX code was a hexadecimal notation version of the binary info the machine runs on. NO? I must be missing something then? After all the HEX code gets transferred to the chip memory but is that not the binary program the machine runs on?[quote]

YES! They are two ways of saying the same thing.

HEX notation is usefull to humans who don't read binary very efficiently, but can read HEX fairly well. HEX numbers and binary numbers have a 1 to 1 corrospondance, so they are two ways of saying the same thing.

HEX can only express binary digits 4 bits at a time, so one hex represents 4 binary digits, 2 hex digits represent 8 binary digits, and so on

The only exception to this is PIC instructions are 14 bits long, so they need a 4 digit hex number to represent them; 4 hex digits is 4x4=16 bits for 2 extra bits at the top end, so any instruction in hex will never be larger then 7FFF

(The actual largest instruction is 7EFF, which is ADDLW H'FF', or add literal to W. The instruction set actually gives the 7th bit as a don't care (1 or 0), but also says 0 is prefered there, and that is what the compiler will give.) (I know cause I just tried it.)