๐๏ธ ๋ฐ์ดํฐ ์์ญ: GDT(Global Descriptor Table) ๊ตฌ์กฐ ์ ์ ๋ถ๋ถ ์ฝ๋ ์ค๋ช
์
๋๋ค.
Data Area: This is an explanation of the code defining the GDT (Global Descriptor Table) structure.
โ๏ธ ๋ฐ์ดํฐ ์์ญ์ผ๋ก GDT(Global Descriptor Table) ๊ตฌ์กฐ๋ฅผ ์ ์ ํฉ๋๋ค.
Define the GDT (Global Descriptor Table) structure in the data area.
— 4๋ฐ์ดํธ ์ ๋ ฌ / 4-byte alignment
1)ํ์ฌ ์์น์ ์ฝ๋ ๋ฐ์ดํฐ์ ๋ฐ์ดํธ ์๋ฅผ 4๋ก ๋๋์์๊ฒฝ์ฐ ๋๋จธ์ง๊ฐ 0์ด ์๋๋ฉด 0~3๋ฐ์ดํธ๋ฅผ 0์ ์ถ๊ฐํด์ 4๋ก ๋๋ ๋๋จธ์ง๊ฐ0์ด ๋๋๋ก ๋ง์ถฅ๋๋ค.
If the byte count of the code data at the current position is not divisible by 4 (i.e., the remainder is not 0), 0 to 3 bytes are added to make the remainder 0 when divided by 4.
2)ํ์ ์ฌํญ์ ์๋๋ฉฐ GDT์ ๊น๋ํ ์ ๋ ฌ ๋๋ฌธ์ ์ฌ์ฉํฉ๋๋ค.
It is not mandatory; I use it because of GDT’s clean alignment.
align 4
— ๋ ๋์คํฌ๋ฆฝํฐ ์
๋๋ค.
It is a null descriptor.
dd 0, 0
1)GDT์ ์ฒซ ๋ฒ์งธ ์ํธ๋ฆฌ๋ Null Descriptor์ฌ์ผ ํฉ๋๋ค.
The first entry of the GDT must be a null descriptor.
2)๋์คํฌ๋ฆฝํฐ๋ ์ธ๊ทธ๋จผํธ๋ฅผ ์ค๋ช
ํ๋ 8๋ฐ์ดํธ์ง๋ฆฌ ์ ๋ณด์
๋๋ค.
A descriptor is an 8-byte piece of information that describes a segment.
3) GDT๋ ํ
์ด๋ธ์ด๊ณ ๋์คํฌ๋ฆฝํฐ๋ ํ
์ด๋ธ์ ์์์
๋๋ค.
The GDT is a table, and descriptors are the elements of that table.
4) dd 0, 0์ 32๋นํธ(double word) ๋ฐ์ดํฐ ๋ ๊ฐ๋ฅผ 0์ผ๋ก ์ ์ฅํ๋ผ๋ ์๋ฏธ์
๋๋ค.
“dd 0, 0” means to store two 32-bit (double-word) data items as 0.
5) ์ง์์ด์ ํฌ๊ธฐ / Size of the directive
db (Define Byte) : 1Byte
dw (Define Word) : 2Byte
dd (Define Double Word) : 4Byte
6)์ค์ ๋ฉ๋ชจ๋ฆฌ์๋ ๋ค์๊ณผ ๊ฐ์ด ์ ์ฅ ๋ฉ๋๋ค.(4๋ฐ์ดํธ + 4๋ฐ์ดํธ = 8๋ฐ์ดํธ)
It is stored in actual memory as follows (4 bytes + 4 bytes = 8 bytes).
6-1) ๋๋์คํฌ๋ฆฝํฐ์ ํฌ๊ธฐ๋ 8๋ฐ์ดํธ์ด๋ฉฐ ๋ฉ๋ชจ๋ฆฌ์๋ ์ค์ ๋ก ์๋์ ๊ฐ์ด ์ ์ฅ๋ฉ๋๋ค.
The null descriptor is 8 bytes in size and is actually stored in memory as shown below
00 00 00 00
00 00 00 00
— ์ฝ๋ ์ธ๊ทธ๋จผํธ ๋์คํฌ๋ฆฝํฐ (์คํ์
0x08 = ๋ ๋์คํฌ๋ฆฝํฐ 8๋ฐ์ดํธ)
Code segment descriptor (offset 0x08 = 8-byte null descriptor)
dw 0xFFFF, 0x0000
db 0x00, 0x9A, 0xCF, 0x00
1) ์ฝ๋ ์ธ๊ทธ๋จผํธ ๋์คํฌ๋ฆฝํฐ๋ ์ฝ๋ ์ธ๊ทธ๋จผํธ์ ์์น์ ๋ํ ์ ๋ณด๊ฐ ์ ์ฅ๋ฉ๋๋ค.
A code segment descriptor stores information about the location of a code segment.
2)dw๋ 2๋ฐ์ดํธ๋ฅผ ์์ฑํฉ๋๋ค.
dw generates 2 bytes.
3) 0xFFFF๋ FF FF 2๋ฐ์ดํธ๊ฐ ๋๊ณ 0x0000๋ 00 00๋ก 2๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
0xFFFF becomes the two bytes FF FF, and 0x0000 becomes the two bytes 00 00.
4) ๊ทธ๋ฌ๋ฉด ์ด 4๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
That makes a total of 4 bytes.
5) db๋ 1๋ฐ์ดํธ๋ฅผ ๋ง๋ญ๋๋ค.db creates a 1-byte value.
6) ๊ทธ๋ฌ๋ฉด ์๋์ฒ๋ผ ๊ฐ1๋ฐ์ดํธ์ ํฉ๊ณ๋ ์ด4๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
Then, as shown below, the sum of the 1-byte values โโresults in a total of 4 bytes.
1)dw๋ 2๋ฐ์ดํธ๋ฅผ ์์ฑํฉ๋๋ค.
dw generates 2 bytes.
2) 0xFFFF๋ FF FF 2๋ฐ์ดํธ๊ฐ ๋๊ณ 0x0000๋ 00 00๋ก 2๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
0xFFFF becomes the two bytes FF FF, and 0x0000 becomes the two bytes 00 00.
3) ๊ทธ๋ฌ๋ฉด ์ด 4๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
That makes a total of 4 bytes.
4) db๋ 1๋ฐ์ดํธ๋ฅผ ๋ง๋ค๊ณ ์ด 4๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.db creates 1 byte, resulting in a total of 4 bytes.
db 0x00 โ 1 byte
db 0x9A โ 1 byte
db 0xCF โ 1 byte
db 0x00 โ 1 byte
--------------------
ํฉ๊ณ/total 4 byte
5) ์ฝ๋ ์ธ๊ทธ๋จผํธ ๋์คํฌ๋ฆฝํฐ๋ dw(2byteร2) 4๋ฐ์ดํธ์ db(1byteร4) 4๋ฐ์ดํธ๋ฅผ ํฉํด์ ์ด 8๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
A code segment descriptor totals 8 bytes, combining 4 bytes from dw (2 bytes ร 2) and 4 bytes from db (1 byte ร 4).
6) ๋ฉ๋ชจ๋ฆฌ์๋ ๋ค์์ฒ๋ผ 8๋ฐ์ดํธ๊ฐ ์์ฑ๋ฉ๋๋ค.
8 bytes are created in memory as follows.
FF FF 00 00 00 9A CF 00
7) ์ฝ๋ ๋์คํฌ๋ฆฝํฐ์ ๊ตฌ์กฐ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
The structure of the code descriptor is as follows.
+----------------+----------------+
| Limit(2B) |
+----------------+----------------+
| Base(2B) |
+----------------+----------------+
| Base(1B) |
+----------------+----------------+
| Access(1B) |
+----------------+----------------+
| Flags+Limit(1B)|
+----------------+----------------+
| Base(1B) |
+----------------+----------------+
8) ๋ค์์ ์ฝ๋ ๋์คํฌ๋ฆฝํฐ์ ๊ธฐ๋ฅ์
๋๋ค.
The following are the functions of the code descriptor.
Code Descriptor
Base
-- ์ฝ๋ ์ธ๊ทธ๋จผํธ๊ฐ ์์๋ ์์น
The starting location of the code segment
Limit
-- ์ฌ์ฉํ ๋ฉ๋ชจ๋ฆฌ ์ฉ๋
Memory capacity to use
Access
-- ์ฝ๋์ธ์ง ๋ฐ์ดํฐ์ธ์ง ์ค์
Configure whether it is code or data.
-- ์คํ ๊ฐ๋ฅํ์ง ์ค์
Set whether it is executable
-- ๊ถํ์ค์
Permission Settings
Flags
-- 16๋นํธ์ธ์ง 32๋นํธ์ธ์ง ์ค์
Set to 16-bit or 32-bit
-- Limit๋ฅผ ๋ฐ์ดํธ ๋จ์๋ก ๋ณผ์ง 4KB ๋จ์๋ก ๋ณผ์ง ์ค์
Configure whether to view the limit in bytes or 4KB units.
7-2) ์ฝ๋๋์คํฌ๋ฆฝํฐ์ ๊ฐ ์ฝ๋์ ๊ธฐ๋ฅ ์ค๋ช
์
๋๋ค.
Here are the descriptions of the codes and functions for the code descriptor.
dw 0xFFFF
-- Limit์ ํ์ 16๋นํธ
The lower 16 bits of the Limit
-- 0xCF ์์๋ Limit์ ์์ 4๋นํธ๊ฐ ๋ค์ด๊ฐ๋๋ค.
The upper 4 bits of the Limit are also included in 0xCF.
โ
Limit = ์์ 4๋นํธ(0xF) + ํ์16๋นํธ(0xFFFF) = 4GB
Limit = Upper 4 bits (0xF) + Lower 16 bits (0xFFFF) = 4GB
dw 0x0000
-- Base Address ํ์ 16๋นํธ
Lower 16 bits of the base address
-- ์ธ๊ทธ๋จผํธ์ ์์ ์ฃผ์์
๋๋ค.
This is the starting address of the segment.
-- Base = 0x0000
db 0x00
-- Base Address 16~23bit
-- Base = 0x000000
db 0x9A
-- Access Byte(๊ถํ ๋ฐ ์ธ๊ทธ๋จผํธ ์ข
๋ฅ)๐
Access Byte (Permissions and Segment Type)
db 0xCF
-- 11001111์์ 1100์ ํ๋๊ทธ๐, 1111์ Limit์ ์์ 4๋นํธ์
๋๋ค.
In 11001111, 1100 represents the flags ๐, and 1111 represents the upper 4 bits of the Limit.
db 0x00
-- Base = 0x00000000
โ
Base Address๋ dw 0x0000 , db 0x00 ,db 0x00๋ฅผ ์กฐํฉํด์ 32๋นํธ๋ฅผ ๋ง๋ญ๋๋ค.
The Base Address is formed as a 32-bit value by combining `dw 0x0000`, `db 0x00`, and `db 0x00`.
๐ ์ ๊ทผ๊ถํ๋ฐ์ดํธ / Access Byte
— 0x9A = 10011010
| ๋นํธ/Bit | ์ด๋ฆ/Name | ๊ฐ/Vale | ์ค๋ช /Description |
|---|---|---|---|
| 7 | P(Present) | 1 | ๋ฉ๋ชจ๋ฆฌ์ ์กด์ฌ Resides in memory |
| 6~5 | DPL | 00 | Ring0 |
| 4 | S | 1 | Code/Data ์ธ๊ทธ๋จผํธ Code/Data segment |
| 3 | E | 1 | ์คํ ๊ฐ๋ฅFeasible(Code) |
| 2 | C | 0 | Conforming ์ ํจ Non-conforming |
| 1 | R | 1 | ์ฝ๊ธฐ ๊ฐ๋ฅ Readable |
| 0 | A | 0 | CPU๊ฐ ์ ๊ทผํ๋ฉด 1๋ก ๋ณ๊ฒฝ Changes to 1 when accessed by the CPU. |
| ๋นํธ/Bit | ์ด๋ฆ/Name | ๊ฐ/Vale | ์ค๋ช /Description |
|---|---|---|---|
| 7 | P(Present) | 1 | ๋ฉ๋ชจ๋ฆฌ์ ์กด์ฌ Resides in memory |
| 6~5 | DPL | 00 | Ring0 |
| 4 | S | 1 | Code/Data ์ธ๊ทธ๋จผํธ Code/Data segment |
| 3 | E | 1 | ์คํ ๊ฐ๋ฅFeasible(Code) |
| 2 | C | 0 | Conforming ์ ํจ Non-conforming |
| 1 | R | 1 | ์ฝ๊ธฐ ๊ฐ๋ฅ Readable |
| 0 | A | 0 | CPU๊ฐ ์ ๊ทผํ๋ฉด 1๋ก ๋ณ๊ฒฝ Changes to 1 when accessed by the CPU. |
๐ ํ๋๊ทธ / Flags
— 1100(G D L AVL)
| ๋นํธ Bit | ์ด๋ฆ Name | ํ์ฌ ๊ฐ Current Value | ์๋ฏธ Description |
|---|---|---|---|
| 7 | G (Granularity) | 1 | Limit๋ฅผ 4KB ๋จ์๋ก ํด์ํฉ๋๋ค. The limit is interpreted in 4KB units. |
| 6 | D (Default Operation Size) | 1 | 32๋นํธ ์ฝ๋/๋ฐ์ดํฐ 32-bit code/data |
| 5 | L (Long Mode) | 0 | 64๋นํธ ์๋ Not 64-bit |
| 4 | AVL (Available) | 0 | ์ด์์ฒด์ ๊ฐ ์์ ๋กญ๊ฒ ์ฌ์ฉํ๋ ๋นํธ bits freely used by the operating system |
1)G (Granularity)
1-1) G=0์ด๋ฉด Limit๋ฅผ 1๋ฐ์ดํธ ๋จ์๋ก ํด์ํฉ๋๋ค.Limit = 100์ด๋ฉด 100Byte๊น์ง๋ง ์ฌ์ฉ ํ ์ ์์ต๋๋ค.
If G=0, the limit is interpreted in 1-byte units. If Limit = 100, only up to 100 bytes can be used.
1-2)G=1์ด๋ฉด Limit๋ฅผ 4KB ๋จ์๋ก ํด์ํฉ๋๋ค.100 ร 4096 Byte๋ฅผ ์ฌ์ฉ ํ ์ ์์ต๋๋ค.
If G=1, the Limit is interpreted in 4 KB units; 100 ร 4,096 bytes can be used.
1-3)ํ์ฌ ์ฝ๋์์ 0xFFFFF(1,048,575) ร 4096 + 4095 = 4GB์ด ๋ฉ๋๋ค.
In the current code, 0xFFFFF (1,048,575) ร 4096 + 4095 equals 4 GB.
1-4)0~4GB์ด๊ธฐ ๋๋ฌธ์ 0xFFFFF(1,048,575) ร 4096 ์ด ๋ถ๋ถ์์ 4096์ 0~4095๊น์ง์ ๊ฐ์
๋๋ค.
Since the range is 0 to 4 GB, in the expression 0xFFFFF (1,048,575) ร 4096, the value 4096 represents the range from 0 to 4095.
1-5)๊ทธ๋์ ๋ฉ๋ชจ๋ฆฌ ์ ์ฒด ์ฉ๋์ 1~4GB๊ฐ ์๋๋ผ 0~4GB๋ฅผ ์ฌ์ฉ ํ ์ ์์ต๋๋ค.
Therefore, the total usable memory capacity is 0 to 4 GB, rather than 1 to 4 GB.
1-6)1~4GB์ ๋ํ ๊ณ์ฐ์ 0xFFFFF(1,048,575) ร 4096 ์
๋๋ค.
The calculation for 1โ4 GB is 0xFFFFF (1,048,575) ร 4096.
1-7)์์ ๊ฐ์ 0์์ ๋ถํฐ 1์ฌ์ด์ ๊ฐ์ธ 4095๋ฅผ ๋ํฉ๋๋ค.(4096๊ฐ์์ 0์ ๋นผ๋ฉด 4095)
Add 4095โa value ranging from 0 to 4095โto the value above. (Subtracting 0 from 4,096 yields 4,095.)
1-8)๊ทธ๋ฌ๋ฉด ์ ์ฒด ๋ฉ๋ชจ๋ฆฌ ์ฉ๋์ 0xFFFFF(1,048,575) ร 4096 + 4095 = 4GB ์ด๋ ๊ฒ ๋ฉ๋๋ค.
Then, the total memory capacity becomes 0xFFFFF (1,048,575) ร 4096 + 4095 = 4 GB.
2)D (Default Operation Size)
2-1)CPU๊ฐ ์ด ์ธ๊ทธ๋จผํธ๋ฅผ 16๋นํธ๋ก ์ฌ์ฉํ ์ง 32๋นํธ๋ก ์ฌ์ฉํ ์ง๋ฅผ ๊ฒฐ์ ํฉ๋๋ค.
It determines whether the CPU uses this segment as 16-bit or 32-bit.
3)L (Long Mode)
3-1)64๋นํธ ๋ชจ๋ ์ฌ๋ถ์
๋๋ค.
Indicates whether 64-bit mode is enabled.
4)AVL (Available)
4-1)์ด์์ฒด์ ๊ฐ ์์ ๋กญ๊ฒ ์ฌ์ฉํ๋ ๋นํธ๋ก cpu๋ ๋ณ๋ก ์ ๊ฒฝ์ฐ์ง ์์ผ๋ฉฐ ๋ณดํต 0์ผ๋ก ๋ก๋๋ค.
This is a bit that the operating system is free to use; the CPU generally pays no attention to it and usually leaves it set to 0.
— ๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ ๋์คํฌ๋ฆฝํฐ
Data segment descriptor
1)์ฝ๋ ์ธ๊ทธ๋จผํธ ๋์คํฌ๋ฆฝํฐ์ ๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ ๋์คํฌ๋ฆฝํฐ์ Base, Limit, Flags๋ ๋์ผํฉ๋๋ค.
The Base, Limit, and Flags of the code segment descriptor and the data segment descriptor are identical.
2) access byte์์ ๋ bit3์ ์ค์ ๊ฐ์ด ๋ฌ๋ผ ์ฝ๋/๋ฐ์ดํฐ๋ฅผ ๊ตฌ๋ถํฉ๋๋ค.
In the access byte, the setting of bit 3 distinguishes between code and data.
3)๊ทธ๋ฆฌ๊ณ CPU๋ ๊ทธ ๊ฒฐ๊ณผ์ ๋ฐ๋ผ bit2์ bit1์ ์๋ก ๋ค๋ฅธ ์๋ฏธ(์ฝ๋์์๋ Conforming/Readable, ๋ฐ์ดํฐ์์๋ Expand Down/Writable)๋ก ํด์ํฉ๋๋ค.
Based on that result, the CPU interprets bits 2 and 1 differently (as Conforming/Readable for code, and as Expand-Down/Writable for data).
2)0x92 = 10010010
| ๋นํธ Bit | ์ด๋ฆ Name | ๊ฐ Value | ์ค๋ช
Description |
|---|---|---|---|
| 7 | P (Present) | 1 | ์ธ๊ทธ๋จผํธ๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์กด์ฌ Segment exists in memory |
| 6~5 | DPL | 00 | Ring 0 |
| 4 | S | 1 | ์์คํ
์ธ๊ทธ๋จผํธ๊ฐ ์๋๋ผ Code/Data ์ธ๊ทธ๋จผํธ Code/Data segment, not a system segment. |
| 3 | E (Executable) | 0 | ์คํ ๋ถ๊ฐ โ ๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ Non-executable โ Data segment |
| 2 | ED (Expand Down) | 0 | ์ผ๋ฐ ๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ General data segment |
| 1 | W (Writable) | 1 | ์ฐ๊ธฐ ๊ฐ๋ฅ Writable |
| 0 | A (Accessed) | 0 | ์์ง ์ ๊ทผ ์ ํจ Not yet approached. |
1)P,DPL,S๋ถ๋ถ์ ์ฝ๋ ์ธ๊ทธ๋จผํธ ๋์คํฌ๋ฆฝํฐ์ ๋์ผํฉ๋๋ค.
The P, DPL, and S fields are identical to those of the code segment descriptor.
2)E (Executable)
2-1)์ด๊ฐ์ด 0์ด๋ฉด ๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ๋ผ๊ณ ํ๋จํฉ๋๋ค.
If this value is 0, it is determined to be a data segment.
3)ED – Expand Down (๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ ์ ์ฉ์ผ๋ก ์ฌ์ฉ/Used exclusively for data segments)
3-1)ED = 1์ด๋ฉด ์คํ์ฒ๋ผ ๋์ ์ฃผ์์์ ๋ฎ์ ์ฃผ์ ๋ฐฉํฅ์ผ๋ก ์ฌ์ฉํ๋ ํน์ํ ๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ ์
๋๋ค.
If ED = 1, it is a special data segment that is used in the direction from high addresses to low addresses, similar to a stack.
3-2)ED = 0์ด๋ฉด ์ผ๋ฐ์ ์ธ ๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ์
๋๋ค.
If ED = 0, it is a standard data segment.
4)W
4-1)์ด ๊ฐ์ด 1์ด๋ฉด ์ฐ๊ธฐ๊ฐ ๊ฐ๋ฅํฉ๋๋ค.
If this value is 1, writing is possible.
5)A
5-1)A ๋นํธ๋ ํ๋ก๊ทธ๋๋จธ๊ฐ ์ง์ ์ฌ์ฉํ๋ ๊ฒ์ด ์๋๋ผ CPU๊ฐ “์ด ์ธ๊ทธ๋จผํธ๋ฅผ ์ฌ์ฉํ๋ค”๋ ํ์๋ก ์ฌ์ฉํ๋ ๋นํธ์
๋๋ค.
The A-bit is not used directly by the programmer; instead, it is a bit used by the CPU to indicate that “this segment has been used.”
— CPU์๊ฒ “GDT๊ฐ ์ด๋ ์๋์ง” ์๋ ค์ฃผ๋ ๊ตฌ์กฐ์ฒด์
๋๋ค.(dw 2byte,dd 4byte)
It is a structure that tells the CPU “where the GDT is.”
gdt_pointer:
dw gdt_end - gdt_start - 1 ; GDT์ ํฌ๊ธฐ (Size of GDT)
dd gdt_start ; GDT์ ์์ ์ฃผ์ (Starting address of GDT)
1)lgdt [gdt_pointer] ์ด ์ฝ๋์์ ์ฌ์ฉํ๊ธฐ ์ํ ๋ถ๋ถ์
๋๋ค.
This part is intended for use with the lgdt [gdt_pointer] instruction.
2) gdt_end์ gdt_start๋ ๋ผ๋ฒจ์ ์์น์
๋๋ค.
gdt_end and gdt_start are the locations of the labels.
3)gdt_end – gdt_start = 24(8[Null Descriptor]+8[Code Descriptor]+8[Data Descriptor])
4)๊ทธ๋์ dw gdt_end – gdt_start – 1 ์ด ๊ฐ์ dw 23์ด ์ ์ฅ ๋ฉ๋๋ค.
Therefore, the value dw 23 is stored for the expression dw gdt_end - gdt_start - 1.
5)gdt_start๋ gdt์์ ์ฃผ์๊ฐ ์ ์ฅ๋ฉ๋๋ค.
The starting address of the GDT is stored in gdt_start.
— (sector2.asm) 512๋ฐ์ดํธ์์ ๋ฐ์ดํฐ๋ก ์ฌ์ฉ๋๊ณ ๋ ๋๋จธ์ง ์ฝ๋๋ 0์ผ๋ก ๋ง์ถ๋ ๋ถ๋ถ์
๋๋ค.
(sector2.asm) This section pads the remaining space within the 512 bytes with zeros after the code.
times 512 - ($ - $$) db 0
1) boot.asm์์ ๋ค์๊ณผ ๊ฐ์ด ์นํฐ๋ฅผ 1๊ฐ๋ง ์ฝ์ด์ค๋ฉด 512๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
If you read only one sector in boot.asm as shown below, it amounts to 512 bytes.
boot.asm
mov al, 1 โ 1์นํฐ ์ฝ์ / 1 Sector Read
secotr2.asm
times 512 - ($ - $$) db 0
2) boot.asm์์ ๋ค์๊ณผ ๊ฐ์ด ์นํฐ๋ฅผ 2๊ฐ๋ฅผ ์ฝ์ด์ค๋ฉด 1024๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
If you read two sectors in boot.asm as shown below, it amounts to 1024 bytes.
boot.asm
mov al, 2 โ 2์นํฐ ์ฝ์ / 2 Sector Read
sector2.asm
times 1024 - ($ - $$) db 0
3) boot.asm์์ ๋ค์๊ณผ ๊ฐ์ด ์นํฐ๋ฅผ 3๊ฐ๋ฅผ ์ฝ์ด์ค๋ฉด 1536๋ฐ์ดํธ๊ฐ ๋ฉ๋๋ค.
If you read three sectors in boot.asm as shown below, it amounts to 1,536 bytes.
boot.asm
mov al, 3 โ 3์นํฐ ์ฝ์ / 3 Sector Read
sector2.asm
times 1536 - ($ - $$) db 0