0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

IBM BIOSを読む。16進数値画面表示篇

0
Posted at

目的

以下のIBMBIOSで実装されているALに入っている0〜15の値を、'0'〜'F'に変換して画面表示する関数を追いました。

;--------------------------------------------
;	CONVERT AND PRINT ASCII CODE
;
;	AL MUST CONTAIN NUMBER TO BE CONVERTED.
;	AX AND BX DESTROYED.
;--------------------------------------------
XLAT_PRINT_CODE PROC	NEAR
	PUSH	DS				;SAVE DS VALUE
	PUSH	CS				;POINT DS TO CODE SEG
	POP	DS
	MOV	BX,0E4B7H			; OFFSET ASCII_TBL-XLAT TABLE
	XLATB
	MOV	AH,14
	MOV	BH,0
	INT	10H				;CALL VIDEO_IO
	POP	DS				;RESTORE ORIG VALUE IN DS
	RET
XLAT_PRINT_CODE ENDP

; ...省略...

ASCII_TBL	DB	'0123456789ABCDEF'

NASM用に修正したコード

boot.asm
[org 0x7C00]
bits 16

start:

	mov al,0x00
	call xlat_print_code
	mov al,0x01
	call xlat_print_code
	mov al,0x02
	call xlat_print_code
	mov al,0x03
	call xlat_print_code
	mov al,0x04
	call xlat_print_code
	mov al,0x05
	call xlat_print_code
	mov al,0x06
	call xlat_print_code
	mov al,0x07
	call xlat_print_code
	mov al,0x08
	call xlat_print_code
	mov al,0x09
	call xlat_print_code
	mov al,0x0A
	call xlat_print_code
	mov al,0x0B
	call xlat_print_code
	mov al,0x0C
	call xlat_print_code
	mov al,0x0D
	call xlat_print_code
	mov al,0x0E
	call xlat_print_code
	mov al,0x0F
	call xlat_print_code

hlt_loop:
	cli
	hlt
	loop hlt_loop

xlat_print_code:
	push ds ; ds退避
	push cs ; ds=cs
	pop ds
	
	mov bx, ascii_tbl
	xlatb               ; al = [ds:bx + al]
	mov ah, 14          ; 14=0x0e AH=0x0eは1文字出力
	mov bh, 0
	int 10h
	
	pop ds
	ret

ascii_tbl db '0123456789ABCDEF'

times 510-($-$$) db 0
dw 0xAA55

検証

nasm -f bin boot.asm -o boot.bin
qemu-system-i386 -fda boot.bin
lsblk
sudo dd if=boot.bin of=/dev/sdb bs=512 count=2 conv=notrunc

QEMU実機

何故か表示がおかしい。
截图 2026-05-22 21-25-10

V30実機

f9f17ffdde3ad8

ThinkPad X280

87c5d2b4fb468
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?