Linux kernel annotations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.