Linux kernel comment -1/boot/bootsect.s
The code comes from the linux0.11 kernel code/BOOT/BOOTSECT.S
This code uses the ASM assembler format to start the code and does not use the/t because the 16-bit mode is not supported at the then-t assembly.
Www.ahlinux.com
Assembly Knowledge:
String Operation instruction:
The operand of a string operation instruction is a continuous data string (string) stored in main memory, i.e. a sequence of bytes or words in a contiguous main memory area.
The operand of a string operation instruction is a string in words (W) or a byte string in bytes (B)
String Addressing Method:
The source operand is addressed with a register SI, which defaults to the data segment DS, but allows the segment to exceed: Ds:[si]
Purpose operand with register DI addressing, default in additional segment ES, segment beyond: Es:[di]
Si and di will automatically increment (subtract) each time the string operation instruction is executed.
String transfer instruction Movw,movb
Transfers byte (B) or Word (W) operands from the source address of main memory to the destination address
Rep repeat prefix instruction
REP: Each execution of a string instruction, CX minus 1, until cx=0, repeat execution end
1 bootseg = 0x07c0
2 initseg = 0x9000
3 .....
4 entry Start
5 Start:
6 mov ax, #BOOTSEG
7 mov ds, ax!ds = 0x07c0
8 mov ax, #INITSEG
9 mov es, ax!es = 0x9000
Ten mov cx, #256!CX = 256 for cycle count
One sub Si, si!si = si-si means si = 0
!ds:si = 0x07c0:0x0000 = 0x7c00
A sub di, di!di = di-di means di = 0
!ds:si = 0x9000:0x0000 = 0x90000
Start the loop operation until CX = 0
MOVW! Each time you move 1 words, execute 256 times to achieve:
!0X7C00 starting at 256 words (word) that is 512 bytes of data to 0x9000
18. Move Bootsect.s to 0x9000
Jmpi go, initseg! Jump to 0x90000 to start execution, the following code
- This article is from: Linux Tutorial Network
Linux kernel annotations