Raphael
I'm trying to get the following assignment to work with the PIC16 port
of sdcc. Is there a reason the sdcc assembler is so complex and more
to the point a reason for it not working?
PORTBbits.RB4 = PORTBbits.RB0
sdcc --version
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.8.3 #5222 (Aug 25 2008) (UNIX)
The sdcc generated binary doesn't seem to work and generates the
following assembler:
0000d2 6a00 clrf 0, 0 CLRF r0x00
0000d4 b081 btfsc 0x81, 0, 0 BTFSC _PORTBbits, 0
0000d6 2a00 incf 0, 0x1, 0 INCF r0x00, F
0000d8 5000 movf 0, 0, 0 MOVF r0x00, W
0000da 0b01 andlw 0x1 ANDLW 0x01
0000dc 38e8 swapf 0xe8, 0, 0 SWAPF WREG, W
0000de 6ef4 movwf 0xf4, 0 MOVWF PRODH
0000e0 5081 movf 0x81, 0, 0 MOVF _PORTBbits, W
0000e2 0bef andlw 0xef ANDLW 0xef
0000e4 10f4 iorwf 0xf4, 0, 0 IORWF PRODH, W
0000e6 6e81 movwf 0x81, 0 MOVWF _PORTBbits
I had a colleague send me the Hi-TECH assembler instruction! which does work.
3FF8 8881 BSF 0xf81, 0x4, ACCESS
Here are my makefile commands:
sdcc -c main.c -mpic16 -p18f248
gplink -w -r -o main.hex -m main.o -I /usr/share/sdcc/lib/pic16
pic18f248.lib libsdcc.lib crt0i.o
:main.c
#pragma stack 0x200 0x100
#include <pic18fregs.h>
code unsigned char at __CONFIG1H _conf0 = _OSCS_OFF_1H & _OSC_HS_PLL_1H;
code unsigned char at __CONFIG2L _conf1 = _PUT_OFF_2L & _BODEN_OFF_2L;
code unsigned char at __CONFIG2H _conf2 = _WDT_OFF_2H & _WDTPS_1_128_2H;
code unsigned char at __CONFIG4L _conf3 = _BACKBUG_OFF_4L &
_LVP_OFF_4L &_STVR_ON_4L;
void main(void) {
TRISB = 0x09;
PORTB = 0x14;
while(1) {
PORTBbits.RB4 = PORTBbits.RB0;
}
}
Jonathan
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user