Run the code first. This code runs on my bochs.
**************************************** **************************************** **************************************** *
1!
2! Boot. s -- bootsect. s framework program. Use Code 0x07 to replace the one character in m1_and display it on the first line of the screen.
3!
4
5. globl begtext, begdata, begbss, endtext, enddata, endbss! Global identifier for ld86 links
6. Text! Body section
7 begtext:
8. Data! Data Segment
9 begdata:
10. BSS! Uninitialized data segment
11 begbss:
12. Text! Start of text section
13 bootseg = 0x07c0! The original segment address for the BIOS to load the bootsect code. Note that 0x07c0 is a segment base address register. The physical address in the conversion bit is based on the 16-bit segment register to represent the 20-bit bus addressing technology. It should be four shifts left, that is, 0x7c00, this is how the BIOS loads boot. s to memory location
14
15
16 Entry start! Inform the link program and execute the program from the Strat label.
17
18 start:
19 jmpi go, bootseg! Inter-segment jump. Bootseg indicates the jump segment address. The value go indicates the offset address ???????????????
20 go: mov ax, CS! Segment register Cs value --> ax, used to initialize Data Segment registers DS and ES, ax is a 16-bit General Register, CS segment register, through the value of the previous instruction segment register
It has changed from 0x0000 to 0x07c0.
21 mov ds, ax! DS data segment register,
22 mov es, ax! Elasticsearch additional segment register,
23 mov [msg1 + 17], ah! 0x07 --> Replace the string with one dot. The horn starts to sound like ??????????????????
24 mov CX, #20! A total of 20 characters are displayed, including the carriage return newline character. dx can be used in General registers and is often used to save the Count value, for example, as an implicit counter in shift instructions, loops, and string processing commands.
25 mov dx, #0x1004! The string is displayed in 17th rows and 5th columns on the screen.
26 mov BX, # 0x000c! Character Display attribute (red)
27 mov bp, # msg1! Point to the string to be called (call interruption requirements)
28 mov ax, #0x1301! Write a string and move the cursor to the end of the string
29 int 0x10! BiOS interrupt call 0x10, function 0x13, sub-function 01
30! Write string (Bytes +, meaning PC at minimum) Ah = 13 h Al = write mode, BH = page number, BL = color, Cx = String Length, DH = row, DL = column, ES: BP = offset of string this section is the information found on a foreign website so that it can be explained in 24-29 .. Web http://en.wikipedia.org/wiki/INT_10H
Function of row assignment
31 loop0: JMP loop0! Endless loop
32
33 msg1:. ASCII "loading system ..."! The information displayed when the BIOS interruption is called. A total of 20 ASCII characters.
34. byte 13, 10! In ASCII, "13" indicates the carriage return and "10" indicates the line feed. Here, note that the carriage return function is to move the cursor to the beginning of the line.
35
36
37. org 510! It indicates that subsequent statements are stored from address 510 (0x1fe ).
38. Word 0xaa55! Valid Boot Sector flag for BIOS Boot Sector loading.
39
40. Text
41 endtext:
42. Data
43 enddata:
44. BSS
45 endbss:
**************************************** **************************************** ***********************
In the meantime, many questions have been commented out in the program, indicating that there are still two problems that have not been solved ???.
The first one is that if you change go to the specified value, it will still run correctly, and the second one is ah, replacing the last byte of the string will sound ????
In fact, this program is far more than that. I think the most important thing for beginners is to understand two values: 0x07c0 and 0xaa55.
This is the most amazing part of this program. :-) Hehao.
Read this article for the value 0x07c0:
Http://blog.csdn.net/ccccdddxxx/archive/2011/06/07/6529721.asp
I believe I can understand it almost.
I am not very clear about the value 0xaa55;
Http://www.linkedin.com/answers/technology/software-development/TCH_SFT/648541-63552830
It is not clear after reading. Hey