Prior to Prior to v5.50, the MPASM header file name of few devices were in uppercase and most of them were in lowercase. On case in-sensitive OS like Windows, this was not a matter of concern. On case sensitive OS like those based on Linux, the user had to take care of matching the case of the filename used in their #include statement to that of the actual filename.
In order to maintain uniformity and avoid confusion, starting from v5.50,the names of all MPASM header file (.inc) would be in lowercase. As a consequence, assembly source files with uppercase filenames in #include statement might fail to assemble. There are two possible ways to fix this:
The recommended method is to change the filename of .inc file in the #include statement to lowercase. If the user does not wish to do this, then they can work around the issue by creating a symbolic link to the new lowercase filename from the uppercase filename. A shell script called createbackcompatiblelinks has been provided in mpasmx folder on Linux to do the same. Depending on where the user's mpasmx folder is located, root or super-user privilege might be required.
Due to the various limitations of COD format, versions 5.3 and above of MPASM do not generate COD format as the output of an absolute assembly file. COFF format replaces COD format in all cases. This should not affect ordinary users because COD format was only used by MPLAB IDE versions prior to v8.20 to display debug information. MPLAB IDE v8.20 and later recognize the COFF output of MPASM in absolute mode, and this transition should not impose noticeable change in the expected behavior of the language tool suite.
Also due to the elimination of the COD Format from MPASM ouput, and the use of COFF format instead, new flags have been added to COFF files that are generated by C18 v3.30 and MPASM v5.30. These flags are only recognized by MPLINK v4.30 and above. MPLINK v4.30 and above continue to recognize the old COFF files. However, earlier versions of MPLINK may not recognize new COFF files.
The default behavior of MPLINK does not allow defining code or data in memory address locations outside the boundaries of linker script regions. Existing projects in absolute mode that use these address spaces will encounter a linker error indicating that section '.org_xx' can not fit the absolute section. The workaround for this error is to add a new region to the default linker script to define the user defined addresses for the linker. For more information, see the MPLINK User's Guide. The default linker script is located at the LKR directory at the same location where the mplink.exe executable exists.
For example, if you see the following error message in the output window of your MPLAB IDE when building your Absolute assembly project:
Executing: "C:\MCC18\bin\mplink.exe" /p18F8527 "test.o" /z__MPLAB_BUILD=1 /o"test.cof" /M"test.map" /W /x MPLINK 4.30, Linker Copyright (c) 2009 Microchip Technology Inc. Error - section '.org_6' can not fit the absolute section. Section '.org_6' start=0x0000c020, length=0x00000006
open the file "C:\MCC18\bin\LKR\18f8527_g.lkr" in a text editor and add the line:
CODEPAGE NAME=unimplemented START=0xC000 END=0x1FFFFF PROTECTED
at line 32 after #FI and before the idlocs region.
This problem only applicable since MPLINK v4.30.
Due to a change in COFF file format, MPASM Assembler v5.00 and later will not be compatible with versions of MPLINK Linker prior to v4.00 or versions of the MPLAB IDE prior to v7.21.
MPASM Assembler v5.00 and later will have backward compatibility to earlier versions at the source level only. Any existing object files or libraries compiled with earlier versions of the tools will not link using new versions of the tools. They will need to be recompiled from source.
If the user attempts to use this release with object files or libraries compiled with earlier versions of MPLAB C18, MPLINK Linker, and MPASM Assembler, the error message that will be received will be similar to:
Error - Coff file format for 'C:\mcc18\lib/c018i.o' is out of date.
If the user attempts to use an old version of MPLINK Linker to link object files or libraries compiled with this release, the error message that will be received will be similar to:
Error - Coff file format for 'C:\mcc18\lib/c018i.o' does not appear to be a valid COFF file.
Click here for a complete listing.
THE PARTS CORRESPONDING TO THESE OPTIONS MAY NOT ALL BE COMMERCIALLY AVAILABLE.
These can be chosen through the introductory screen, on the command line, or in source file.
NOTES:
16C52
16C54
16CR54
16C54A
16CR54A
16C54B
16CR54B
16C54C
16CR54C
16C55
16C55A
16C56
16C56A
16CR56A
16C57
16CR57A
16CR57B
16C57C
16CR57C
16C58A
16CR58A
16C58B
16CR58B
16F54
16F57
16F59
MPASMWIN.EXE is the 32-bit Windows version of MPASM Assembler which is distributed with MPLAB IDE and MPLAB C18. It is supported on the following platforms (32- and 64-bit):
MPASMX.EXE is the 32-bit version of MPASM Assembler which is distributed with MPLAB X IDE. It is supported on the following platforms (32- and 64-bit):
include p16f18313.inc
__idlocs _IDLOC0, 0x0123
__idlocs _IDLOC1, 0x0678
__idlocs _IDLOC2, 0x09ab
code
.
.
end
'Instruction is not supported on this device'
For example, PAGESELW is not supported on PIC16 extended.
'STATUS register has no IRP or RP1 or RP0 bits'
_CONFIG1L, _CONFIG1H... _CONFIG4L
Config bit setting definition example:
_LP_OSC_1H
They are different from the old INC files that had:
_CONFIG0, _CONFIG1, _CONFIG2... _CONFIG4
Example:
_LP_OSC_1
_CONFIG1L, _CONFIG1H... _CONFIG4L
Config bit setting definition example:
_LP_OSC_1H
They are different from the old INC files that had:
_CONFIG0, _CONFIG1, _CONFIG2... _CONFIG4
Example:
_LP_OSC_1
EBDIS
WAIT1
WAIT0
WM1
WM0
PORTE bits removed (family does not support external memory):
ALE
OE
WRL
WRH
H'110' - H'011F' (has ram at 110-11F)
Changed __BADRAM locations:
H'18D' - H'019F'
to
H'18D' - H'018F' (has ram at 190-19F)
_CP_ALL EQU H'00CF'
_CP_50 EQU H'15DF'
_CP_OFF EQU H'3FFF'
But data sheet shows 4 options
11 = Code protection off
10 = Upper half of program memory code protected
01 = Upper 3/4th of program memory code protected
00 = All memory is code protected
The following is a list of known problems. For a list of limitations, please see MPASM Assembler Help, Troubleshooting, Assembler Limitations.
LIST P=18F452
MOVWF 0x1000
END
will assemble without warning.
U1 IDATA
X DB 1
U2 IDATA
X DB 2
CODE
MOVWF X
assembles quietly, but the definition of X which is used in the MOVWF
instruction is not well defined.
UDATA 0x124
X RES 1
CODE 0x100
DT X
will generate 0x0124 at address 0x100 instead of 0x3424 (RETLW 0x24).
#define F(X,Y) X + Y
Y EQU 2
movlw F(Y,1)
will yield movlw 2 instead of movlw 3. After Y is substituted in
place of X, it is replaced itself by the second argument upon
rescanning.
bsf ,1
END
This assembles as if "bsf 0,1" was given.
code 0
bra start
startscn code 0x100
start nop
goto $-1
bra $
end
causing a link-time error:
Error - file 'C:\test\mpasm\gotoneg1.o', section 'startscn', Symbol '_startscn_0102' is not word-aligned.
It can not be used as the target of a call or goto instruction.
org 0
bra start
org 0x100
start nop
goto $-1
bra $
end
Warning[226] C:\TEST\MPASM\GOTONEG1.ASM 8 : Destination address must be word aligned
RM MACRO Name,Size
LOCAL i =0
Name RES 0
GLOBAL Name
WHILE i <Size
Name#v(i) RES 1
i +=1
ENDW
ENDM
myuscn UDATA
RM hello,myconstsz ; Should cause an assembly error
myconstsz equ 2
CODE
lfsr 0,hello0
END
Assembly of this code causes only a warning, but MPLINK Linker gives an
error message "reloc[0] has an invalid r_symndx." while trying to
link the COFF file.
myconstsz equ 2
RM hello, myconstsz
IF (CONST)
; no ENDIF
MPASM Assembler assembles it and gives no error, only a warning.
File not found.
Any resulting intermediate or output files will not include the
portion of the file name after the first '.' For example, the file
name above may cause files named foo.ERR, foo.COD, or foo.LST to be
created.To invoke the assembler from the command line, execute either:
mpasmwin (MPLAB IDE)
or
mpasmx (MPLAB X IDE)
On a Windows system, you will then be given a GUI interface window. Help on using the interface is provided on-line. The assembler can also be invoked with parameters or through drag-and-drop. In these cases, the interface screen is not displayed and assembly begins immediately.
On a Linux or Mac system (MPASMX only), no GUI screen is displayed, but a list of command-line options is presented.
Correct any syntax problems, referring to the MPASM Assembler, MPLINK Object Linker, MPLIB Object Librarian User's Guide (DS33014) for syntax help. MPASM Assembler assembles with INHX32 as the default hex output, and generates a listing file, error file, and .COD file.
Serial EEPROM Support:
Two "processor" selections are provided to generate byte data - EEPROM8 and EEPROM16. Both generate data in terms of bytes, but EEPROM8 considers a "word" to be 8 bits wide, while EEPROM16 considers a "word" to be 16 bits wide. The "program counter" is always incremented in terms of bytes.
The default size for memory products is 128 bytes. This can be overridden by using the LIST M=<max address> directive. Note that <max address> is always evaluated as a decimal number. The header file MEMORY.INC is provided to define the maximum address for available memory devices. The format of the defined symbols is _<device>; for example, to set the maximum memory size for a 24LCS21, use the directive LIST M=_24LCS21.
The following data generation directives are supported for memory products:
DW FILL ORG
The behavior of other data generation directives is not guaranteed.
All other directives are unchanged.
An example of generating a file for programming a memory device is as follows:
;*************************************************
; Generate data for a 8-bit wide memory device.
LIST P=EEPROM8, R=DECIMAL
INCLUDE "MEMORY.INC"
LIST M=_24LCS21
#DEFINE MAX_VALUE 255
ORG 0
;-------------------------------------------------
; Create a packed-byte, null terminated string.
DW "Hello World", 0
;-------------------------------------------------
; Create data representing a line. The X position
; is implied from the position of the data in the
; device. The Y values are stored in the device.
; First, define an equation for the line.
#DEFINE Line( X ) Slope * X + Y_Intercept
; Now define the values needed for the equation.
Slope EQU 10
Y_Intercept EQU 5
; Declare and initialize the X and Y values.
VARIABLE X = 0, Y = Line( X )
; Generate values until the maximum Y value is
; reached or the device is filled up.
WHILE (Y <= MAX_VALUE) && ($ <= _24LCS21)
DW Y
X = X + 1
Y = Line( X )
ENDW
;-------------------------------------------------
; Perform some checking based on the line data
; generated above.
; If the device filled up before the end of the
; line was reached, generate an error. Otherwise,
; if the device is almost out of room, generate a
; message.
IF (Y < MAX_VALUE)
ERROR "Device is full."
ELSE
IF (($+10) > _24LCS21)
MESSG "Device is nearly full."
ENDIF
ENDIF
;-------------------------------------------------
; Fill the rest of the device with zeroes.
FILL 0, _24LCS21 - $ + 1
END
CLRW COMMAND:
The CLRW encoding was changed on all 14-bit core devices from 0x0100 to 0x0103 (v1.40 and later). This will not affect the expected operation of the instruction, but it will change the value for the instruction in the hex file and therefore the checksum.
WARNING MESSAGE:
The text for Message #302 was modified to explain more clearly that bank indication bits are stripped when assembling instructions that access file registers. The appropriate bank must be selected by the appropriate bank selection bits. For example, 14-bit core devices contain the lower seven bits of the file register address in the opcode, with two bank selection bits in the STATUS register. The message was changed from:
Argument out of range. Least significant bits used.
to:
Register in operand not in bank 0. Ensure that bank bits are correct.
END DIRECTIVE:
Take care to not use the END directive in a macro. If the END directive is encountered in a macro, it can cause the assembler to loop indefinitely. Macros should be terminated with the ENDM directive.
HIGH DIRECTIVE:
While using the assembler for enhanced mid-range devices and the HIGH directive with the movlw instruction (i.e., movlw high xx), the value returned has its most-significant bit (MSb) set if xx is in program memory. This makes it easier to read the program flash memory through the FSR by using the value loaded to the working register. However, when the HIGH directive is used with the movlp instruction, the most significant bit is ignored as the movlp instruction encodes a 7-bit wide literal.