Programming tools for your new processor
Compiler Generated Tree Sort optimized code
; Archelon URCC C 3.17 2003/09/19 MCSYS = ucode
; - tree.c at Wed Sep 24 15:22:18 2003
; struct node {
; struct node *left,*right;
; int val;
; };
; struct node *tree;
; int sortlist[ 5000 +1],
; biggest, littlest,
; top;
; void
; tInitarr()
.segment tree_code,memtype=0,locinc=1,rom
.global _tInitarr
_tInitarr:
addi_l R31,0x4,R31
strri_l R30,R31,-0x4
mov_l R31,R30
addi_l R31,0x4,R31
strri_l R0,R30,0x0
; ENTRY
; i in reg size 2
; temp in reg size 2
; .otmp0 in reg size 4
; .otmp1 in reg size 2
; .otmp2 in reg size 4
; .otmp3 in reg size 4
; {
; int i, temp;
; Initrand();
; biggest = 0; littlest = 0;
; .otmp4 in reg size 2
; for ( i = 1; i <= 5000 ; i++ )
; {
; temp = Rand();
; sortlist[i] = temp - (temp/100000)*100000 - 50000;
; if ( sortlist[i] > biggest )
; biggest = sortlist[i];
; };
; else if ( sortlist[i] < littlest )
; littlest = sortlist[i];
call _Initrand
stizi_w 0x0,_biggest
stizi_w 0x0,_littlest
ldzi_l __pcons1,R0
tInitarr_L1:
call _Rand
cvtswl R24,R26
ldzi_l __lcons2,R24
div_l R26,R24,R25
ldzi_l __lcons2,R24
mul_l R25,R24,R24
sub_l R26,R24,R25
ldzi_l __lcons3,R24
sub_l R25,R24,R24
cvtlw R24,R25
strri_w R25,R0,0x0
ldzi_w _biggest,R24
cmp_w R25,R24
ble tInitarr_L2
strzi_w R25,_biggest
tInitarr_L4:
addi_l R0,0x2,R0
ldzi_l __lcons4,R24
cmp_l R0,R24
ble tInitarr_L1
br tInitarr_LL1
tInitarr_L2:
ldzi_w _littlest,R24
cmp_w R25,R24
bge tInitarr_L4
strzi_w R25,_littlest
br tInitarr_L4
tInitarr_L5:
tInitarr_LL1:
; EXIT
; .temp0 at stkloc 0 (0x0) size 4
ldri_l R30,0x0,R0
mov_l R30,R31
ldri_l R31,-0x4,R30
subi_l R31,0x4,R31
ret
; }
; void
; CreateNode (t,n) struct node **t; int n;
.global _CreateNode
_CreateNode:
addi_l R31,0x4,R31
strri_l R30,R31,-0x4
mov_l R31,R30
addi_l R31,0x8,R31
strri_l R0,R30,0x0
strri_l R1,R30,0x4
; ENTRY
mov_l R24,R0
; t at argloc 0 (0x0) in reg size 4
mov_w R25,R1
; n at argloc 0 (0x0) in reg size 2
; .otmp5 in reg size 4
; {
; *t = (struct node *)malloc(sizeof(struct node));
; (*t) ->left = 0 ; (*t) ->right = 0 ;
; (*t) ->val = n;
movi_l 0xa,R24
call _malloc
cvtuwl R24,R24
strri_l R24,R0,0x0
stiri_l 0x0,R24,0x0
stiri_l 0x0,R24,0x4
strri_w R1,R24,0x8
; EXIT
; .temp1 at stkloc 0 (0x0) size 8
ldri_l R30,0x0,R0
ldri_l R30,0x4,R1
mov_l R30,R31
ldri_l R31,-0x4,R30
subi_l R31,0x4,R31
ret
; }
; void
; Insert(n, t) int n; struct node *t;
.global _Insert
_Insert:
addi_l R31,0x4,R31
strri_l R30,R31,-0x4
mov_l R31,R30
; ENTRY
mov_w R24,R26
; n at argloc 0 (0x0) in reg size 2
mov_l R25,R24
; t at argloc 0 (0x0) in reg size 4
; .otmp6 in reg size 2
; .otmp7 in reg size 4
; .otmp8 in reg size 4
; .otmp9 in reg size 4
; {
; if ( n > t->val )
; if ( t->left == 0 ) CreateNode(&t->left,n);
; else Insert(n,t->left);
; else if ( n < t->val )
; if ( t->right == 0 ) CreateNode(&t->right,n);
; else Insert(n,t->right);
ldri_w R24,0x8,R25
cmp_w R25,R26
bge Insert_L1
ldri_l R24,0x0,R25
cmpui_l R25,0x0
bne Insert_L2
mov_w R26,R25
call _CreateNode
Insert_L3:
Insert_L7:
br Insert_LL1
Insert_L2:
mov_w R26,R24
call _Insert
br Insert_LL1
Insert_L1:
cmp_w R25,R26
ble Insert_L7
addi_l R24,0x4,R24
ldri_l R24,0x0,R25
cmpui_l R25,0x0
bne Insert_L6
mov_w R26,R25
call _CreateNode
br Insert_LL1
Insert_L6:
mov_w R26,R24
call _Insert
br Insert_LL1
Insert_L8:
Insert_LL1:
; EXIT
mov_l R30,R31
ldri_l R31,-0x4,R30
subi_l R31,0x4,R31
ret
; }
; int Checktree(p) struct node *p;
.global _Checktree
_Checktree:
addi_l R31,0x4,R31
strri_l R30,R31,-0x4
mov_l R31,R30
addi_l R31,0xc,R31
strri_l R0,R30,0x0
strri_l R1,R30,0x4
strri_l R2,R30,0x8
; ENTRY
mov_l R24,R2
; p at argloc 0 (0x0) in reg size 4
; result in reg size 2
; .otmp10 in reg size 2
; .otmp11 in reg size 4
; .otmp12 in reg size 4
; .otmp13 in reg size 4
; .otmp14 in reg size 4
; .otmp15 in reg size 2
; .otmp16 in reg size 2
; .otmp17 in reg size 2
; .otmp18 in reg size 2
; .otmp19 in reg size 2
; .otmp20 in reg size 2
; .otmp21 in reg size 2
; .otmp22 in reg size 2
; {
; int result;
; result = 1 ;
; if ( p->left != 0 )
; if ( p->left->val <= p->val )
; result= 0 ;
; if ( p->right != 0 )
; if ( p->right->val >= p->val )
; result = 0 ;
; return( result);
; else
; result = Checktree(p->right) && result;
; else
; result = Checktree(p->left) && result;
movi_w 0x1,R1
ldri_l R2,0x0,R24
cmpui_l R24,0x0
mov_l R1,R0
beq Checktree_L3
ldri_w R2,0x8,R25
ldri_w R24,0x8,R26
cmp_w R26,R25
bgt Checktree_L2
movi_w 0x0,R0
Checktree_L3:
ldri_l R2,0x4,R25
cmpui_l R25,0x0
mov_l R0,R24
beq Checktree_L6
mov_l R25,R24
ldri_w R2,0x8,R26
ldri_w R25,0x8,R25
cmp_w R25,R26
blt Checktree_L5
movi_w 0x0,R24
Checktree_L6:
br Checktree_L13
Checktree_L5:
call _Checktree
cmpi_w R24,0x0
beq Checktree_L12
cmpi_w R0,0x0
bne Checktree_L10
Checktree_L12:
movi_w 0x0,R1
Checktree_L11:
mov_l R1,R24
br Checktree_L6
Checktree_L10:
br Checktree_L11
Checktree_L2:
call _Checktree
cmpi_w R24,0x0
beq Checktree_L9
mov_l R1,R0
Checktree_L8:
br Checktree_L3
Checktree_L9:
movi_w 0x0,R0
br Checktree_L8
Checktree_L13:
; EXIT
; .temp2 at stkloc 0 (0x0) size 12
ldri_l R30,0x0,R0
ldri_l R30,0x4,R1
ldri_l R30,0x8,R2
mov_l R30,R31
ldri_l R31,-0x4,R30
subi_l R31,0x4,R31
ret
; }
; void
; Trees()
.global _Trees
_Trees:
addi_l R31,0x4,R31
strri_l R30,R31,-0x4
mov_l R31,R30
addi_l R31,0x4,R31
strri_l R0,R30,0x0
; ENTRY
; i in reg size 2
; .otmp23 in reg size 4
; .otmp24 in reg size 4
; .otmp25 in reg size 4
; {
; int i;
; tInitarr();
; tree = (struct node *)malloc(sizeof(struct node));
; tree->left = 0 ; tree->right= 0 ; tree->val=sortlist[1];
; for ( i = 2; i <= 5000 ; i++ )
; Insert(sortlist[i],tree);
; if ( ! Checktree(tree) ) printf ( " Error in Tree.\n");
; .otmp26 in reg size 2
call _tInitarr
movi_l 0xa,R24
call _malloc
cvtuwl R24,R24
strzi_l R24,_tree
stiri_l 0x0,R24,0x0
stiri_l 0x0,R24,0x4
ldzi_l _tree,R24
ldzi_w _sortlist+2,R25
strri_w R25,R24,0x8
ldzi_l __pcons5,R0
Trees_L1:
ldri_w R0,0x0,R24
ldzi_l _tree,R25
call _Insert
addi_l R0,0x2,R0
ldzi_l __lcons4,R24
cmp_l R0,R24
ble Trees_L1
ldzi_l _tree,R24
call _Checktree
cmpi_w R24,0x0
bne Trees_L2
ldzi_l __pcons6,R24
call _printf
Trees_L2:
; EXIT
; .temp3 at stkloc 0 (0x0) size 4
ldri_l R30,0x0,R0
mov_l R30,R31
ldri_l R31,-0x4,R30
subi_l R31,0x4,R31
ret
.segment tree_bss,memtype=1,locinc=1,wordsize=8
tree_V8:
.global _sortlist
_sortlist:
.bss 10002
; sortlist size 10002
.global _biggest
_biggest:
.bss 2
; biggest size 2
.global _tree
_tree:
.bss 4
; tree size 4
.global _top
_top:
.bss 2
; top size 2
.global _littlest
_littlest:
.bss 2
; littlest size 2
.extern _Rand
.extern _printf
.extern _malloc
.extern _Initrand
.segment tree_data_const,memtype=1,locinc=1,wordsize=8,rom
__pcons6:
.data .byte3(tree_V5)
.data .byte2(tree_V5)
.data .byte1(tree_V5)
.data .byte0(tree_V5)
__pcons5:
.data .byte3(_sortlist+4)
.data .byte2(_sortlist+4)
.data .byte1(_sortlist+4)
.data .byte0(_sortlist+4)
__lcons4:
.data .byte3(_sortlist+10000)
.data .byte2(_sortlist+10000)
.data .byte1(_sortlist+10000)
.data .byte0(_sortlist+10000)
__lcons3:
.data 0x0
.data 0x0
.data 0xc3
.data 0x50
__lcons2:
.data 0x0
.data 0x1
.data 0x86
.data 0xa0
__pcons1:
.data .byte3(_sortlist+2)
.data .byte2(_sortlist+2)
.data .byte1(_sortlist+2)
.data .byte0(_sortlist+2)
.segment tree_istrings_const,memtype=1,locinc=1,wordsize=8,rom
tree_V5:
.data 0x20
.data 0x45
.data 0x72
.data 0x72
.data 0x6f
.data 0x72
.data 0x20
.data 0x69
.data 0x6e
.data 0x20
.data 0x54
.data 0x72
.data 0x65
.data 0x65
.data 0x2e
.data 0xa
.data 0x0
.segment _idesc,memtype=1,locinc=1,wordsize=8,rom
.data 0x0
.data 0x0
.data 0x0
.data 0x0
.data .byte3(tree_V8)
.data .byte2(tree_V8)
.data .byte1(tree_V8)
.data .byte0(tree_V8)
.data 0x0
.data 0x0
.data 0x27
.data 0x1c
Back to Archelon's Home Page