From afceadb7f7e9d5aa8d276cc7d08394819bad3a32 Mon Sep 17 00:00:00 2001 From: Kragen Javier Sitaker Date: Thu, 9 Oct 2008 01:24:23 -0300 Subject: [PATCH] Got compiler to be able to compile "hello, world" program. Although it just says "hi", since I don't have strings. --- .gitignore | 1 + build | 8 ++++++++ hi.tbf1 | 3 +++ tinyboot1.tbf1 | 4 +++- 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 hi.tbf1 diff --git a/.gitignore b/.gitignore index 747de50..0aea899 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ hello42 a.out tmp.* Q +hi diff --git a/build b/build index 47c1ff5..72cba32 100755 --- a/build +++ b/build @@ -3,9 +3,17 @@ set -ve if ! ./tinyboot.py hello42.tbf1 > hello42; then cat hello42; exit 1; fi chmod 755 hello42 ./hello42 || echo $? + +./tinyboot.py Q.tbf1 if ! ./tinyboot.py tinyboot1.tbf1 < Q.tbf1 > Q; then cat Q; exit 1; fi chmod 755 Q strace ./Q + +./tinyboot.py hi.tbf1 +if ! ./tinyboot.py tinyboot1.tbf1 < hi.tbf1 > hi; then cat hi; exit 1; fi +chmod 755 hi +strace ./hi + if ! ./tinyboot.py tinyboot1.tbf1 < tinyboot1.tbf1 > tb1; then cat tb1; exit 1; fi chmod 755 tb1 ./tb1 || echo $? diff --git a/hi.tbf1 b/hi.tbf1 new file mode 100644 index 0000000..80d0891 --- /dev/null +++ b/hi.tbf1 @@ -0,0 +1,3 @@ +( simple program to print out "hi" ) +v h b 104 b 105 b 10 +^ h 3 W Q diff --git a/tinyboot1.tbf1 b/tinyboot1.tbf1 index fe88b3e..56161a2 100644 --- a/tinyboot1.tbf1 +++ b/tinyboot1.tbf1 @@ -102,9 +102,11 @@ v ` v M ( system call routine; called in program with lowercase `m`) ( syscall number already in %eax ) ( xchg %ebp, %esp) b 135 b 236 +( this really weird order is basically a special case for write(2) +( first we pop the first argument, then the third, then the second) ( pop %ebx) b 91 - ( pop %ecx) b 89 ( pop %edx) b 90 + ( pop %ecx) b 89 ( int 0x80) b 205 b 128 ( xchg %ebp, %esp) b 135 b 236 ( ret) b 195