Skip to content

Instantly share code, notes, and snippets.

@7shi
Last active November 4, 2015 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/4c05ba4335eba3876834 to your computer and use it in GitHub Desktop.
Save 7shi/4c05ba4335eba3876834 to your computer and use it in GitHub Desktop.
[VAX]アセンブラでハローワールド
main() {
write(1, "hello\n", 6);
return 0;
}
.globl _main
_main: .word 0
# write(1, hello, 6);
pushl $6
pushl $hello
pushl $1
calls $3, _write
# exit(0);
pushl $0
calls $1, _exit
hello: .byte 'h, 'e, 'l, 'l, 'o, 10
.word 0
# write(1, hello, 6);
pushl $6
pushl $hello
pushl $1
pushl $3
movl sp, ap
chmk $4
# exit(0);
pushl $0
pushl $1
movl sp, ap
chmk $1
.data
hello: .byte 'h, 'e, 'l, 'l, 'o, 10
.word 0
movl $args, ap
# write(1, hello, 6);
movl $3, (ap)
movl $1, 4(ap)
movl $hello, 8(ap)
movl $6, 12(ap)
chmk $4
# exit(0);
movl $1, (ap)
movl $0, 4(ap)
chmk $1
.data
args: .long 0, 0, 0, 0
hello: .byte 'h, 'e, 'l, 'l, 'o, 10
.word 0
# write(1, hello, 6);
movl $args1, ap
chmk $4
# exit(0);
movl $args2, ap
chmk $1
.data
args1: .long 3, 1, hello, 6
args2: .long 1, 0
hello: .byte 'h, 'e, 'l, 'l, 'o, 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment