According to the compilers the Hi-Tech version took up 84 bytes of Flash while the mikroC required 122 bytes. Both compilers used only 2 bytes of RAM. Apparently Hi-Tech wins by a mile, at least in this particular test.
Here's the C program I fed both compilers:
#define int8 unsigned char void InitRegisters() { IRCF1 = 1; ADCON1 = 0b1111; // turn all analog inputs into digital PORTA = 0; PORTB = 0; PORTC = 0; TRISA = 0; TRISB = 0; TRISC = 0; } void OnLoad(int8 *salad) { *salad = 0xFF; } void OffLoad(int8 *greens) { *greens = 0; } // ==================================================================== // main // ==================================================================== void main() { InitRegisters(); while(1) { if (PORTC) OffLoad(&PORTC); else OnLoad(&PORTC); } // while (1) } // main
Here's the disaasembly listing by Hi-Tech:
1: /* 2: 3: sandbox 4: compiler = Hi Tech 5: 6: */ 7: 8: #include9: 10: __CONFIG (1, INTIO & FCMDIS & IESODIS); 11: __CONFIG (2, PWRTDIS & BORDIS & WDTDIS & WDTPS4); 12: __CONFIG (3, PBDIGITAL & LPT1DIS & MCLRDIS); 13: __CONFIG (4, XINSTDIS & STVRDIS & LVPDIS & DEBUGDIS); 14: __CONFIG (5, 0xFFFF); // write protect disabled 15: __CONFIG (6, 0xFFFF); // write protect disabled 16: __CONFIG (7, 0xFFFF); // write protect disabled 17: 18: 19: #define int8 unsigned char 20: 21: // ==================================================================== 22: // Global variables and enumerations 23: // ==================================================================== 24: 25: 26: 27: 28: // ==================================================================== 29: // Functions 30: // ==================================================================== 31: 32: void InitRegisters() 33: { 34: IRCF1 = 1; 1FC8 8AD3 BSF 0xfd3, 0x5, ACCESS 35: ADCON1 = 0b1111; // turn all analog inputs into digital 1FCA 0E0F MOVLW 0xf 1FCC 6EC1 MOVWF 0xfc1, ACCESS 36: 37: PORTA = 0; 1FCE 6A80 CLRF 0xf80, ACCESS 38: PORTB = 0; 1FD0 6A81 CLRF 0xf81, ACCESS 39: PORTC = 0; 1FD2 6A82 CLRF 0xf82, ACCESS 40: TRISA = 0; 1FD4 6A92 CLRF 0xf92, ACCESS 41: TRISB = 0; 1FD6 6A93 CLRF 0xf93, ACCESS 42: TRISC = 0; 1FD8 6A94 CLRF 0xf94, ACCESS 43: } 1FDA 0012 RETURN 0 44: 45: void OnLoad(int8 *salad) 46: { 47: *salad = 0xFF; 1FBC C000 MOVFF 0, 0xfe9 1FBE FFE9 NOP 1FC0 C001 MOVFF 0x1, 0xfea 1FC2 FFEA NOP 1FC4 68EF SETF 0xfef, ACCESS 48: } 1FC6 0CFF RETLW 0xff 49: 50: void OffLoad(int8 *greens) 51: { 52: *greens = 0; 1FB0 C000 MOVFF 0, 0xfe9 1FB2 FFE9 NOP 1FB4 C001 MOVFF 0x1, 0xfea 1FB6 FFEA NOP 1FB8 6AEF CLRF 0xfef, ACCESS 53: } 1FBA 0C00 RETLW 0 54: 55: // ==================================================================== 56: // main 57: // ==================================================================== 58: 59: void main() 60: { 61: InitRegisters(); 1FDC ECE4 CALL 0x1fc8, 0 1FDE F00F NOP 62: 63: while(1) 1FFE D7F0 BRA 0x1fe0 64: { 65: if (PORTC) 1FE0 5082 MOVF 0xf82, W, ACCESS 1FE2 E007 BZ 0x1ff2 66: OffLoad(&PORTC); 1FE4 0E82 MOVLW 0x82 1FE6 6E00 MOVWF 0, ACCESS 1FE8 0E0F MOVLW 0xf 1FEA 6E01 MOVWF 0x1, ACCESS 1FEC ECD8 CALL 0x1fb0, 0 1FEE F00F NOP 1FF0 D7F7 BRA 0x1fe0 67: else 68: OnLoad(&PORTC); 1FF2 0E82 MOVLW 0x82
Disassembly listing by mikroC:
; LST file generated by mikroListExporter - v.2.0 ; Date/Time: 9/30/2010 8:21:34 PM ;---------------------------------------------- ;Address Opcode ASM 0x0000 0xF000EF2D GOTO 90 0x0004 0x0000 NOP 0x0006 0x0000 NOP 0x0008 0xF000EF00 GOTO 0 0x000C 0x0000 NOP 0x000E 0x0000 NOP 0x0010 0x0000 NOP 0x0012 0x0000 NOP 0x0014 0x0000 NOP 0x0016 0x0000 NOP 0x0018 0xD7F3 BRA 0 _OnLoad: ;sandbox18F.c,36 :: void OnLoad(int8 *salad) ;sandbox18F.c,38 :: *salad = 0xFF; 0x001C 0xFFE1C015 MOVFF FARG_OnLoad_salad, FSR1L 0x0020 0xFFE2C016 MOVFF FARG_OnLoad_salad+1, FSR1H 0x0024 0x0EFF MOVLW 255 0x0026 0x6EE6 MOVWF POSTINC1 ;sandbox18F.c,39 :: } 0x0028 0x0012 RETURN 0 ; end of _OnLoad ___CC2DW: ;__Lib_System.c,21 :: ;__Lib_System.c,23 :: _CC2DL_Loop1: ;__Lib_System.c,24 :: 0x002A 0x0009 TBLRD*+ ;__Lib_System.c,25 :: 0x002C 0xFFE6CFF5 MOVFF TABLAT, POSTINC1 ;__Lib_System.c,26 :: 0x0030 0x0600 DECF R0, 1, 0 ;__Lib_System.c,27 :: 0x0032 0xE1FB BNZ _CC2DL_Loop1 ;__Lib_System.c,28 :: 0x0034 0x0601 DECF R1, 1, 0 ;__Lib_System.c,29 :: 0x0036 0xE1F9 BNZ _CC2DL_Loop1 ;__Lib_System.c,31 :: 0x0038 0x0012 RETURN 0 ; end of ___CC2DW _OffLoad: ;sandbox18F.c,41 :: void OffLoad(int8 *greens) ;sandbox18F.c,43 :: *greens = 0; 0x003A 0xFFE1C015 MOVFF FARG_OffLoad_greens, FSR1L 0x003E 0xFFE2C016 MOVFF FARG_OffLoad_greens+1, FSR1H 0x0042 0x6AE6 CLRF POSTINC1 ;sandbox18F.c,44 :: } 0x0044 0x0012 RETURN 0 ; end of _OffLoad _InitRegisters: ;sandbox18F.c,23 :: void InitRegisters() ;sandbox18F.c,25 :: OSCCON.IRCF1 = 1; 0x0046 0x8AD3 BSF OSCCON, 5 ;sandbox18F.c,26 :: ADCON1 = 0b1111; // turn all analog inputs into digital 0x0048 0x0E0F MOVLW 15 0x004A 0x6EC1 MOVWF ADCON1 ;sandbox18F.c,28 :: PORTA = 0; 0x004C 0x6A80 CLRF PORTA ;sandbox18F.c,29 :: PORTB = 0; 0x004E 0x6A81 CLRF PORTB ;sandbox18F.c,30 :: PORTC = 0; 0x0050 0x6A82 CLRF PORTC ;sandbox18F.c,31 :: TRISA = 0; 0x0052 0x6A92 CLRF TRISA ;sandbox18F.c,32 :: TRISB = 0; 0x0054 0x6A93 CLRF TRISB ;sandbox18F.c,33 :: TRISC = 0; 0x0056 0x6A94 CLRF TRISC ;sandbox18F.c,34 :: } 0x0058 0x0012 RETURN 0 ; end of _InitRegisters _main: ;sandbox18F.c,50 :: void main() ;sandbox18F.c,52 :: InitRegisters(); 0x005A 0xDFF5 RCALL _InitRegisters ;sandbox18F.c,54 :: while(1) L_main0: ;sandbox18F.c,56 :: if (PORTA) 0x005C 0x5280 MOVF PORTA, 1 0x005E 0xE006 BZ L_main2 ;sandbox18F.c,57 :: OffLoad(&PORTA); 0x0060 0x0E80 MOVLW PORTA 0x0062 0x6E15 MOVWF FARG_OffLoad_greens 0x0064 0x0E0F MOVLW hi_addr(PORTA) 0x0066 0x6E16 MOVWF FARG_OffLoad_greens+1 0x0068 0xDFE8 RCALL _OffLoad 0x006A 0xD005 BRA L_main3 L_main2: ;sandbox18F.c,59 :: OnLoad(&PORTA); 0x006C 0x0E80 MOVLW PORTA 0x006E 0x6E15 MOVWF FARG_OnLoad_salad 0x0070 0x0E0F MOVLW hi_addr(PORTA) 0x0072 0x6E16 MOVWF FARG_OnLoad_salad+1 0x0074 0xDFD3 RCALL _OnLoad L_main3: ;sandbox18F.c,60 :: } // while (1) 0x0076 0xD7F2 BRA L_main0 ;sandbox18F.c,61 :: } // main 0x0078 0xD7FF BRA $+0 ; end of _main
No comments:
Post a Comment