Last active
November 4, 2015 15:33
-
-
Save 7shi/4c05ba4335eba3876834 to your computer and use it in GitHub Desktop.
[VAX]アセンブラでハローワールド
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main() { | |
write(1, "hello\n", 6); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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