; CC1B Ver 0.5A beta, Copyright (c) B Knudsen Data ; C compiler for the Ubicom SX family ; ************ 24. Jun 2002 11:40 ************* device SX28 FSR_7 EQU 7 PCL EQU $02 Carry EQU 0 ug24 EQU $70 table1 EQU $10 cgt EQU $0B pro EQU $34 ov0 EQU 0 ov1 EQU $0A ov2 EQU $0A ov3 EQU 7 uu16 EQU $71 uu24 EQU $13 table2 EQU $10 i EQU $30 ci EQU $31 ; FILE sx\demo-var.c ;// DEFINING RAM VARIABLES ; ;#pragma chip SX28 // select device ; ; ;bit bt; // a bit variable ;char ga, c8; // two 8 bit unsigned char variables ; ;bank1 char a; // stating the RAM bank directly ; ;bank3 uns24 ug24; // 24 bit unsigned integer in bank 3 ; ;uns16 table1[3]; // a table with 3 elements of 16 bit ; ; ;struct { // a structure of 2 char variables ; char b; ; char c; ;} cgt; ; ; ;typedef struct { // a typedef ; int tab[2]; ; struct { ; uns8 l1; ; uns8 l2; ; } vx; ;} Txx; ; ;bank2 Txx ax, bx[2]; // using the defined type ; ; ;#pragma rambank 3 // defining the RAM bank for following definitions ;char m1; ;bank0 char uu1; ;int24 m2; ; ;#pragma rambank - // unbanked RAM ;char yy; ; ;#pragma rambank 1 ;char pp; ;shrBank int16 ir; // unbanked RAM ; ; ;const char *pro[3]; // a table in RAM of pointers to 'const' data ; ; ;// OVERLAY DEFINITIONS ;// variables overlaying another variable or table ;bit ov0 @ bt; // full overlay ;char ov1 @ c8; // full overlay ; ;int8 ov2 @ c8; // full overlay, different type ; ;bit ov3 @ ug24.23; // partial overlay ;uns16 uu16 @ ug24.high16; // partial overlay ;uns24 uu24 @ table1[1].high8; // partial overlay ;char table2[5] @ table1[0]; // partial overlay ; ; ; ;void main(void) ;{ _const1 MOV ci,W MOV W,#11 MOV W,ci-W SNB 3.Carry RETW 0 MOV W,ci ADD PCL,W RETW 72 RETW 101 RETW 108 RETW 108 RETW 111 RETW 0 RETW 78 RETW 101 RETW 119 RETW 115 RETW 0 main ; cgt.c = 0; CLR cgt+1 ; ; ov0 = 0; CLRB 8.ov0 ; ov1 = 0; CLR ov1 ; ov2 = 0; CLR ov2 ; ov3 = 0; BANK 96 CLRB 4.FSR_7 CLRB 114.ov3 ; ; ug24 = 0; CLR ug24 CLR ug24+1 CLR ug24+2 ; uu16 = 0; CLR uu16 CLR uu16+1 ; ; uu24 = 0; BANK 0 CLR uu24 CLR uu24+1 CLR uu24+2 ; table1[2] = 0; CLR table1+4 CLR table1+5 ; table1[0] = 0; CLR table1 CLR table1+1 ; table2[0] = 0; CLR table2 ; ; pro[0] = "Hello"; BANK 32 CLR pro ; pro[1] = "News"; MOV W,#6 MOV pro+1,W ; ; char i = *pro[0]; MOV W,pro CALL _const1 MOV i,W ;} SLEEP ORG $07FF GOTO main END