Setup. s code comment

Source: Internet
Author: User

1!
2! Setup. S (c) 1991 Linus Torvalds
3!
4! Setup. S is responsible for getting the system data from the bios,
5! And putting them into the appropriate places in system memory.
6! Both setup. s and system has been loaded by the bootblock.
7!
8! This code asks the BIOS for memory/Disk/other parameters, and
9! Puts them in a "safe" Place: 0x90000-0x901ff, ie where
10! Boot-block used to be. It is then up to the Protected Mode
11! System to read them from there before the area is overwritten
12! For buffer-blocks.
!
! Setup. S is responsible for Retrieving System data from the bios and placing the data in a proper place in the system memory.
! At this time, setup. s and system have been loaded into the memory by the bootsect boot block.
!
! This code asks the BIOS about memory/Disk/other parameters, and puts these parameters into one
! "Safe": 0x90000-0x901ff, that is, the original bootsect code block was
! And then read by the protection mode system before it is overwritten by the buffer block.
13!
14
15! Note! These had better be the same as in bootsect. s!

! The following parameters are recommended to be the same as those in bootsect. s!
16
17 initseg = 0x9000! We move boot here-Out of the way! The original bootsect segment.
18 sysseg = 0x1000! System loaded at 0x10000 (65536 ).! System is at 0x10000 (64 K.
19 setupseg = 0x9020! This is the current segment! The segment address of the program.
20
21. globl begtext, begdata, begbss, endtext, enddata, endbss
22. Text
23 begtext:
24. Data
25 begdata:
26. BSS
27 begbss:
28. Text
29
30 Entry start
31 start:
32
33! OK, the read went well so we get current cursor position and save it
34! Posterity.
! OK. The entire disk reading process is normal. Now, save the cursor position for future use.
35
36 mov ax, # initseg! This is done in bootsect already,...
! Set ds to # initseg (0x9000 ). This is already in the bootsect Program
! But now it's a setup program. Linus thinks it needs to be set again.
! Set it.
37 mov ds, ax
38 mov ah, #0x03! Read cursor POS
! BiOS interrupt 0x10 read cursor function number AH = 0x03
! Input: bH = page number
! Return: CH = scanning start line, CL = scanning slave line,
! DH = row number (0x00 is the top), DL = column number (0x00 is the left ).
39 xor bh, BH
40 int 0x10! Save it in known place, con_init fetches
41 mov [0], dx! From 0x90000.
! The last two sentences are used to store the cursor position information at 0x90000. The Console
! It will be retrieved during initialization.
42
43! Get memory size (Extended MEM, KB )! In the following three sentences, the size of the extended memory is measured in KB ).
! Yes, the call is interrupted 0x15, and the function number AH = 0x88
! Returns the extended memory size (Kb) starting from 0x100000 (1 MB ).
! If an error occurs, CF is set to a bit, and AX = the error code.
44
45 mov ah, #0x88
46 int 0x15
47 mov [2], ax! The extended memory value is 0x90002 (1 word ).
48
49! Get video-card data :! The following section is used to obtain the current display mode of the display card.
! 0x10 for BIOS interruption, function ID Ah = 0x0f
! Return Value: Ah = number of columns, Al = display mode, BH = current display page.
! 0x90004 (1 Word) stores the current page, 0x90006 display mode, 0x90007 character columns.
50
51 mov ah, # 0x0f

52 int 0x10
53 mov [4], BX! BH = display page
54 mov [6], ax! Al = video mode, Ah = window width
55
56! Check for parameters/VGA and some config parameters! Check the display mode (Measures/VGA) and take the parameters.
! Call the BIOS to interrupt 0x10. Select the "Retrieve Method" option for the additional function.
! Function No.: Ah = 0x12, BL = 0x10
! Return: bH = display status
! (0x00-color mode, I/O port = 0x3dx)
! (0x01-monochrome mode, I/O port = 0x3bx)
! BL = installed Display memory
! (0x00-64 K, 0x01-128 K, 0x02-192 K, 0x03 = 256 K)
! Cx = display card feature parameters (see the description after the program ).
57
58 mov ah, #0x12
59 mov BL, #0x10
60 int 0x10
61 mov [8], ax! 0x90008 = ??
62 mov [10], BX! 0x9000a = memory for installation, 0x9000b = display status (color/monochrome)
63 mov [12], CX! 0x9000c = display card feature parameters.
64
65! Get hd0 data! Take the information of the first hard disk (copy the hard disk parameter table ).
! The first address of the 1st hard disk parameter table is the Vector Value of the interrupt vector 0x41! And 2nd Hard Disks
! The parameter table is followed by 1st tables, and the Vector Value of the interrupt vector 0x46 also points to the 2nd hard disks.
! The first address of the parameter table. The table length is 16 bytes (0x10 ).
! The following two procedures copy the BIOS parameter table for two hard disks, and store 90080 data disks at 0 x 1st.
! Hard Disk table, where 90090 hard disks are stored at 0 x 2nd.
66
67 mov ax, #0x0000.
68 mov ds, ax
69 lDs Si, [4*0x41]! Take the value of the interrupt vector 0x41, that is, the address of the hd0 parameter table.

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.