CCS PCW C Compiler, Version 2.636, 5783
Filename: D:\PIC_CO~1\PICC\SRC\BUGCHE~1.LST
ROM used: 166 (16%)
166 (16%) including unused fragments
RAM used: 21 (58%) at main() level
32 (89%) worst case
Stack: 3 worst case (2 in main + 1 for interrupts)
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 05A
0003: NOP
.................... // Bugcheck
.................... //
.................... // This tests out certain instructions in the processor, which have been
.................... // reported to be BUGGY.
.................... //
.................... // Author: John Clayton
.................... // Date : 08/06/03
....................
.................... #device PIC16C84
.................... #byte stat_reg = 0x03 // Status register
.................... #byte addr_lo = 0x05 // Aux. bus address low
.................... #byte addr_hi = 0x06 // Aux. bus address high
.................... #byte data = 0x08 // Aux. bus data
.................... #byte int_reg = 0x0b // Interrupt control register
....................
.................... // Global type variables
.................... int int_count;
.................... unsigned int w_temp;
.................... unsigned int stat_temp;
.................... unsigned int addr_lo_temp;
.................... unsigned int addr_hi_temp;
.................... unsigned int count1;
.................... unsigned int count2;
....................
.................... // This functions plots a single pixel at coordinates (x,y)
.................... // color should range from 0..7.
.................... void plot(unsigned int x, unsigned int y, unsigned int color)
.................... {
.................... addr_hi = (y>>1) | 0x40;
*
001C: MOVF 28,W
001D: MOVWF 0C
001E: BCF 03,0
001F: RRF 0C,F
0020: MOVF 0C,W
0021: IORLW 40
0022: MOVWF 06
.................... addr_lo = x | (y 0023: MOVF 28,W
0024: MOVWF 0C
0025: SWAPF 0C,F
0026: RLF 0C,F
0027: RLF 0C,F
0028: RLF 0C,F
0029: MOVLW 80
002A: ANDWF 0C,F
002B: MOVF 0C,W
002C: IORWF 27,W
002D: MOVWF 05
.................... data = color;
002E: MOVF 29,W
002F: MOVWF 08
0030: RETLW 00
.................... }
....................
.................... void fill_block(unsigned int x1,
.................... unsigned int y1,
.................... unsigned int x2,
.................... unsigned int y2,
.................... unsigned int color)
.................... {
.................... int i,j;
....................
.................... for (i=x1;i 0031: MOVF 20,W
0032: MOVWF 25
0033: MOVF 22,W
0034: SUBWF 25,W
0035: BTFSC 03,0
0036: GOTO 048
.................... for (j=y1;j 0037: MOVF 21,W
0038: MOVWF 26
0039: MOVF 23,W
003A: SUBWF 26,W
003B: BTFSC 03,0
003C: GOTO 046
.................... plot (i,j,color);
003D: MOVF 25,W
003E: MOVWF 27
003F: MOVF 26,W
0040: MOVWF 28
0041: MOVF 24,W
0042: MOVWF 29
0043: CALL 01C
0044: INCF 26,F
0045: GOTO 039
0046: INCF 25,F
0047: GOTO 033
0048: GOTO 064
.................... }
....................
.................... void show_leds(unsigned int value)
.................... {
.................... addr_hi = 0xff;
*
000E: MOVLW FF
000F: MOVWF 06
.................... addr_lo = 0x07;
0010: MOVLW 07
0011: MOVWF 05
.................... data = value;
0012: MOVF 2B,W
0013: MOVWF 08
.................... }
....................
.................... // This is an interrupt service routine
.................... // #int_default -- this directive causes the compiler to produce
.................... // code for saving registers and "cleanup." It is not working
.................... // too well.
....................
.................... #int_global
....................
.................... void isr1()
.................... {
.................... // Save the 'w' register, so that the ISR will not destroy
.................... // any work in progress using the 'w' register at the time
.................... // the interrupt occurred.
.................... // Also, save the status register
.................... // Also, save the aux address bus values
.................... #asm
.................... movwf w_temp
*
0004: MOVWF 12
.................... movf stat_reg,w
0005: MOVF 03,W
.................... movwf stat_temp
0006: MOVWF 13
.................... movf addr_hi,w
0007: MOVF 06,W
.................... movwf addr_hi_temp
0008: MOVWF 15
.................... movf addr_lo,w
0009: MOVF 05,W
.................... movwf addr_lo_temp
.................... #endasm
000A: MOVWF 14
.................... show_leds(++int_count);
000B: INCF 11,F
000C: MOVF 11,W
000D: MOVWF 2B
.................... // Restore the contents of the 'w' register and status register
.................... #asm
.................... movf addr_lo_temp,w
*
0014: MOVF 14,W
.................... movwf addr_lo
0015: MOVWF 05
.................... movf addr_hi_temp,w
0016: MOVF 15,W
.................... movwf addr_hi
0017: MOVWF 06
.................... movf stat_temp,w
0018: MOVF 13,W
.................... movwf stat_reg
0019: MOVWF 03
.................... movf w_temp,w
.................... #endasm
001A: MOVF 12,W
001B: RETFIE
.................... }
....................
....................
.................... void check1()
.................... {
.................... #asm
.................... movwf w_temp // save w
*
0049: MOVWF 12
....................
.................... movlw 0xff
004A: MOVLW FF
.................... movwf count1 // initialize count1
004B: MOVWF 16
.................... load2:
.................... movlw 0xff
004C: MOVLW FF
.................... movwf count2 // initialize count2
004D: MOVWF 17
.................... dec2:
.................... decfsz count2,1
004E: DECFSZ 17,F
.................... goto dec2
004F: GOTO 04E
.................... decfsz count1,1
0050: DECFSZ 16,F
.................... goto load2
0051: GOTO 04C
....................
.................... movf w_temp,w // restore w
.................... #endasm
0052: MOVF 12,W
0053: GOTO 078
.................... }
....................
.................... void check2()
.................... {
.................... #asm
.................... movwf w_temp // save w
0054: MOVWF 12
....................
.................... movlw 0xff
0055: MOVLW FF
.................... movwf count1 // initialize count1
0056: MOVWF 16
.................... subwf count1,1 // Subtract, store in count1
0057: SUBWF 16,F
....................
.................... movf w_temp,w // restore w
.................... #endasm
0058: MOVF 12,W
0059: GOTO 079
.................... }
....................
....................
.................... main() {
.................... int rand;
.................... int a,x,y,c,d;
.................... long b;
005A: CLRF 04
005B: CLRF 03
....................
.................... // Clear the screen
.................... fill_block(0,0,128,96,0);
005C: CLRF 20
005D: CLRF 21
005E: MOVLW 80
005F: MOVWF 22
0060: MOVLW 60
0061: MOVWF 23
0062: CLRF 24
0063: GOTO 031
....................
.................... // Enable the interrupts
.................... #asm
.................... bsf 0x0b,4 // set the interrupt flag
0064: BSF 0B,4
.................... bsf 0x0b,7 // set the GIE
.................... #endasm
0065: BSF 0B,7
....................
.................... x = 10;
0066: MOVLW 0A
0067: MOVWF 1A
.................... y = 10;
0068: MOVLW 0A
0069: MOVWF 1B
.................... c = 1;
006A: MOVLW 01
006B: MOVWF 1C
.................... d = 0;
006C: CLRF 1D
.................... while (1) {
.................... plot(x,y++,c);
006D: MOVF 1B,W
006E: INCF 1B,F
006F: MOVWF 20
0070: MOVF 1A,W
0071: MOVWF 27
0072: MOVF 20,W
0073: MOVWF 28
0074: MOVF 1C,W
0075: MOVWF 29
0076: CALL 01C
.................... check1();
0077: GOTO 049
.................... check2();
0078: GOTO 054
.................... if (y>86) {
0079: MOVLW 57
007A: SUBWF 1B,W
007B: BTFSS 03,0
007C: GOTO 080
.................... y = 10;
007D: MOVLW 0A
007E: MOVWF 1B
.................... x++;
007F: INCF 1A,F
.................... }
.................... if (x>118) {
0080: MOVLW 77
0081: SUBWF 1A,W
0082: BTFSS 03,0
0083: GOTO 089
.................... x = 10;
0084: MOVLW 0A
0085: MOVWF 1A
.................... d++;
0086: INCF 1D,F
.................... c+=1;
0087: MOVLW 01
0088: ADDWF 1C,F
.................... }
.................... c += d;
0089: MOVF 1D,W
008A: ADDWF 1C,F
.................... // Delay
.................... for (a=0;a 008B: CLRF 19
008C: MOVLW 02
008D: SUBWF 19,W
008E: BTFSC 03,0
008F: GOTO 0A4
.................... for (b=0;b 0090: CLRF 1F
0091: CLRF 1E
0092: MOVLW 07
0093: SUBWF 1F,W
0094: BTFSS 03,0
0095: GOTO 09E
0096: MOVLW 07
0097: SUBWF 1F,W
0098: BTFSS 03,2
0099: GOTO 0A2
009A: MOVLW D0
009B: SUBWF 1E,W
009C: BTFSC 03,0
009D: GOTO 0A2
009E: INCF 1E,F
009F: BTFSC 03,2
00A0: INCF 1F,F
00A1: GOTO 092
00A2: INCF 19,F
00A3: GOTO 08C
....................
.................... } // End of while loop
00A4: GOTO 06D
....................
.................... } // End of main()
00A5: SLEEP