Myke's Home Page

Book CD-ROM Home

File Copying/Harddrive Setup

Development Tools

Experiments

Projects

Useful Code Snippets and Macros

Introduction to Electronics

Introduction to Programming

Datasheets

PCBs

Links

McGraw-Hill Professional Publishing

"Arith" Experiment

This application is an extension of the Status application which was presented previously. The purpose of this experiment is to give you an idea of how the the addition and subtraction instructions work in the MPLAB IDE.

When executing the application, I recommend that you enable the "modify" dialog box in the MPLAB IDE by first Clicking on "Windows" followed by "Modify..." and moving the box to the bottom left hand corner of the MPLAB IDE desktop as shown below: Arith experiment recommended MPLAB IDE Desktop Setup

The source code is listed below, or it can be accessed from the CD-ROM by clicking Here.

 title  "Arith - Showing How Arithmetic Operations Work"
;
;  This simply supplies an "addlw" and "sublw" instruction for 
;   the user to observe how these operations execute.  
;
;  Myke Predko
;  99.12.29
;
;  Hardware Notes:
;  Simulated 16F84
;  No I/O
;
 LIST P=16F84, R=DEC
 INCLUDE "p16f84.inc"

;  Macros
ClearFlags Macro		;  Clear the Processor Status Flags
        movlw    0x0F8
        andwf    STATUS, w
        movwf    STATUS
        endm

 __CONFIG _CP_OFF & _WDT_OFF & _RC_OSC

  PAGE
;  Mainline of Arith

  org 0
Loop

 ClearFlags			;  Clear the STATUS Flags

  movlw  0x012			;  Load a Value in "w"

  nop				;  <--- Breakpoint Here for Test Execution
				;  <---  Change the contents of "w"

  addlw  0x088			;  Perform the Addition Operation

  nop				;  <--- Breakpoint Here for STATUS Check

 ClearFlags

  movlw  0x012			;  Load a Value in "w"

  nop				;  <--- Breakpoint Here for Test Execution
				;  <---  Change the contents of "w"

  sublw  0x088			;  Perform the Subtraction Operation

  nop				;  <--- Breakpoint Here for STATUS Check

  goto   Loop


  end
              

Click Here to look at the fifth experiment - MidGoto