LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   This is a Boot Sector written by as86,but I can't understand some directives (https://www.linuxquestions.org/questions/linux-newbie-8/this-is-a-boot-sector-written-by-as86-but-i-cant-understand-some-directives-4175507503/)

mirage1993 06-09-2014 10:50 AM

This is a Boot Sector written by as86,but I can't understand some directives
 
Code:

BOOTSEG =0x07c0

entry start
start:
jmpi go,BOOTSEG
go: mov ax ,cs
mov ds,ax
mov es ,ax
mov [msg1+17],ah
mov cx,#20
mov dx,#0x1004
mov bx,#0x00c
mov bp,#msg1
mov ax,#0x1301
int 0x10
loop0: jmp loop0
msg1: .ascii "Loading system..."
.byte 13,10
org 510
.word 0xAA55

I want to know why we should use "jmpi go,BOOTSEG"?

I think when the first sector is read into memory,it is placed in 07c0:0000h.
If the directive "jmpi go,BOOTSEG" is not existed,the next directive is "mov ax ,cs"
And when the directive "jmpi go,BOOTSEG" is existed ,the program would jump to 07c0:go . The next directive is "mov ax ,cs" too!

I want to know does the directive "jmpi go,BOOTSEG" make any sense?

johnsfine 06-09-2014 11:41 AM

The BIOS examines the contents of the boot sector and looks for certain details before being willing to transfer control to it. I'm pretty sure starting with that short jmp opcode is one of the requirements.

If the BIOS doesn't approve the boot sector contents, it skips the device in the boot sequence.


All times are GMT -5. The time now is 04:28 AM.