Skip to content

Commit e9a8a24

Browse files
committed
Fix examples in README to work
1 parent 6a06a58 commit e9a8a24

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ $ ./docker-run
4949
$ go build -o babygo *.go
5050
5151
# Compile the hello world program by babygo
52-
$ ./babygo t/hello.go > /tmp/hello.s
52+
$ ./babygo example/hello.go
5353
5454
# Assemble and link
55-
$ as -o hello.o /tmp/hello.s runtime.s
55+
$ as -o hello.o /tmp/*.s
5656
$ ld -o hello hello.o
5757
5858
# Run hello world
@@ -67,13 +67,16 @@ hello world!
6767
$ go build -o babygo *.go
6868
6969
# Build babygo by babygo (2nd generation)
70-
$ ./babygo *.go > /tmp/babygo2.s
71-
$ as -o babygo2.o /tmp/babygo2.s runtime.s
70+
$ rm /tmp/*.s
71+
$ ./babygo *.go
72+
$ as -o babygo2.o /tmp/*.s
7273
$ ld -o babygo2 babygo2.o # 2nd generation compiler
7374
74-
# Assert babygo2.s and babygo3.s are exactly same
75-
$ ./babygo2 *.go > /tmp/babygo3.s
76-
$ diff /tmp/babygo2.s /tmp/babygo3.s
75+
# You can generate babygo3 (3rd generation), babygo4, and so on...
76+
$ rm /tmp/*.s
77+
$ ./babygo2 *.go
78+
$ as -o babygo3.o /tmp/*.s
79+
$ ld -o babygo3 babygo3.o # 3rd generation compiler
7780
```
7881

7982
## Test

example/hello.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package main
2+
3+
import "os"
4+
5+
func main() {
6+
var msg = []uint8("hello world!\n")
7+
os.Stdout.Write(msg)
8+
}

0 commit comments

Comments
 (0)