Created
August 14, 2016 17:05
-
-
Save tanishiking/b2aeece19db934c1d4aa225f2d621d14 to your computer and use it in GitHub Desktop.
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
.code16 #16bitバイナリをはくように | |
.text | |
jmp entry | |
.byte 0x90 # BS_jmpBoot 3 | |
.ascii "HELLOIPL" # BS_OEMName 8 | |
.word 512 # BPB_BytsPerSec 2 | |
.byte 1 # BPB_SecPerClus 1 | |
.word 1 # BPB_RsvdSecCnt 2 | |
.byte 2 # BPB_NumFATs 1 | |
.word 224 # BPB_RootEntCnt 2 | |
.word 2880 # BPB_TotSec16 2 | |
.byte 0xf0 # BPB_Media 1 | |
.word 9 # BPB_FATSz16 2 | |
.word 18 # BPB_SecPerTrk 2 | |
.word 2 # BPB_NumHeads 2 | |
.int 0 # BPB_HiddSec 4 | |
.int 2880 # BPB_TotSec32 4 | |
.byte 0 # BS_DrvNum 1 | |
.byte 0 # BS_Reserved1 1 | |
.byte 0x29 # BS_BootSig 1 | |
.int 0xffffffff # BS_VolID 4 | |
.ascii "HELLO-OS " # BS_VolLab 11 | |
.ascii "FAT12 " # BS_FilSysType 8 | |
.skip 18 | |
entry: | |
movw $0, %ax | |
movw %ax, %ss | |
movw $0x7c00, %sp | |
movw %ax, %ds | |
movw %ax, %es | |
movw $msg, %si # ラベルのアドレスをレジスタに | |
putloop: | |
movb (%si), %al # 書き込む文字コード | |
addw $1, %si # 次の文字のアドレスへ | |
cmpb $0, %al # alレジスタがnullバイトなら終了 | |
je fin | |
movb $0x0e, %ah # 文字コード書き込み | |
movw $15, %bx # カラーコード | |
int $0x10 # ビデオサービスBIOS | |
jmp putloop | |
fin: | |
hlt | |
jmp fin | |
msg: | |
.byte 0x0a, 0x0a | |
.string "hello, world" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment