CCS PCH C Compiler, Version 5.103, 56135               17-May-24 09:43

               Filename:   D:\owncloud8.2\2023-24 assignments\embedded C\Embedded C EES\practical\Bridgewater Daniel\Daniel Bridgewater - ACDA4013 Practical\proteus\PIC18F25K22_1\Debug.lst

               ROM used:   1156 bytes (4%)
                           Largest free fragment is 31612
               RAM used:   7 (0%) at main() level
                           20 (1%) worst case
               Stack used: 5 locations
               Stack size: 31

*
0000:  GOTO   034C
.................... #import(file="main.o")
.................... #include <main.h>
.................... #include <main.h>
.................... #include <18F25K22.h>
.................... //////////// Standard Header file for the PIC18F25K22 device ////////////////
.................... ///////////////////////////////////////////////////////////////////////////
.................... ////        (C) Copyright 1996, 2020 Custom Computer Services          ////
.................... //// This source code may only be used by licensed users of the CCS C  ////
.................... //// compiler.  This source code may only be distributed to other      ////
.................... //// licensed users of the CCS C compiler.  No other use, reproduction ////
.................... //// or distribution is permitted without written permission.          ////
.................... //// Derivative programs created using this software in object code    ////
.................... //// form are not restricted in any way.                               ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... #device PIC18F25K22
*
02BE:  MOVF   0B,W
02C0:  CLRF   01
02C2:  SUBWF  0A,W
02C4:  BC    02CC
02C6:  MOVFF  0A,00
02CA:  BRA    02E4
02CC:  CLRF   00
02CE:  MOVLW  08
02D0:  MOVWF  0C
02D2:  RLCF   0A,F
02D4:  RLCF   00,F
02D6:  MOVF   0B,W
02D8:  SUBWF  00,W
02DA:  BTFSC  FD8.0
02DC:  MOVWF  00
02DE:  RLCF   01,F
02E0:  DECFSZ 0C,F
02E2:  BRA    02D2
02E4:  RETURN 0
02E6:  MOVF   01,W
02E8:  MOVFF  08,0A
02EC:  MOVLW  64
02EE:  MOVWF  0B
02F0:  RCALL  02BE
02F2:  MOVFF  00,08
02F6:  MOVF   01,W
02F8:  MOVLW  30
02FA:  BNZ   030A
02FC:  BTFSS  09.1
02FE:  BRA    0318
0300:  BTFSC  09.3
0302:  BRA    0318
0304:  BTFSC  09.4
0306:  MOVLW  20
0308:  BRA    0310
030A:  BCF    09.3
030C:  BCF    09.4
030E:  BSF    09.0
0310:  ADDWF  01,F
0312:  MOVFF  01,0A
0316:  RCALL  026E
0318:  MOVFF  08,0A
031C:  MOVLW  0A
031E:  MOVWF  0B
0320:  RCALL  02BE
0322:  MOVFF  00,08
0326:  MOVF   01,W
0328:  MOVLW  30
032A:  BNZ   0338
032C:  BTFSC  09.3
032E:  BRA    0340
0330:  BTFSS  09.0
0332:  BRA    0340
0334:  BTFSC  09.4
0336:  MOVLW  20
0338:  ADDWF  01,F
033A:  MOVFF  01,0A
033E:  RCALL  026E
0340:  MOVLW  30
0342:  ADDWF  08,F
0344:  MOVFF  08,0A
0348:  RCALL  026E
034A:  RETURN 0
.................... 
.................... #list
.................... 
.................... #device ADC=8
.................... 
.................... #FUSES NOWDT                 	//No Watch Dog Timer
.................... #FUSES PRIMARY               	//Primary clock is system clock when scs=00
.................... #FUSES FCMEN                 	//Fail-safe clock monitor enabled
.................... #FUSES IESO                  	//Internal External Switch Over mode enabled
.................... #FUSES PUT                   	//Power Up Timer
.................... #FUSES BROWNOUT              	//Reset when brownout detected
.................... #FUSES BORV19                	//Brownout reset at 1.9V
.................... #FUSES CCP3B5                	//CCP3 input/output multiplexed with RB5
.................... #FUSES HFOFST                	//High Frequency INTRC starts clocking CPU immediately
.................... #FUSES TIMER3C0              	//Timer3 Clock In is on pin C0
.................... #FUSES CCP2B5                	//CCP2 input/output multiplexed with RB5
.................... #FUSES NOPROTECT             	//Code not protected from reading
.................... #FUSES NOWRT                 	//Program memory not write protected
.................... #FUSES NOEBTR                	//Memory not protected from table reads
.................... #FUSES NOMCLR
.................... 
.................... #use delay(internal=16MHz)
*
0004:  CLRF   FEA
0006:  MOVLW  0C
0008:  MOVWF  FE9
000A:  MOVF   FEF,W
000C:  BTFSC  FD8.2
000E:  GOTO   002E
0012:  MOVLW  05
0014:  MOVWF  01
0016:  CLRF   00
0018:  DECFSZ 00,F
001A:  BRA    0018
001C:  DECFSZ 01,F
001E:  BRA    0016
0020:  MOVLW  2E
0022:  MOVWF  00
0024:  DECFSZ 00,F
0026:  BRA    0024
0028:  BRA    002A
002A:  DECFSZ FEF,F
002C:  BRA    0012
002E:  RETURN 0
.................... 
.................... // LCD pin definitions
.................... #define LCD_ENABLE_PIN PIN_C0
.................... #define LCD_RS_PIN PIN_C2
.................... #define LCD_RW_PIN PIN_C1
.................... #define LCD_DATA4 PIN_C4
.................... #define LCD_DATA5 PIN_C5
.................... #define LCD_DATA6 PIN_C6
.................... #define LCD_DATA7 PIN_C7
.................... 
.................... // Pin definitions
.................... #define BTN_1 PIN_A4
.................... #define BTN_2 PIN_A5
.................... #define MOTOR_A PIN_A6
.................... #define MOTOR_B PIN_A7
.................... 
.................... // Function definitions
.................... int read_pot(int pot);
.................... void sane_lcd_gotoxy(int x, int y);
.................... 
.................... 
.................... #include <lcd.c>
.................... ///////////////////////////////////////////////////////////////////////////////
.................... ////                             LCD.C                                     ////
.................... ////                 Driver for common LCD modules                         ////
.................... ////                                                                       ////
.................... ////  lcd_init()   Must be called before any other function.               ////
.................... ////                                                                       ////
.................... ////  lcd_putc(c)  Will display c on the next position of the LCD.         ////
.................... ////                 \a  Set cursor position to upper left                 ////
.................... ////                 \f  Clear display, set cursor to upper left           ////
.................... ////                 \n  Go to start of second line                        ////
.................... ////                 \b  Move back one position                            ////
.................... ////              If LCD_EXTENDED_NEWLINE is defined, the \n character     ////
.................... ////              will erase all remanining characters on the current      ////
.................... ////              line, and move the cursor to the beginning of the next   ////
.................... ////              line.                                                    ////
.................... ////              If LCD_EXTENDED_NEWLINE is defined, the \r character     ////
.................... ////              will move the cursor to the start of the current         ////
.................... ////              line.                                                    ////
.................... ////                                                                       ////
.................... ////  lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1)        ////
.................... ////                                                                       ////
.................... ////  lcd_getc(x,y)   Returns character at position x,y on LCD             ////
.................... ////                                                                       ////
.................... ////  lcd_cursor_on(int1 on)   Turn the cursor on (on=TRUE) or off         ////
.................... ////              (on=FALSE).                                              ////
.................... ////                                                                       ////
.................... ////  lcd_set_cgram_char(w, *p)   Write a custom character to the CGRAM.   ////
.................... ////                                                                       ////
.................... ////                                                                       ////
.................... ////  CONFIGURATION                                                        ////
.................... ////  The LCD can be configured in one of two ways: a.) port access or     ////
.................... ////  b.) pin access.  Port access requires the entire 7 bit interface     ////
.................... ////  connected to one GPIO port, and the data bits (D4:D7 of the LCD)     ////
.................... ////  connected to sequential pins on the GPIO.  Pin access                ////
.................... ////  has no requirements, all 7 bits of the control interface can         ////
.................... ////  can be connected to any GPIO using several ports.                    ////
.................... ////                                                                       ////
.................... ////  To use port access, #define LCD_DATA_PORT to the SFR location of     ////
.................... ////  of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP    ////
.................... ////  of this file to configure the pin order.  If you are using a         ////
.................... ////  baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must  ////
.................... ////  be defined.                                                          ////
.................... ////                                                                       ////
.................... ////  Example of port access:                                              ////
.................... ////     #define LCD_DATA_PORT getenv("SFR:PORTD")                         ////
.................... ////                                                                       ////
.................... ////  To use pin access, the following pins must be defined:               ////
.................... ////     LCD_ENABLE_PIN                                                    ////
.................... ////     LCD_RS_PIN                                                        ////
.................... ////     LCD_RW_PIN                                                        ////
.................... ////     LCD_DATA4                                                         ////
.................... ////     LCD_DATA5                                                         ////
.................... ////     LCD_DATA6                                                         ////
.................... ////     LCD_DATA7                                                         ////
.................... ////                                                                       ////
.................... ////  Example of pin access:                                               ////
.................... ////     #define LCD_ENABLE_PIN  PIN_E0                                    ////
.................... ////     #define LCD_RS_PIN      PIN_E1                                    ////
.................... ////     #define LCD_RW_PIN      PIN_E2                                    ////
.................... ////     #define LCD_DATA4       PIN_D4                                    ////
.................... ////     #define LCD_DATA5       PIN_D5                                    ////
.................... ////     #define LCD_DATA6       PIN_D6                                    ////
.................... ////     #define LCD_DATA7       PIN_D7                                    ////
.................... ////                                                                       ////
.................... ///////////////////////////////////////////////////////////////////////////////
.................... ////        (C) Copyright 1996,2010 Custom Computer Services           ////
.................... //// This source code may only be used by licensed users of the CCS C  ////
.................... //// compiler.  This source code may only be distributed to other      ////
.................... //// licensed users of the CCS C compiler.  No other use, reproduction ////
.................... //// or distribution is permitted without written permission.          ////
.................... //// Derivative programs created using this software in object code    ////
.................... //// form are not restricted in any way.                               ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... 
.................... #ifndef __LCD_C__
.................... #define __LCD_C__
.................... 
.................... // define the pinout.
.................... // only required if port access is being used.
.................... typedef struct  
.................... {                            // This structure is overlayed
....................    int1 enable;           // on to an I/O port to gain
....................    int1 rs;               // access to the LCD pins.
....................    int1 rw;               // The bits are allocated from
....................    int1 unused;           // low order up.  ENABLE will
....................    unsigned int     data : 4;         // be LSB pin of that port.
....................   #if defined(__PCD__)       // The port used will be LCD_DATA_PORT.
....................    unsigned int    reserved: 8;
....................   #endif
.................... } LCD_PIN_MAP;
.................... 
.................... // this is to improve compatability with previous LCD drivers that accepted
.................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B.
.................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE))
....................  #define LCD_DATA_PORT getenv("SFR:PORTB")
.................... #endif
.................... 
.................... #if defined(__PCB__)
....................    // these definitions only need to be modified for baseline PICs.
....................    // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
.................... /*                                    EN, RS,   RW,   UNUSED,  DATA  */
....................  const LCD_PIN_MAP LCD_OUTPUT_MAP =  {0,  0,    0,    0,       0};
....................  const LCD_PIN_MAP LCD_INPUT_MAP =   {0,  0,    0,    0,       0xF};
.................... #endif
.................... 
.................... ////////////////////// END CONFIGURATION ///////////////////////////////////
.................... 
.................... #ifndef LCD_ENABLE_PIN
....................    #define lcd_output_enable(x) lcdlat.enable=x
....................    #define lcd_enable_tris()   lcdtris.enable=0
.................... #else
....................    #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
....................    #define lcd_enable_tris()  output_drive(LCD_ENABLE_PIN)
.................... #endif
.................... 
.................... #ifndef LCD_RS_PIN
....................    #define lcd_output_rs(x) lcdlat.rs=x
....................    #define lcd_rs_tris()   lcdtris.rs=0
.................... #else
....................    #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
....................    #define lcd_rs_tris()  output_drive(LCD_RS_PIN)
.................... #endif
.................... 
.................... #ifndef LCD_RW_PIN
....................    #define lcd_output_rw(x) lcdlat.rw=x
....................    #define lcd_rw_tris()   lcdtris.rw=0
.................... #else
....................    #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
....................    #define lcd_rw_tris()  output_drive(LCD_RW_PIN)
.................... #endif
.................... 
.................... // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
.................... // LCD_DATA1 as LCD_DATA5, and so on.  this block of code makes the driver
.................... // compatible with any code written for the original library
.................... #if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7))
....................    #define  LCD_DATA4    LCD_DATA0
....................    #define  LCD_DATA5    LCD_DATA1
....................    #define  LCD_DATA6    LCD_DATA2
....................    #define  LCD_DATA7    LCD_DATA3
.................... #endif
.................... 
.................... #ifndef LCD_DATA4
.................... #ifndef LCD_DATA_PORT
....................    #if defined(__PCB__)
....................       #define LCD_DATA_PORT      0x06     //portb
....................       #define set_tris_lcd(x)   set_tris_b(x)
....................    #else
....................      #if defined(PIN_D0)
....................       #define LCD_DATA_PORT      getenv("SFR:PORTD")     //portd
....................      #else
....................       #define LCD_DATA_PORT      getenv("SFR:PORTB")     //portb
....................      #endif
....................    #endif   
.................... #endif
.................... 
.................... #if defined(__PCB__)
....................    LCD_PIN_MAP lcd, lcdlat;
....................    #byte lcd = LCD_DATA_PORT
....................    #byte lcdlat = LCD_DATA_PORT
.................... #elif defined(__PCM__)
....................    LCD_PIN_MAP lcd, lcdlat, lcdtris;
....................    #byte lcd = LCD_DATA_PORT
....................    #byte lcdlat = LCD_DATA_PORT
....................    #byte lcdtris = LCD_DATA_PORT+0x80
.................... #elif defined(__PCH__)
....................    LCD_PIN_MAP lcd, lcdlat, lcdtris;
....................    #byte lcd = LCD_DATA_PORT
....................    #byte lcdlat = LCD_DATA_PORT+9
....................    #byte lcdtris = LCD_DATA_PORT+0x12
.................... #elif defined(__PCD__)
....................    LCD_PIN_MAP lcd, lcdlat, lcdtris;
....................    #word lcd = LCD_DATA_PORT
....................    #word lcdlat = LCD_DATA_PORT+2
....................    #word lcdtris = LCD_DATA_PORT-0x02
.................... #endif
.................... #endif   //LCD_DATA4 not defined
.................... 
.................... #ifndef LCD_TYPE
....................    #define LCD_TYPE 2           // 0=5x7, 1=5x10, 2=2 lines
.................... #endif
.................... 
.................... #ifndef LCD_LINE_TWO
....................    #define LCD_LINE_TWO 0x40    // LCD RAM address for the second line
.................... #endif
.................... 
.................... #ifndef LCD_LINE_LENGTH
....................    #define LCD_LINE_LENGTH 20
.................... #endif
.................... 
.................... unsigned int8 lcd_read_nibble(void);
.................... 
.................... unsigned int8 lcd_read_byte(void)
.................... {
....................    unsigned int8 low,high;
.................... 
....................  #if defined(__PCB__)
....................    set_tris_lcd(LCD_INPUT_MAP);
....................  #else
....................   #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
....................    output_float(LCD_DATA4);
*
00C8:  BSF    F94.4
....................    output_float(LCD_DATA5);
00CA:  BSF    F94.5
....................    output_float(LCD_DATA6);
00CC:  BSF    F94.6
....................    output_float(LCD_DATA7);
00CE:  BSF    F94.7
....................   #else
....................    lcdtris.data = 0xF;
....................   #endif
....................  #endif
....................         
....................    lcd_output_rw(1);
00D0:  BSF    F8B.1
00D2:  BCF    F94.1
....................    delay_cycles(1);
00D4:  NOP   
....................    lcd_output_enable(1);
00D6:  BSF    F8B.0
00D8:  BCF    F94.0
....................    delay_cycles(1);
00DA:  NOP   
....................    high = lcd_read_nibble();
00DC:  RCALL  0076
00DE:  MOVFF  01,12
....................       
....................    lcd_output_enable(0);
00E2:  BCF    F8B.0
00E4:  BCF    F94.0
....................    delay_cycles(1);
00E6:  NOP   
....................    lcd_output_enable(1);
00E8:  BSF    F8B.0
00EA:  BCF    F94.0
....................    delay_us(1);
00EC:  BRA    00EE
00EE:  BRA    00F0
....................    low = lcd_read_nibble();
00F0:  RCALL  0076
00F2:  MOVFF  01,11
....................       
....................    lcd_output_enable(0);
00F6:  BCF    F8B.0
00F8:  BCF    F94.0
.................... 
....................  #if defined(__PCB__)
....................    set_tris_lcd(LCD_OUTPUT_MAP);
....................  #else
....................   #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
....................    output_drive(LCD_DATA4);
00FA:  BCF    F94.4
....................    output_drive(LCD_DATA5);
00FC:  BCF    F94.5
....................    output_drive(LCD_DATA6);
00FE:  BCF    F94.6
....................    output_drive(LCD_DATA7);
0100:  BCF    F94.7
....................   #else
....................    lcdtris.data = 0x0;
....................   #endif
....................  #endif
.................... 
....................    return( (high<<4) | low);
0102:  SWAPF  12,W
0104:  MOVWF  00
0106:  MOVLW  F0
0108:  ANDWF  00,F
010A:  MOVF   00,W
010C:  IORWF  11,W
010E:  MOVWF  01
0110:  GOTO   0120 (RETURN)
.................... }
.................... 
.................... unsigned int8 lcd_read_nibble(void)
.................... {
....................   #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
*
0076:  CLRF   13
....................    unsigned int8 n = 0x00;
.................... 
....................    /* Read the data port */
....................    n |= input(LCD_DATA4);
0078:  BSF    F94.4
007A:  MOVLW  00
007C:  BTFSC  F82.4
007E:  MOVLW  01
0080:  IORWF  13,F
....................    n |= input(LCD_DATA5) << 1;
0082:  BSF    F94.5
0084:  MOVLW  00
0086:  BTFSC  F82.5
0088:  MOVLW  01
008A:  MOVWF  00
008C:  BCF    FD8.0
008E:  RLCF   00,F
0090:  MOVF   00,W
0092:  IORWF  13,F
....................    n |= input(LCD_DATA6) << 2;
0094:  BSF    F94.6
0096:  MOVLW  00
0098:  BTFSC  F82.6
009A:  MOVLW  01
009C:  MOVWF  00
009E:  RLCF   00,F
00A0:  RLCF   00,F
00A2:  MOVLW  FC
00A4:  ANDWF  00,F
00A6:  MOVF   00,W
00A8:  IORWF  13,F
....................    n |= input(LCD_DATA7) << 3;
00AA:  BSF    F94.7
00AC:  MOVLW  00
00AE:  BTFSC  F82.7
00B0:  MOVLW  01
00B2:  MOVWF  00
00B4:  RLCF   00,F
00B6:  RLCF   00,F
00B8:  RLCF   00,F
00BA:  MOVLW  F8
00BC:  ANDWF  00,F
00BE:  MOVF   00,W
00C0:  IORWF  13,F
....................    
....................    return(n);
00C2:  MOVFF  13,01
....................   #else
00C6:  RETURN 0
....................    return(lcd.data);
....................   #endif
.................... }
.................... 
.................... void lcd_send_nibble(unsigned int8 n)
.................... {
....................   #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
....................    /* Write to the data port */
....................    output_bit(LCD_DATA4, bit_test(n, 0));
*
0030:  BTFSC  12.0
0032:  BRA    0038
0034:  BCF    F8B.4
0036:  BRA    003A
0038:  BSF    F8B.4
003A:  BCF    F94.4
....................    output_bit(LCD_DATA5, bit_test(n, 1));
003C:  BTFSC  12.1
003E:  BRA    0044
0040:  BCF    F8B.5
0042:  BRA    0046
0044:  BSF    F8B.5
0046:  BCF    F94.5
....................    output_bit(LCD_DATA6, bit_test(n, 2));
0048:  BTFSC  12.2
004A:  BRA    0050
004C:  BCF    F8B.6
004E:  BRA    0052
0050:  BSF    F8B.6
0052:  BCF    F94.6
....................    output_bit(LCD_DATA7, bit_test(n, 3));
0054:  BTFSC  12.3
0056:  BRA    005C
0058:  BCF    F8B.7
005A:  BRA    005E
005C:  BSF    F8B.7
005E:  BCF    F94.7
....................   #else      
....................    lcdlat.data = n;
....................   #endif
....................       
....................    delay_cycles(1);
0060:  NOP   
....................    lcd_output_enable(1);
0062:  BSF    F8B.0
0064:  BCF    F94.0
....................    delay_us(2);
0066:  MOVLW  02
0068:  MOVWF  00
006A:  DECFSZ 00,F
006C:  BRA    006A
006E:  NOP   
....................    lcd_output_enable(0);
0070:  BCF    F8B.0
0072:  BCF    F94.0
0074:  RETURN 0
.................... }
.................... 
.................... void lcd_send_byte(unsigned int8 address, unsigned int8 n)
.................... {
....................   #if defined(__PCB__)
....................    set_tris_lcd(LCD_OUTPUT_MAP);
....................   #else
....................    lcd_enable_tris();
*
0114:  BCF    F94.0
....................    lcd_rs_tris();
0116:  BCF    F94.2
....................    lcd_rw_tris();
0118:  BCF    F94.1
....................   #endif
.................... 
....................    lcd_output_rs(0);
011A:  BCF    F8B.2
011C:  BCF    F94.2
....................    while ( bit_test(lcd_read_byte(),7) ) ;
011E:  BRA    00C8
0120:  MOVFF  01,11
0124:  BTFSC  01.7
0126:  BRA    011E
....................    lcd_output_rs(address);
0128:  MOVF   0F,F
012A:  BNZ   0130
012C:  BCF    F8B.2
012E:  BRA    0132
0130:  BSF    F8B.2
0132:  BCF    F94.2
....................    delay_cycles(1);
0134:  NOP   
....................    lcd_output_rw(0);
0136:  BCF    F8B.1
0138:  BCF    F94.1
....................    delay_cycles(1);
013A:  NOP   
....................    lcd_output_enable(0);
013C:  BCF    F8B.0
013E:  BCF    F94.0
....................    lcd_send_nibble(n >> 4);
0140:  SWAPF  10,W
0142:  MOVWF  11
0144:  MOVLW  0F
0146:  ANDWF  11,F
0148:  MOVFF  11,12
014C:  RCALL  0030
....................    lcd_send_nibble(n & 0xf);
014E:  MOVF   10,W
0150:  ANDLW  0F
0152:  MOVWF  11
0154:  MOVWF  12
0156:  RCALL  0030
0158:  RETURN 0
.................... }
.................... 
.................... #if defined(LCD_EXTENDED_NEWLINE)
.................... unsigned int8 g_LcdX, g_LcdY;
.................... #endif
.................... 
.................... void lcd_init(void) 
.................... {
....................    unsigned int8 i;
....................    unsigned int8 LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};
015A:  MOVLW  28
015C:  MOVWF  08
015E:  MOVLW  0C
0160:  MOVWF  09
0162:  MOVLW  01
0164:  MOVWF  0A
0166:  MOVLW  06
0168:  MOVWF  0B
....................                              // These bytes need to be sent to the LCD
....................                              // to start it up.
....................    
.................... 
....................    lcd_output_enable(0);
016A:  BCF    F8B.0
016C:  BCF    F94.0
....................    lcd_output_rs(0);
016E:  BCF    F8B.2
0170:  BCF    F94.2
....................    lcd_output_rw(0);
0172:  BCF    F8B.1
0174:  BCF    F94.1
.................... 
....................  #if defined(__PCB__)
....................    set_tris_lcd(LCD_OUTPUT_MAP);
....................  #else
....................   #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
....................    output_drive(LCD_DATA4);
0176:  BCF    F94.4
....................    output_drive(LCD_DATA5);
0178:  BCF    F94.5
....................    output_drive(LCD_DATA6);
017A:  BCF    F94.6
....................    output_drive(LCD_DATA7);
017C:  BCF    F94.7
....................   #else
....................    lcdtris.data = 0x0;
....................   #endif
....................    lcd_enable_tris();
017E:  BCF    F94.0
....................    lcd_rs_tris();
0180:  BCF    F94.2
....................    lcd_rw_tris();
0182:  BCF    F94.1
....................  #endif
....................     
....................    delay_ms(15);
0184:  MOVLW  0F
0186:  MOVWF  0C
0188:  RCALL  0004
....................    for(i=1;i<=3;++i)
018A:  MOVLW  01
018C:  MOVWF  07
018E:  MOVF   07,W
0190:  SUBLW  03
0192:  BNC   01A4
....................    {
....................        lcd_send_nibble(3);
0194:  MOVLW  03
0196:  MOVWF  12
0198:  RCALL  0030
....................        delay_ms(5);
019A:  MOVLW  05
019C:  MOVWF  0C
019E:  RCALL  0004
01A0:  INCF   07,F
01A2:  BRA    018E
....................    }
....................    
....................    lcd_send_nibble(2);
01A4:  MOVLW  02
01A6:  MOVWF  12
01A8:  RCALL  0030
....................    delay_ms(5);
01AA:  MOVLW  05
01AC:  MOVWF  0C
01AE:  RCALL  0004
....................    for(i=0;i<=3;++i)
01B0:  CLRF   07
01B2:  MOVF   07,W
01B4:  SUBLW  03
01B6:  BNC   01D2
....................       lcd_send_byte(0,LCD_INIT_STRING[i]);
01B8:  CLRF   03
01BA:  MOVF   07,W
01BC:  ADDLW  08
01BE:  MOVWF  FE9
01C0:  MOVLW  00
01C2:  ADDWFC 03,W
01C4:  MOVWF  FEA
01C6:  MOVFF  FEF,10
01CA:  CLRF   0F
01CC:  RCALL  0114
.................... 
....................   #if defined(LCD_EXTENDED_NEWLINE)
01CE:  INCF   07,F
01D0:  BRA    01B2
01D2:  GOTO   038E (RETURN)
....................    g_LcdX = 0;
....................    g_LcdY = 0;
....................   #endif
.................... }
.................... 
.................... void lcd_gotoxy(unsigned int8 x, unsigned int8 y)
.................... {
....................    unsigned int8 address;
....................    
....................    if(y!=1)
01D6:  DECFSZ 0C,W
01D8:  BRA    01DC
01DA:  BRA    01E2
....................       address=LCD_LINE_TWO;
01DC:  MOVLW  40
01DE:  MOVWF  0D
01E0:  BRA    01E4
....................    else
....................       address=0;
01E2:  CLRF   0D
....................      
....................    address+=x-1;
01E4:  MOVLW  01
01E6:  SUBWF  0B,W
01E8:  ADDWF  0D,F
....................    lcd_send_byte(0,0x80|address);
01EA:  MOVF   0D,W
01EC:  IORLW  80
01EE:  MOVWF  0E
01F0:  CLRF   0F
01F2:  MOVWF  10
01F4:  RCALL  0114
.................... 
....................   #if defined(LCD_EXTENDED_NEWLINE)
01F6:  RETURN 0
....................    g_LcdX = x - 1;
....................    g_LcdY = y - 1;
....................   #endif
.................... }
.................... 
.................... void lcd_putc(char c)
.................... {
....................    switch (c)
*
026E:  MOVF   0A,W
0270:  XORLW  07
0272:  BZ    0282
0274:  XORLW  0B
0276:  BZ    028C
0278:  XORLW  06
027A:  BZ    029C
027C:  XORLW  02
027E:  BZ    02A8
0280:  BRA    02B2
....................    {
....................       case '\a'   :  lcd_gotoxy(1,1);     break;
0282:  MOVLW  01
0284:  MOVWF  0B
0286:  MOVWF  0C
0288:  RCALL  01D6
028A:  BRA    02BC
.................... 
....................       case '\f'   :  lcd_send_byte(0,1);
028C:  CLRF   0F
028E:  MOVLW  01
0290:  MOVWF  10
0292:  RCALL  0114
....................                      delay_ms(2);
0294:  MOVLW  02
0296:  MOVWF  0C
0298:  RCALL  0004
....................                     #if defined(LCD_EXTENDED_NEWLINE)
....................                      g_LcdX = 0;
....................                      g_LcdY = 0;
....................                     #endif
....................                      break;
029A:  BRA    02BC
.................... 
....................      #if defined(LCD_EXTENDED_NEWLINE)
....................       case '\r'   :  lcd_gotoxy(1, g_LcdY+1);   break;
....................       case '\n'   :
....................          while (g_LcdX++ < LCD_LINE_LENGTH)
....................          {
....................             lcd_send_byte(1, ' ');
....................          }
....................          lcd_gotoxy(1, g_LcdY+2);
....................          break;
....................      #else
....................       case '\n'   : lcd_gotoxy(1,2);        break;
029C:  MOVLW  01
029E:  MOVWF  0B
02A0:  MOVLW  02
02A2:  MOVWF  0C
02A4:  RCALL  01D6
02A6:  BRA    02BC
....................      #endif
....................      
....................       case '\b'   : lcd_send_byte(0,0x10);  break;
02A8:  CLRF   0F
02AA:  MOVLW  10
02AC:  MOVWF  10
02AE:  RCALL  0114
02B0:  BRA    02BC
....................      
....................      #if defined(LCD_EXTENDED_NEWLINE)
....................       default     : 
....................          if (g_LcdX < LCD_LINE_LENGTH)
....................          {
....................             lcd_send_byte(1, c);
....................             g_LcdX++;
....................          }
....................          break;
....................      #else
....................       default     : lcd_send_byte(1,c);     break;
02B2:  MOVLW  01
02B4:  MOVWF  0F
02B6:  MOVFF  0A,10
02BA:  RCALL  0114
....................      #endif
....................    }
02BC:  RETURN 0
.................... }
....................  
.................... char lcd_getc(unsigned int8 x, unsigned int8 y)
.................... {
....................    char value;
.................... 
....................    lcd_gotoxy(x,y);
....................    while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
....................    lcd_output_rs(1);
....................    value = lcd_read_byte();
....................    lcd_output_rs(0);
....................    
....................    return(value);
.................... }
.................... 
.................... // write a custom character to the ram
.................... // which is 0-7 and specifies which character array we are modifying.
.................... // ptr points to an array of 8 bytes, where each byte is the next row of
.................... //    pixels.  only bits 0-4 are used.  the last row is the cursor row, and
.................... //    usually you will want to leave this byte 0x00.
.................... void lcd_set_cgram_char(unsigned int8 which, unsigned int8 *ptr)
.................... {
....................    unsigned int i;
.................... 
....................    which <<= 3;
....................    which &= 0x38;
.................... 
....................    lcd_send_byte(0, 0x40 | which);  //set cgram address
.................... 
....................    for(i=0; i<8; i++)
....................    {
....................       lcd_send_byte(1, *ptr++);
....................    }
....................   
....................    #if defined(LCD_EXTENDED_NEWLINE)
....................     lcd_gotoxy(g_LcdX+1, g_LcdY+1);  //set ddram address
....................    #endif
.................... }
.................... 
.................... void lcd_cursor_on(int1 on)
.................... {
....................    if (on)
....................    {
....................       lcd_send_byte(0,0x0F);           //turn LCD cursor ON
....................    }
....................    else
....................    {
....................       lcd_send_byte(0,0x0C);           //turn LCD cursor OFF
....................    }
.................... }
.................... 
.................... #endif
.................... 
.................... 
.................... void main() {
*
034C:  CLRF   FF8
034E:  BCF    FD0.7
0350:  MOVLW  70
0352:  MOVWF  FD3
0354:  BCF    F9B.6
0356:  BCF    F9B.7
0358:  MOVF   FC1,W
035A:  ANDLW  F0
035C:  MOVWF  FC1
035E:  MOVLW  00
0360:  MOVLB  F
0362:  MOVWF  x38
0364:  MOVWF  x39
0366:  MOVWF  x3A
0368:  CLRF   F77
036A:  CLRF   F78
036C:  CLRF   F79
.................... 	setup_adc_ports(sAN0 | sAN1 | sAN2, VSS_VDD);
036E:  MOVF   FC1,W
0370:  ANDLW  F0
0372:  MOVWF  FC1
0374:  MOVLW  07
0376:  MOVWF  x38
0378:  MOVLW  00
037A:  MOVWF  x39
037C:  MOVWF  x3A
.................... 	setup_adc(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_0);
037E:  MOVF   FC0,W
0380:  ANDLW  C0
0382:  IORLW  07
0384:  MOVWF  FC0
0386:  BCF    FC0.7
0388:  BSF    FC2.0
.................... 
....................    lcd_init();
038A:  MOVLB  0
038C:  BRA    015A
....................  
.................... 	int btn_1_mode = 0; // Button 1 counter
038E:  CLRF   05
.................... 
.................... 	while(TRUE)	{
.................... 		// TASK 1
.................... 		// Show all three potentiometer values on separate lines, from 0-255
.................... 		sane_lcd_gotoxy(7,0); // Line 1 centre
0390:  MOVLW  07
0392:  MOVWF  07
0394:  CLRF   08
0396:  RCALL  01F8
.................... 		printf(lcd_putc, "A=%3u", read_pot(0));
0398:  CLRF   07
039A:  RCALL  0246
039C:  MOVFF  01,07
03A0:  MOVLW  41
03A2:  MOVWF  0A
03A4:  RCALL  026E
03A6:  MOVLW  3D
03A8:  MOVWF  0A
03AA:  RCALL  026E
03AC:  MOVFF  07,08
03B0:  MOVLW  13
03B2:  MOVWF  09
03B4:  RCALL  02E6
.................... 		sane_lcd_gotoxy(7,1); // Line 2 centre
03B6:  MOVLW  07
03B8:  MOVWF  07
03BA:  MOVLW  01
03BC:  MOVWF  08
03BE:  RCALL  01F8
.................... 		printf(lcd_putc, "B=%3u", read_pot(1));
03C0:  MOVLW  01
03C2:  MOVWF  07
03C4:  RCALL  0246
03C6:  MOVFF  01,07
03CA:  MOVLW  42
03CC:  MOVWF  0A
03CE:  RCALL  026E
03D0:  MOVLW  3D
03D2:  MOVWF  0A
03D4:  RCALL  026E
03D6:  MOVFF  07,08
03DA:  MOVLW  13
03DC:  MOVWF  09
03DE:  RCALL  02E6
.................... 		sane_lcd_gotoxy(7,2); // Line 3 centre
03E0:  MOVLW  07
03E2:  MOVWF  07
03E4:  MOVLW  02
03E6:  MOVWF  08
03E8:  RCALL  01F8
.................... 		printf(lcd_putc, "C=%3u", read_pot(2));
03EA:  MOVLW  02
03EC:  MOVWF  07
03EE:  RCALL  0246
03F0:  MOVFF  01,07
03F4:  MOVLW  43
03F6:  MOVWF  0A
03F8:  RCALL  026E
03FA:  MOVLW  3D
03FC:  MOVWF  0A
03FE:  RCALL  026E
0400:  MOVFF  07,08
0404:  MOVLW  13
0406:  MOVWF  09
0408:  RCALL  02E6
.................... 
.................... 		// TASK 2
.................... 		if (input(BTN_1)) {
040A:  BSF    F92.4
040C:  BTFSS  F80.4
040E:  BRA    0448
.................... 			switch (btn_1_mode++) {
0410:  MOVF   05,W
0412:  INCF   05,F
0414:  XORLW  00
0416:  BZ    0426
0418:  XORLW  02
041A:  BZ    0430
041C:  XORLW  03
041E:  BZ    043A
0420:  XORLW  02
0422:  BZ    043A
.................... 				default:
.................... 					// If counter overflows, reset counter and then proceed to mode 0
.................... 					btn_1_mode = 0;
0424:  CLRF   05
.................... 				case 0: // TASK 2.i
.................... 					// Set motor running counter-clockwise
.................... 					output_low (MOTOR_A);
0426:  BCF    F92.6
0428:  BCF    F89.6
.................... 					output_high(MOTOR_B);
042A:  BCF    F92.7
042C:  BSF    F89.7
.................... 					break;
042E:  BRA    0442
.................... 
.................... 				case 2: // TASK 2.iii
.................... 					// Set motor running counter-clockwise
.................... 					output_high(MOTOR_A);
0430:  BCF    F92.6
0432:  BSF    F89.6
.................... 					output_low (MOTOR_B);
0434:  BCF    F92.7
0436:  BCF    F89.7
.................... 					break;
0438:  BRA    0442
.................... 
.................... 				// In either steps 2 or 4...
.................... 				case 1: // TASK 2.ii
.................... 				case 3: // TASK 2.iv
.................... 					// ... stop the motor.
.................... 					output_low(MOTOR_A);
043A:  BCF    F92.6
043C:  BCF    F89.6
.................... 					output_low(MOTOR_B);
043E:  BCF    F92.7
0440:  BCF    F89.7
.................... 					break;
.................... 			}
.................... 
.................... 			while (input(BTN_1)); // Wait for release
0442:  BSF    F92.4
0444:  BTFSC  F80.4
0446:  BRA    0442
.................... 		}
.................... 
.................... 		// TASK 3
.................... 		if (input(BTN_2)) {
0448:  BSF    F92.5
044A:  BTFSS  F80.5
044C:  BRA    0480
.................... 			btn_1_mode = 0; // Interpretation of "sequentially" in Task 2 suggests that pressing Button 2 should reset the sequence
044E:  CLRF   05
.................... 			
.................... 			// For each potentiometer A,B,C (0,1,2)...
.................... 			for (int pot=0; pot<=2; pot++) {
0450:  CLRF   06
0452:  MOVF   06,W
0454:  SUBLW  02
0456:  BNC   0476
.................... 				// ... show the binary representation on the LEDs
.................... 				output_b(read_pot(pot));
0458:  MOVFF  06,07
045C:  RCALL  0246
045E:  CLRF   F93
0460:  MOVFF  01,F8A
.................... 				// Then wait 2 seconds before showing the next value.
.................... 				delay_ms(2000);
0464:  MOVLW  08
0466:  MOVWF  07
0468:  MOVLW  FA
046A:  MOVWF  0C
046C:  RCALL  0004
046E:  DECFSZ 07,F
0470:  BRA    0468
0472:  INCF   06,F
0474:  BRA    0452
.................... 			}
.................... 			output_b(0); // Clear LEDS after the final value
0476:  CLRF   F93
0478:  CLRF   F8A
.................... 
.................... 			// Task 3 doesn't specify if this should loop when held. I've interpreted "press" to mean "on rising edge". 
.................... 			while (input(BTN_2)); // Wait for release
047A:  BSF    F92.5
047C:  BTFSC  F80.5
047E:  BRA    047A
.................... 		}
0480:  BRA    0390
.................... 	}
.................... }
.................... 
0482:  SLEEP 
.................... int read_pot(int pot) {
.................... 	// Change ADC channel then return a reading.
.................... 	// Argument 'pot' corresponds to PORTA analogue pins 0-3
.................... 	set_adc_channel(pot);
*
0246:  RLCF   07,W
0248:  MOVWF  00
024A:  RLCF   00,F
024C:  MOVLW  FC
024E:  ANDWF  00,F
0250:  MOVF   FC2,W
0252:  ANDLW  83
0254:  IORWF  00,W
0256:  MOVWF  FC2
.................... 	delay_us(20); // Allow time for the hardware to adjust
0258:  MOVLW  1A
025A:  MOVWF  00
025C:  DECFSZ 00,F
025E:  BRA    025C
0260:  NOP   
.................... 	return read_adc();
0262:  BSF    FC2.1
0264:  BTFSC  FC2.1
0266:  BRA    0264
0268:  MOVFF  FC4,01
026C:  RETURN 0
.................... }
.................... 
.................... void sane_lcd_gotoxy(int x, int y) {
....................    // Because the memory map for multiple lines on a character LCD are ludicrous.
....................    switch (y) {
*
01F8:  MOVF   08,W
01FA:  XORLW  00
01FC:  BZ    020A
01FE:  XORLW  01
0200:  BZ    021A
0202:  XORLW  03
0204:  BZ    0228
0206:  XORLW  01
0208:  BZ    0238
.................... 	  case 0:
.................... 	  default:
.................... 		 lcd_gotoxy(1+x,1); // Line 1
020A:  MOVLW  01
020C:  ADDWF  07,W
020E:  MOVWF  09
0210:  MOVWF  0B
0212:  MOVLW  01
0214:  MOVWF  0C
0216:  RCALL  01D6
.................... 		 break;
0218:  BRA    0244
.................... 	  case 1:
.................... 		 lcd_gotoxy(1+x,0); // Line 2
021A:  MOVLW  01
021C:  ADDWF  07,W
021E:  MOVWF  09
0220:  MOVWF  0B
0222:  CLRF   0C
0224:  RCALL  01D6
.................... 		 break;
0226:  BRA    0244
.................... 	  case 2:
.................... 		 lcd_gotoxy(21+x,1); // Line 3
0228:  MOVLW  15
022A:  ADDWF  07,W
022C:  MOVWF  09
022E:  MOVWF  0B
0230:  MOVLW  01
0232:  MOVWF  0C
0234:  RCALL  01D6
.................... 		 break;
0236:  BRA    0244
.................... 	  case 3:
.................... 		 lcd_gotoxy(21+x,0); // Line 4
0238:  MOVLW  15
023A:  ADDWF  07,W
023C:  MOVWF  09
023E:  MOVWF  0B
0240:  CLRF   0C
0242:  RCALL  01D6
.................... 		 break;
....................    }
0244:  RETURN 0
.................... }
.................... 

Configuration Fuses:
   Word  1: E800   INTRC_IO NOPLLEN PRIMARY FCMEN IESO
   Word  2: 3C1E   PUT BROWNOUT BORV19 NOWDT WDT32768
   Word  3: 3F00   CCP2C1 PBADEN CCP3B5 HFOFST TIMER3C0 CCP2B5 NOMCLR
   Word  4: 0081   STVREN NOLVP NOXINST NODEBUG
   Word  5: C00F   NOPROTECT NOCPB NOCPD
   Word  6: E00F   NOWRT NOWRTC NOWRTB NOWRTD
   Word  7: 400F   NOEBTR NOEBTRB
