PIC18F4520 assembly programe error.

Thread Starter

thar07

Joined Jan 3, 2015
71
i wrote this program to toggel the output of Port d in the proteus and it is running perfectly. But when i complied it with MPASMWIN it shows the following errors. Could you please tell me what wrong with this ?


#include <p18F4520.inc>

portb equ 0xff6
trisb equ 0f93h
trisd equ 0f95h
portd equ 0xf83

org 0h
bsf trisb,0 ;make Rb0 input
clrf trisd ;make port d output
movf portb,w
movlw 55h
movwf portd

end


lst file

MPASM 02.40 Released BB.ASM 9-24-2015 7:58:14 PAGE 1


LOC OBJECT CODE LINE SOURCE TEXT
VALUE

Error[105] : Cannot open file (Include File "p18F4520.inc" not found)
00001 #include <p18F4520.inc>
00002
00000FF6 00003 portb equ 0xff6
00000F93 00004 trisb equ 0f93h
00000F95 00005 trisd equ 0f95h
00000F83 00006 portd equ 0xf83
00007
0000 00008 org 0h
Warning[207]: Found label after column 1. (bsf)
Error[122] : Illegal opcode (trisb)
0000 00009 bsf trisb,0 ;make Rb0 input
Warning[207]: Found label after column 1. (clrf)
Error[122] : Illegal opcode (trisd)
0000 00010 clrf trisd ;make port d output
Warning[207]: Found label after column 1. (movf)
Error[122] : Illegal opcode (portb)
0000 00011 movf portb,w
Warning[207]: Found label after column 1. (movlw)
Error[108] : Illegal character (5)
0000 00012 movlw 55h
Warning[207]: Found label after column 1. (movwf)
Error[122] : Illegal opcode (portd)
0000 00013 movwf portd
00014
00015 end
Error[131] : Processor type is undefined
MPASM 02.40 Released BB.ASM 9-24-2015 7:58:14 PAGE 2


SYMBOL TABLE
LABEL VALUE

portb 00000FF6
portd 00000F83
trisb 00000F93
trisd 00000F95


MEMORY USAGE MAP ('X' = Used, '-' = Unused)


All other memory blocks unused.

Program Memory Words Used: 0
Program Memory Words Free: 1


Errors : 7
Warnings : 5 reported, 0 suppressed
Messages : 0 reported, 0 suppressed
 

GopherT

Joined Nov 23, 2012
8,009
i wrote this program to toggel the output of Port d in the proteus and it is running perfectly. But when i complied it with MPASMWIN it shows the following errors. Could you please tell me what wrong with this ?






lst file
Register names are case sensitive. PORTB, TRISB
 

Papabravo

Joined Feb 24, 2006
22,082
The assembler could not find the include file which defines things. This usually happens for one of two reasons:
  1. The include file "p18f4520inc" is not located in the folder where the assembler is looking for it, or
  2. The assembler has no idea where to look for the include file.
What you need to do is review the documentation to find out how such things are done.
 
Last edited:

Papabravo

Joined Feb 24, 2006
22,082
How to correct those errors ?
How to correct those errors requires understanding what the assembler is trying to do. Understanding what the assembler is trying to do requires that you:

"... review the documentation to find out how such things are done."

which is what I told you in my previous post.

In other words you must place the include file where the assembler can find it, or you must give the assembler the path to the folder where the include file is located.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,415
Once you get the path to your include files settled your next errors will come from your list of equates. At best these will produce warnings for delicate definitions, at worst they will yield hard errors. Best remove them and let the include file do that part of the heavy lifting.

How are you using the assembler? It works easily inside MPLAB where setting like the device being used (which is in your list of errors) will be set for you when you walk thru the new project wizard.
 
Last edited:

dannyf

Joined Sep 13, 2015
2,197
PIC18F4520 assembly programe error.

Using assembly is preferred if you have lots of free time or free money, or you want to push the performance envelope.

Otherwise, it is far better to code in C.
 

dannyf

Joined Sep 13, 2015
2,197
For example, your asm code can be simply done in C as

Code:
  OUT_PORT ^= OUT_MASK; // flip out_mask
The code itself is quite self explanatory and will work for all mcus -> much more portable than your assembly.
 
Top