-
[OS] 03. Boot Sector MemoryOS/OS from Scratch 2021. 6. 20. 15:03
서론
이번 강의에서는 가장 기본적인 Boot Sector에서 메모리의 구조에 대해 알아보겠습니다. 해당 Github 강의는 다음과 같습니다.
https://github.com/cfenollosa/os-tutorial/tree/master/03-bootsector-memory
cfenollosa/os-tutorial
How to create an OS from scratch. Contribute to cfenollosa/os-tutorial development by creating an account on GitHub.
github.com
이론
메모리 구조
메모리 구조 BIOS는 Boot Sector를 0x7c00주소부터 채우게 됩니다. 이를 고려해 Boot Sector를 만듭니다.
Assembly org 명령어
[org 0x7c00]
위 Assembly 코드는 모든 Assembly코드에서 0x7c00만큼 offset을 설정하는 코드입니다. 위 코드를 삽입하면 이후 나타나는 메모리 주소에서 0x7c00만큼의 주소가 더해져 계산됩니다.
코드
[org 0x7c00] mov ah, 0x0e mov al, "1" int 0x10 mov al, [the_secret] int 0x10 jmp $ the_secret: db "X" times 510-($-$$) db 0 dw 0xaa55
실행 결과
위 코드를 실행 bin파일로 컴파일하고, qemu로 실행시키면 다음과 같은 화면이 나옵니다.
0x7c00만큼 offset를 설정해 사용한 모습 'OS > OS from Scratch' 카테고리의 다른 글
[OS] 05. Boot Sector Function (0) 2021.06.20 [OS] 04. Boot Sector Stack (0) 2021.06.20 [OS] 02. Boot Sector Print (0) 2021.06.20 [OS] 01. Boot Sector Barebone (0) 2021.06.20 [OS] 00. 강좌 소개와 Environment 구성 (1) 2021.06.20