opt: add directory; add asm demo

This commit is contained in:
K. Lange 2018-10-10 22:40:26 +09:00
parent 7b253da9ba
commit 9db81febb6
2 changed files with 30 additions and 0 deletions

23
base/opt/asm-demo.s Normal file
View File

@ -0,0 +1,23 @@
# x86 Assembly w/ libc
.global fprintf # libc export
.global stdout # libc export
.global main # our exported main function, called by C runtime
main:
push $world
push $hello
push stdout
call fprintf # fprintf(stdout, "Hello, %s!\n", "world");
pop %eax
pop %eax
pop %eax
mov $0, %eax
ret
hello:
.asciz "Hello, %s!\n"
world:
.asciz "world"

7
base/opt/build.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
export CRTBEG="/lib/crt0.o /lib/crti.o /usr/lib/crtbegin.o"
export CRTEND="/usr/lib/crtend.o /lib/crtn.o"
/usr/i686-pc-toaru/bin/as -o /tmp/asm-demo.o asm-demo.s
/usr/i686-pc-toaru/bin/ld -o /tmp/asm-demo $CRTBEG -lc /tmp/asm-demo.o $CRTEND