Created
July 11, 2022 10:57
-
-
Save vmxdev/cc7bc0674524959caff5164f8ef0717d to your computer and use it in GitHub Desktop.
8086 16-bit helloworld in GNU assembly
This file contains hidden or 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
| # as --32 hello.s -o hello.o | |
| # ld -melf_i386 -Ttext=0x100 --oformat=binary hello.o -o hello.com | |
| .code16 | |
| .globl _start | |
| .section .text | |
| _start: | |
| # print question | |
| movw $ask, %dx | |
| movb $0x09, %ah | |
| int $0x21 | |
| # input string | |
| movw $name, %dx | |
| movb $0x0a, %ah | |
| int $0x21 | |
| # append '$' to the end of user string | |
| movw $name + 2, %bx | |
| addb (nmlen), %bl | |
| movb $'$', (%bx) | |
| # put ", " between 'Hello' and user input | |
| movw $0x202c, %ax | |
| movw %ax, (name) | |
| # print 'Hello, %user-input' | |
| movw $msg, %dx | |
| movb $0x09, %ah | |
| int $0x21 | |
| ret | |
| ask: .ascii "What is your name? $" | |
| msg: .ascii "\nHello" | |
| name: .byte 0xff # allow up to 255 symbols | |
| nmlen: .byte 0 # input string length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment