-
[OS] 02. Boot Sector PrintOS/OS from Scratch 2021. 6. 20. 14:54
서론
이번 강의에서는 가장 기본적인 Boot Sector에서 문자를 출력하는 기능을 만들어 보겠습니다. 해당 Github 강의는 다음과 같습니다.
https://github.com/cfenollosa/os-tutorial/tree/master/02-bootsector-print
cfenollosa/os-tutorial
How to create an OS from scratch. Contribute to cfenollosa/os-tutorial development by creating an account on GitHub.
github.com
이론
TTY Mode
TTY Mode는 일반 CLI 콘솔 환경을 의미하며, ah 레지스터에 0x0e를 대입하면 TTY Mode로 진입한다.
Interrupt
Interrupt는 장치나 프로그램에서 OS로 보내는 신호로 OS에게 현재 실행 중인 서비스를 멈추게 한다. 컴퓨터는 한번에 하나의 프로그램 밖에 실행하지 못하는데, Interrupt를 통해 Multi Tasking하는 것처럼 보이게 한다. Interrupt Handler의 과정은 아래 그림과 같다.
https://www.youtube.com/watch?v=O0mRZeUjEhk 본 강좌에서는 문자를 출력하기 위해 0x10 Interrupt를 사용한다. al 레지스터에 값을 저장하고 int 0x10명령어를 통해 interrupt를 발생시키면 al 레지스터에 저장된 값이 비디오 서비스로 출력된다.
코드
이번 강의의 코드는 다음과 같다.
; TTY 모드로 진입 mov ah, 0x0e mov al, 'H' ; 화면에 출력 int 0x10 mov al, 'E' int 0x10 mov al, 'L' int 0x10 mov al, 'L' int 0x10 mov al, 'O' int 0x10 loop: jmp loop times 510-($-$$) db 0 dw 0xaa55
실행 결과
위 코드를 실행 bin파일로 컴파일하고, qemu로 실행시키면 다음과 같은 화면이 나옵니다.
'HELLO' 문자가 출력된 모습 'OS > OS from Scratch' 카테고리의 다른 글
[OS] 05. Boot Sector Function (0) 2021.06.20 [OS] 04. Boot Sector Stack (0) 2021.06.20 [OS] 03. Boot Sector Memory (0) 2021.06.20 [OS] 01. Boot Sector Barebone (0) 2021.06.20 [OS] 00. 강좌 소개와 Environment 구성 (1) 2021.06.20