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

"SmallTbl" Experiment

Due to the program memory organization of the low-end PICmicro® microcontrollers, tables are limited in size to 255 (at most) entries. In this experiment, the maximum size of the low-end PICmicro table is demonstrated along with what happens when execution goes over the first 256 instruction boundary.

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

 title  "SmallTbl - Low-End Table Calling."
;
;  In this Application, A Page 1 Table Read
;   is Implemented on a Low-End Device
;
;
;  99.12.13 - Created for the Second Edition
;
;  Myke Predko
;
  LIST P=16C56, R=DEC
  INCLUDE "p16c5x.inc"

;  Registers
 CBLOCK 0x010
i, Dest:4                       ;  Variables for Use with Monitoring the Table
 ENDC

 __CONFIG _CP_OFF & _WDT_OFF & _RC_OSC

  PAGE
;  Mainline of SmallTbl

 org     0

  clrf   Dest                   ;  Clear Destination for Each Execution
  clrf   Dest + 1
  clrf   Dest + 2
  clrf   Dest + 3

;  Table Read, Get values in the Table in Page 1 until they equal Zero.

  clrf   i                      ;  Use "i" as the Index
  movlw  Dest + 3		;  Point to the Destination
  movwf  FSR                    ;  Look at FSR after this Instruction
Table_Loop                      ;  Loop Around Here until finished
  movf   i, w                   ;  Get the Index into the Table
  incf   i, f                   ;  Increment the Table Index
  call   Table                  ;  Call the Table
  iorlw  0                      ;  At Table End?
  btfsc  STATUS, Z    
   goto  Table_Skip
  movwf  INDF                   ;  No - Store the Returned Value
  decf   FSR, f			;  Point to Next Position in "Dest" Array
  goto   Table_Loop            
Table_Skip

  goto   $                      ;  All Done, Go to Infinite Loop

 org     0x00FB                 ;  Table in Page 0
Table                           ;  Change "org" to 0x00FB 
  addwf  PCL, f
  dt     "TAB1", 0


  end
              

Click Here to look at the seventeenth experiment - StateMC