opt: add directory; add asm demo
This commit is contained in:
parent
7b253da9ba
commit
9db81febb6
23
base/opt/asm-demo.s
Normal file
23
base/opt/asm-demo.s
Normal 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
7
base/opt/build.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user