EE 2361 - Lab # 2a
In the editor enter the following “boilerplate” text into your new source file:
; required "boiler-plate" (BP)
;the next two lines set up the actual chip for operation - required
config __CONFIG2, POSCMOD_EC & I2C1SEL_SEC & IOL1WAY_OFF & OSCIOFNC_ON &
FCKSM_CSECME & FNOSC_FRCPLL & SOSCSEL_LPSOSC & WUTSEL_FST & IESO_OFF
config __CONFIG1, WDTPS_PS1 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_OFF & BKBUG_ON &
GWRP_ON & GCP_ON & JTAGEN_OFF
; put the following labels in RAM
; a variable that takes two bytes (we won’t use
; it for now, but put here to make this a generic
; template to be used later).
; this will be our stack area, needed for func calls
; BP (put the following data in ROM(program memory))
;because we are using the C compiler to assemble our code, we need a "_main" label
;somewhere. (There's a link step that looks for it.)
;; --- Begin your program below here ---
Code Example X: Boilerplate for ASM-only projects
This boilerplate contains all the same functionality as our c-code boilerplate. There are calls to
supporting library definitions with .include() and #include statements. You can see the flash
configuration word declarations (__CONFIG1 and __CONFIG2). And the Clock Divider setting
of 1:1 for full 16 MIPS operation (bclr CLKDIV,#8).
Turn on RA0
In this part of the lab we will prepare a simple assembly program that turns on the RA0 pin. This
will demonstrate some basic structures of assembly code.
Just like the C-program we need to add code that configures LATA, TRISA, and
AD1PCFG registers. Remember, you can’t load an immediate directly into a general file
register (generic memory location): you must first use a special function register as a
Just for the sake of clarity, let us go look at how the C-program compiles the first few
lines of Lab 1.
If you see the Lab1 Project on the left pane, under “Projects”, Right-Click on the
Lab1 Project, and click “Set as Main”. Otherwise, just use File > Open Project to
open it. You will later go back to your assembly project.
Right-Click on Lab 1 project, click Properties, select Simulator as the target