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

"VarMani" Experiment

This experiment demonstrates the different ways in which simple variables can be accessed in the PICmicro MCU. Arrays and sixteen bit variables are manipulated in later experiments and projects.

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

 title  "VarMani - Variable Manipulation."
;
;  This Program is meant to be run in the Simulator to show how
;   Variables can be manipulated and accessed.
;
;  Myke Predko
;  96.05.08
;
;  99.11.01 - Updated for MPLAB
;
;  Hardware Notes
;  Simulated 16F84
;  No I/O
;  Use "varmani.pjt" along with "varmani.wat"
;
  LIST P=16F84, R=DEC
  INCLUDE "p16f84.inc"

;  Registers
 CBLOCK 0x020
i, j
 ENDC

 __CONFIG _CP_OFF & _WDT_OFF & _RC_OSC

  PAGE
;  Mainline of VarMani

  org 0

  movlw  3                      ;  Initialized the Variables
  movwf  i
  movlw  5
  movwf  j

;  i = i + 1  -  Show how a Register is Incremented, the Result Put Back

  incf   i, f                   ;  Increment and Store the Result

;  j = i + 2  -  Now, Add two to a Register and Store it in another one

  movlw  2                      ;  Get the Value to Add
  addwf  i, w                   ;  Add the Register to it
  movwf  j                      ;  Store the Added Value

  movf   i, w                   ;  Now, do the Addition a different way
  addlw  2                      ;  Load then Add, opposite to above
  movwf  j

;  if ( i == j ) then i = i + 1  -  Do a simple Comparison with an Add

  movf   i, w                   ;  Subtract i from j and if the result
  subwf  j, w                   ;   is equal to zero, increment i
  btfsc  STATUS, Z
   incf  i, f

Finished                        ;  Finished, Just Loop Around Forever
  goto  $


  end
              

Click Here to look at the ninth experiment - VarArray