Created
February 12, 2016 17:21
-
-
Save takamichih/10273515dff3b1dd5c61 to your computer and use it in GitHub Desktop.
PC-9800 series boot sector code to print message on screen
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
;; prints message to screen on PC-9800 series text VRAM | |
;; to create bootable floppy: | |
;; 1. save this as pyon.asm with shift_jis (CP932) encoding | |
;; 2. nasm -o pyon.bin pyon.asm | |
;; 3. (for traditional 1.2MB floppy) cat pyon.bin /dev/zero | dd of=pyon.1232 bs=1k count=1232 | |
;; (for 1.44MB floppy) cat pyon.bin /dev/zero | dd of=pyon.144 bs=512 count=2880 | |
;; (of course you might want to write directly to your floppy device instead of the image file if | |
;; you happen to own an actual PC-98 to test on) | |
;; | |
bits 16 | |
org 0 | |
mov ax, cs | |
mov ds, ax | |
mov bx, 160*12+38 | |
mov si, pyon | |
call print | |
jmp $ | |
pyon: | |
db "あぁ^~心がぴょんぴょんするんじゃぁ^~", 0 | |
;text: ds:si | |
;bx: vram offset | |
print: | |
push ax | |
push es | |
mov ax, 0xa000 | |
mov es, ax | |
.loop: | |
lodsb | |
test al, 0xff | |
jz .end | |
call checksjis | |
jnc .ascii | |
xchg ah, al | |
lodsb | |
call jisconv | |
sub ah, 0x20 | |
xchg ah, al | |
mov [es:bx], ax | |
add bx, 2 | |
or al, 0x80 | |
mov [es:bx], ax | |
add bx, 2 | |
jmp .loop | |
.ascii: | |
xor ah, ah | |
mov [es:bx], ax | |
add bx, 2 | |
jmp .loop | |
.end: | |
pop es | |
pop ax | |
ret | |
checksjis: | |
cmp al, 0x81 | |
jb .no | |
cmp al, 0x9f | |
jbe .yes | |
cmp al, 0xe0 | |
jb .no | |
cmp al, 0xfc | |
jbe .yes | |
.no: | |
clc | |
ret | |
.yes: | |
stc | |
ret | |
jisconv: | |
shl ah, 1 | |
cmp al, 0x80 | |
adc ax, 0x1f61 | |
add al, 0x7f | |
jc .skip | |
add al, 0xa2 | |
.skip: | |
and ah, 0x7f | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment