summaryrefslogtreecommitdiff
path: root/miniany/test1.c
diff options
context:
space:
mode:
Diffstat (limited to 'miniany/test1.c')
-rw-r--r--miniany/test1.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/miniany/test1.c b/miniany/test1.c
index 20986e3..3ae7604 100644
--- a/miniany/test1.c
+++ b/miniany/test1.c
@@ -2,12 +2,27 @@
int f( )
{
+// TODO: i is a local
+// return i * 2;
return 42;
}
+// TODO: handle forward declaration
+//void f3( int i );
+
void f2( )
{
- putint( 44 );
+ // TODO: unknown symbol because we don't know about f3 being
+ // a function with one int parameter
+ //f3( 44 );
+}
+
+void f3( int i )
+{
+ // TODO: unknown identifier 'i' in expression, define them as
+ // local symbols, code for initializing them (more precise their
+ // address) being on the stack frame
+ //putint( i );
}
void main( )
@@ -22,17 +37,17 @@ void main( )
int k;
i = 12+25/5-2*3; // 25/5 -> 5, 12+5 -> 17, 2*3 -> 6, 17-6 -> 11
- putint( i );
+ putint( i ); putnl( );
j = i/3+3*4; // 11 / 3 -> 3, 3*4 -> 12, 3+12 -> 15
- putint( j );
- k = 7 == 7; putint( k );
- k = 8 != 7; putint( k );
- k = 8 <= 9; putint( k );
- k = 8 < 9; putint( k );
- k = 9 > 8; putint( k );
- k = 9 >= 8; putint( k );
- k = 8 >= 8; putint( k );
- k = 8 <= 8; putint( k );
+ putint( j ); putnl( );
+ k = 7 == 7; putint( k ); putnl( );
+ k = 8 != 7; putint( k ); putnl( );
+ k = 8 <= 9; putint( k ); putnl( );
+ k = 8 < 9; putint( k ); putnl( );
+ k = 9 > 8; putint( k ); putnl( );
+ k = 9 >= 8; putint( k ); putnl( );
+ k = 8 >= 8; putint( k ); putnl( );
+ k = 8 <= 8; putint( k ); putnl( );
if( i == j ) {
putint( 2 );
} else {
@@ -42,14 +57,15 @@ void main( )
putint( 0 );
}
}
+ putnl( );
i = 5;
while( i > 0 ) {
- putint( i );
+ putint( i ); putnl( );
i = i - 1;
}
i = 1;
do {
- putint( i );
+ putint( i ); putnl( );
i = i + 1;
} while( i <= 5 );
@@ -62,9 +78,24 @@ void main( )
putchar( c2 );
putchar( c3 );
putchar( c4 );
+ putnl( );
+ // TODO: test if parameter types and numbers match
i = f( );
putint( i );
+ putnl( );
+ // TODO: handle negative integer literals
+ //putint( -2147483648 ); putnl( );
+ putint( 2147483647 ); putnl( );
f2( );
- // TODO: disallow this assignment, LHS is a function, RHS is an integer literal
- //f = 1;
+ // TODO: expressions as function parameters
+ f3( 41 + 1 );
+ // TODO: after calling f3 eax contains 42, which is then printed below?
+ // eax is blocked and reserved in register, ebx is used to load 2147483647
+ // we must release the allocated register eax
+ // TODO: might need spilling of registers before computing parameters for the call
+ // of 'f'
+ //f3( ( 43 + 2 ) * f( 3 ) );
+ // call an undefined function (this works)
+ //f4( );
+ putint( 2147483647 ); putnl( );
}