
TO WORD WRAP THIS TEXT:

Click Edit on this screen's above toolbar and then click on Word Wrap.


TK3 TASM TO MPASM CONVERSION NOTES - 01AUG04

Some of this information updates that given in the published EPE TK3 text.

Always check the Updates file for any information that affects these notes. It is normally issued whenever an update to TK3 is released and is accessible via the "Latest Updates" button at the bottom of the main TK3 screen.

TASM ASM TO MPASM ASM CONVERSION

In essence there is little difference between TASM and MPASM ASM dialects. They both use the same codes as specified in Microchip's data sheets for devices such as the PIC16x84, PIC16F87x and PIC16F62x families. The principal difference is in the way that numerical values are expressed, although other minor differences exist as well. The following examples illustrate the different grammar for which TK3 translates:

	TASM		MPASM

Decimal	153		D'153'
Hex	$2B		H'2B' or 0x2B
Binary	%10010110	B'10010110'
ASCII	'C'		'C' or A'C'
Octal	-		O'777' (not recognised by TK3)

	.EQU		EQU (with/without decimal point)
	.ORG		ORG (with/without decimal point)
	.END		END (with/without decimal point)
	LABEL:		LABEL (with/without colon)

Note that TK3's TASM ASM to MPASM ASM conversion does not claim to offer full compatibility with all MPASM's requirements. If statements occur in converted files which MPASM does not recognise, it is up to the user to translate them to a form that MPASM does recognise.

Be aware that some words or letters which might be used in TASM-based files, for labels or equates for instance, may be reserved words in MPASM. For example TITLE is an MPASM reserved word and if used as a label in TASM, might not be accepted by MPASM. The letter B on its own as an equated name might also not be accepted by MPASM.

Following conversion of a file from TASM to MPASM, and its subsequent assembly through MPASM/MPLAB, examine MPASM's List and Error files for any reported errors, then examine the converted ASM file to establish what you need to modify. It is up to you with your knowledge of MPASM/MPLAB, to finalise the conversion satisfactorily.

In most cases you can normally ignore MPASM's Message and Warning reports; it is basically MPASM's Error reports that need concern you.

It is likely that you will need to amend the name of converted files. Some versions of MPASM have a file name length restriction of 8 characters, plus .ASM extension. Many ASM conversion file names created via TK3 are in excess of that length, and so may need shortening - to whatever name you prefer.

********************

TASM OBJ TO MPASM HEX CONVERSION

TASM OBJ (Object) files are converted to MPASM HEX files as literal translations. The OBJ codes are each held as 2-byte binary values, sequentially in the file, and are not directly readable through text editors, since any value between 0 and 255 decimal can occur. They do not hold addressing, identity or check sum values.

MPASM HEX files are formatted in what is known as the Intel style (believed to be known as INHX8M), in which address and other formatting values are included and can be read via a text editor. They are formatted so that several commands are sequenced on the same line, with the structure as for the following example (the spaces between the letter groups are omitted in actual hex files):

:NN AAAA RR MMLL MMLL MMLL MMLL CC TT

in which

":"      = record start character
"NN"     = byte quantity in line as hex value
"AAAA"   = address of first byte in hex *
"RR"     = record type in hex (normally 00 except for last which is 01 - see below)
"MMLL"   = data bytes in order of MMLL in hex
"CC"     = Check Sum in hex
"TT"     = line terminator (carriage return, line feed)

Checksum is calculated as:

Sum      = byte count + address hi + address lo + record type +
           (sum of all data bytes on the line)

Checksum = (-Sum) AND 255

* The AAAA address value is twice that of the actual command count address.

There can be more data values held on each line than are shown here, TK3 normally uses 16 per line when compiling hex files, in common with most assemblers.

Note that other versions of hex files exist in which the data is held in a different order. For example, whereas for MPASM the above MMLL bytes are held in order of MSB/LSB, they might be held in order of LSB/MSB in some other types of hex file. For example, whilst TASM HEX files have never been documented in EPE, the original TASM assembly software used for the EPE Simple PIC Programmer of 1996, PIC Tutorial of Mar-May 1998, and the current (as at April 2001) PICtutor CD-ROM, could be told to generate them, in which the byte order is LSB/MSB.

Only hex files in the MPASM/Intel format can be processed by TK3.

Also note that although TK3 generates the check sum when compiling hex files, it does not use the check sum when sending hex file data to the PIC - all HEX files are assumed to hold the correct data, as are all OBJ files.

It has come to light that some other record types exist (see "RR" above) - thank you originally to Malcolm Wiles. Peter Hemsley clarifies by saying that:

   00 = Data record
   01 - End of file record
   02 - Segment address record
   04 - Linear address record

and that "the last two types are concerned with 32-bit addressing and are not used in INHX8M format files". Thank you Peter!

When you view the OBJ data through the associated screen button, it is a decimalised version of the binary data you are examining, since binary data cannot be correctly viewed via a text editor. This decimalised data is not intended for editing or PIC programming use.


ADDING YOUR OWN NOTES

These notes are displayed via an "Active" text editor and you may add your own notes to them, saving them to disk in the usual way.
