Subject:
SDCC pic port status
From:
Scott Dattalo ####@####.####
Date:
2 Dec 2000 06:01:24 -0000
Message-Id: <Pine.LNX.4.21.0012012348350.13972-100000@tempest2.blackhat.net>
This past week was spent mostly tweaking gpsim to get it to work with batch
files. All that wonderful work Ralf has produced goes to waste when I run gpsim
as part of a big script to perform regression testing. I've got a makefile and a
handful of scripts that will allow me to:
-- compile a c program with SDCC
-- assemble it with gpasm
-- simulate it with gpsim
The C programs are structured in such a way that I only need to examine one
variable to see if the code simulated correctly. gpsim's output is directed to a
file and then grep'd for the good (or bad) result. This works really well and
allows me to make a change and then have confidence that it doesn't disrupt
other areas unexpectedly. You'd be surprised at how intertwined this stuff is!
The latest result is that == and != are working (when the two things being
compared are the same size). If you're interested in the code output, I've
attached it below. I think you'll find that it's fairly tight. Even though I
know many people are anxious to get thier hands on this code, they're going to
have to deal with my obsessive behavior of having it absolutely tweaked
first!
If anyone has access to a "real" C compiler, I'd be interested to see how this
compares.
Scott
PS. I apologize for the size of the post.
compare.c
/*
PIC PORT Test code
*/
/*
compare.c test compare
*/
unsigned char success=0;
unsigned char failures=0;
unsigned char dummy=0;
unsigned char achar0 = 0;
unsigned char achar1 = 0;
unsigned int aint0 = 0;
unsigned int aint1 = 0;
char schar0=0;
char schar1=0;
void done()
{
dummy++;
}
/* achar0 should be zero */
void compare_char_to_lits1(void)
{
if(achar0)
failures++;
if(achar0 == 1)
failures++;
if(achar0 == 7)
failures++;
if(achar0 != 0)
failures++;
}
/* achar0 should be `5' */
void compare_char_to_lits2(void)
{
if(!achar0)
failures++;
if(achar0 == 1)
failures++;
if(achar0 == 7)
failures++;
if(achar0 != 5)
failures++;
}
/* achar0 should equal achar1 */
void compare_char_to_char1(void)
{
if(achar0 != achar1)
failures++;
if(schar0 != schar1)
failures++;
}
/* achar0 should be different than achar1 */
void compare_char_to_char2(void)
{
if(achar0 == achar1)
failures++;
}
/* aint0 should be zero */
void compare_int_to_lits1(void)
{
if(aint0)
failures++;
if(aint0 == 1)
failures++;
if(aint0 == 7)
failures++;
if(aint0 != 0)
failures++;
}
/* aint0 should be `5' */
void compare_int_to_lits2(void)
{
if(!aint0)
failures++;
if(aint0 == 1)
failures++;
if(aint0 == 7)
failures++;
if(aint0 != 5)
failures++;
}
/* aint0 should be `0x1234' */
void compare_int_to_lits3(void)
{
if(!aint0)
failures++;
if(aint0 == 1)
failures++;
if(aint0 == 7)
failures++;
if(aint0 != 0x1234)
failures++;
}
/* aint0 should equal aint1 */
void compare_int_to_int1(void)
{
if(aint0 != aint1)
failures++;
}
/* aint0 should be different than aint1 */
void compare_int_to_int2(void)
{
if(aint0 == aint1)
failures++;
}
void main(void)
{
compare_char_to_lits1();
compare_char_to_char1();
achar0 = 5;
compare_char_to_lits2();
compare_char_to_char2();
compare_int_to_lits1();
aint0 = 5;
compare_int_to_lits2();
aint0 = 0x1234;
compare_int_to_lits3();
compare_int_to_int2();
aint0 = 0;
compare_int_to_int1();
success = failures;
done();
}
compare.asm
;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.2.0 Sat Dec 2 00:45:47 2000
;--------------------------------------------------------
; PIC port for the 14-bit core
;--------------------------------------------------------
; .module compare
list p=16c84
__config _wdt_off
include "p16c84.inc"
;--------------------------------------------------------
; publics variables in this module
;--------------------------------------------------------
; .globl _main
; .globl _compare_int_to_int2
; .globl _compare_int_to_int1
; .globl _compare_int_to_lits3
; .globl _compare_int_to_lits2
; .globl _compare_int_to_lits1
; .globl _compare_char_to_char2
; .globl _compare_char_to_char1
; .globl _compare_char_to_lits2
; .globl _compare_char_to_lits1
; .globl _done
; .globl _schar1
; .globl _schar0
; .globl _aint1
; .globl _aint0
; .globl _achar1
; .globl _achar0
; .globl _dummy
; .globl _failures
; .globl _success
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
cblock 0x13
;--------------------------------------------------------
; special function bits
;--------------------------------------------------------
;--------------------------------------------------------
; internal ram data
;--------------------------------------------------------
; .area DSEG (DATA)
_success
_failures
_dummy
_achar0
_achar1
_aint0
_aint0_2
_aint1
_aint1_2
_schar0
_schar1
;--------------------------------------------------------
; overlayable items in internal ram
;--------------------------------------------------------
; .area OSEG (OVR,DATA)
;--------------------------------------------------------
; bit data
;--------------------------------------------------------
; .area BSEG (BIT)
;--------------------------------------------------------
; Stack segment in internal ram
;--------------------------------------------------------
; .area SSEG (DATA)
;__start__stack:
; .ds 1
;--------------------------------------------------------
; indirectly addressable internal ram data
;--------------------------------------------------------
; .area ISEG (DATA)
;--------------------------------------------------------
; external ram data
;--------------------------------------------------------
; .area XSEG (XDATA)
endc
ORG 0
;--------------------------------------------------------
; interrupt vector
;--------------------------------------------------------
; .area CSEG (CODE)
;__interrupt_vect:
; ljmp __sdcc_gsinit_startup
; reti
; .ds 7
; reti
; .ds 7
; reti
; .ds 7
; reti
; .ds 7
; reti
; .ds 7
; reti
; .ds 7
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
; .area GSINIT (CODE)
; .area GSFINAL (CODE)
; .area GSINIT (CODE)
__sdcc_gsinit_startup:
; mov sp,#7
; lcall __sdcc_external_startup
; mov a,dpl
; jz __sdcc_init_data
; ljmp __sdcc_program_startup
;__sdcc_init_data:
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf _success
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf _failures
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf _dummy
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf _achar0
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf _achar1
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf (_aint0 + 1)
clrf _aint0
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf (_aint1 + 1)
clrf _aint1
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf _schar0
;G_DS_main_DS_0_DS_0 7940
; compare.c 185
clrf _schar1
; .area GSINIT (CODE)
; .area GSFINAL (CODE)
; ljmp __sdcc_program_startup
;--------------------------------------------------------
; code
;--------------------------------------------------------
; .area CSEG (CODE)
__sdcc_program_startup:
call _main
; return from main will lock up
goto $
;G_DS_done_DS_0_DS_0 7940
; compare.c 30
; -----------------------------------------
; function done
; -----------------------------------------
_done:
; compare.c 33
incf _dummy,f
_00121_DS_:
; C_DS_compare.c_DS_35_DS_1_DS_1 ==.
; XG_DS_done_DS_0_DS_0 ==.
return
;G_DS_compare_char_to_lits1_DS_0_DS_0 7940
; compare.c 39
; -----------------------------------------
; function compare_char_to_lits1
; -----------------------------------------
_compare_char_to_lits1:
; compare.c 42
movf _achar0,w
; compare.c 43
;peep 3
skpz
incf _failures,f
_00142_DS_:
; compare.c 45
movf _achar0,w
xorlw 0x1
; compare.c 46
;peep 1
skpnz
incf _failures,f
_00144_DS_:
; compare.c 48
movf _achar0,w
xorlw 0x7
; compare.c 49
;peep 1
skpnz
incf _failures,f
_00146_DS_:
; compare.c 51
movf _achar0,f
; compare.c 52
;peep 3
skpz
incf _failures,f
_00149_DS_:
; C_DS_compare.c_DS_53_DS_1_DS_1 ==.
; XG_DS_compare_char_to_lits1_DS_0_DS_0 ==.
return
;G_DS_compare_char_to_lits2_DS_0_DS_0 7940
; compare.c 56
; -----------------------------------------
; function compare_char_to_lits2
; -----------------------------------------
_compare_char_to_lits2:
; compare.c 59
movf _achar0,w
; compare.c 60
;peep 1
skpnz
incf _failures,f
_00162_DS_:
; compare.c 62
movf _achar0,w
xorlw 0x1
; compare.c 63
;peep 1
skpnz
incf _failures,f
_00164_DS_:
; compare.c 65
movf _achar0,w
xorlw 0x7
; compare.c 66
;peep 1
skpnz
incf _failures,f
_00166_DS_:
; compare.c 68
movf _achar0,w
xorlw 0x5
; compare.c 69
;peep 3
skpz
incf _failures,f
_00169_DS_:
; C_DS_compare.c_DS_70_DS_1_DS_1 ==.
; XG_DS_compare_char_to_lits2_DS_0_DS_0 ==.
return
;G_DS_compare_char_to_char1_DS_0_DS_0 7940
; compare.c 74
; -----------------------------------------
; function compare_char_to_char1
; -----------------------------------------
_compare_char_to_char1:
; compare.c 77
movf _achar0,w
xorwf _achar1,w
; compare.c 78
;peep 3
skpz
incf _failures,f
_00182_DS_:
; compare.c 80
movf _schar0,w
xorwf _schar1,w
; compare.c 81
;peep 3
skpz
incf _failures,f
_00185_DS_:
; C_DS_compare.c_DS_82_DS_1_DS_1 ==.
; XG_DS_compare_char_to_char1_DS_0_DS_0 ==.
return
;G_DS_compare_char_to_char2_DS_0_DS_0 7940
; compare.c 85
; -----------------------------------------
; function compare_char_to_char2
; -----------------------------------------
_compare_char_to_char2:
; compare.c 88
movf _achar0,w
xorwf _achar1,w
; compare.c 89
;peep 1
skpnz
incf _failures,f
_00203_DS_:
; C_DS_compare.c_DS_91_DS_1_DS_1 ==.
; XG_DS_compare_char_to_char2_DS_0_DS_0 ==.
return
;G_DS_compare_int_to_lits1_DS_0_DS_0 7940
; compare.c 95
; -----------------------------------------
; function compare_int_to_lits1
; -----------------------------------------
_compare_int_to_lits1:
; compare.c 98
movf _aint0,w
iorwf (_aint0 + 1),w
; compare.c 99
;peep 3
skpz
incf _failures,f
_00222_DS_:
; compare.c 101
movf _aint0,w
xorlw 0x1
skpz
goto _00224_DS_
movf (_aint0 + 1),f
; compare.c 102
;peep 1
skpnz
incf _failures,f
_00224_DS_:
; compare.c 104
movf _aint0,w
xorlw 0x7
skpz
goto _00226_DS_
movf (_aint0 + 1),f
; compare.c 105
;peep 1
skpnz
incf _failures,f
_00226_DS_:
; compare.c 107
movf _aint0,f
skpnz
goto _00229_DS_
movf (_aint0 + 1),f
; compare.c 108
;peep 3
skpz
incf _failures,f
_00229_DS_:
; C_DS_compare.c_DS_109_DS_1_DS_1 ==.
; XG_DS_compare_int_to_lits1_DS_0_DS_0 ==.
return
;G_DS_compare_int_to_lits2_DS_0_DS_0 7940
; compare.c 112
; -----------------------------------------
; function compare_int_to_lits2
; -----------------------------------------
_compare_int_to_lits2:
; compare.c 115
movf _aint0,w
iorwf (_aint0 + 1),w
; compare.c 116
;peep 1
skpnz
incf _failures,f
_00242_DS_:
; compare.c 118
movf _aint0,w
xorlw 0x1
skpz
goto _00244_DS_
movf (_aint0 + 1),f
; compare.c 119
;peep 1
skpnz
incf _failures,f
_00244_DS_:
; compare.c 121
movf _aint0,w
xorlw 0x7
skpz
goto _00246_DS_
movf (_aint0 + 1),f
; compare.c 122
;peep 1
skpnz
incf _failures,f
_00246_DS_:
; compare.c 124
movf _aint0,w
xorlw 0x5
skpnz
goto _00249_DS_
movf (_aint0 + 1),f
; compare.c 125
;peep 3
skpz
incf _failures,f
_00249_DS_:
; C_DS_compare.c_DS_126_DS_1_DS_1 ==.
; XG_DS_compare_int_to_lits2_DS_0_DS_0 ==.
return
;G_DS_compare_int_to_lits3_DS_0_DS_0 7940
; compare.c 129
; -----------------------------------------
; function compare_int_to_lits3
; -----------------------------------------
_compare_int_to_lits3:
; compare.c 132
movf _aint0,w
iorwf (_aint0 + 1),w
; compare.c 133
;peep 1
skpnz
incf _failures,f
_00262_DS_:
; compare.c 135
movf _aint0,w
xorlw 0x1
skpz
goto _00264_DS_
movf (_aint0 + 1),f
; compare.c 136
;peep 1
skpnz
incf _failures,f
_00264_DS_:
; compare.c 138
movf _aint0,w
xorlw 0x7
skpz
goto _00266_DS_
movf (_aint0 + 1),f
; compare.c 139
;peep 1
skpnz
incf _failures,f
_00266_DS_:
; compare.c 141
movf _aint0,w
xorlw 0x34
skpnz
goto _00269_DS_
movf (_aint0 + 1),w
xorlw 0x12
; compare.c 142
;peep 3
skpz
incf _failures,f
_00269_DS_:
; C_DS_compare.c_DS_143_DS_1_DS_1 ==.
; XG_DS_compare_int_to_lits3_DS_0_DS_0 ==.
return
;G_DS_compare_int_to_int1_DS_0_DS_0 7940
; compare.c 146
; -----------------------------------------
; function compare_int_to_int1
; -----------------------------------------
_compare_int_to_int1:
; compare.c 149
movf _aint0,w
xorwf _aint1,w
skpz
goto _00106_DS_
movf (_aint0 + 1),w
xorwf (_aint1 + 1),w
; compare.c 150
;peep 4
skpz
_00106_DS_:
incf _failures,f
_00283_DS_:
; C_DS_compare.c_DS_152_DS_1_DS_1 ==.
; XG_DS_compare_int_to_int1_DS_0_DS_0 ==.
return
;G_DS_compare_int_to_int2_DS_0_DS_0 7940
; compare.c 155
; -----------------------------------------
; function compare_int_to_int2
; -----------------------------------------
_compare_int_to_int2:
; compare.c 158
movf _aint0,w
xorwf _aint1,w
skpz
goto _00303_DS_
movf (_aint0 + 1),w
xorwf (_aint1 + 1),w
; compare.c 159
;peep 1
skpnz
incf _failures,f
_00303_DS_:
; C_DS_compare.c_DS_161_DS_1_DS_1 ==.
; XG_DS_compare_int_to_int2_DS_0_DS_0 ==.
return
;G_DS_main_DS_0_DS_0 7940
; compare.c 163
; -----------------------------------------
; function main
; -----------------------------------------
_main:
; compare.c 166
call _compare_char_to_lits1
; compare.c 167
call _compare_char_to_char1
; compare.c 168
movlw 0x05
movwf _achar0
; compare.c 169
call _compare_char_to_lits2
; compare.c 170
call _compare_char_to_char2
; compare.c 173
call _compare_int_to_lits1
; compare.c 174
clrf (_aint0 + 1)
movlw 0x05
movwf _aint0
; compare.c 175
call _compare_int_to_lits2
; compare.c 176
movlw 0x34
movwf _aint0
movlw 0x12
movwf (_aint0 + 1)
; compare.c 177
call _compare_int_to_lits3
; compare.c 178
call _compare_int_to_int2
; compare.c 179
clrf (_aint0 + 1)
clrf _aint0
; compare.c 180
call _compare_int_to_int1
; compare.c 182
movf _failures,w
movwf _success
; compare.c 183
call _done
_00321_DS_:
; C_DS_compare.c_DS_184_DS_1_DS_1 ==.
; XG_DS_main_DS_0_DS_0 ==.
return
; .area CSEG (CODE)
end