Vi chiedo scusa pensavo di avere gia dato il codice seguente :
ORG 0
Begin:
CLI
mov ax,0060h
mov ds,ax
mov es,ax
MOV [CDDriveNumber],DL
MOV AX,7000h
MOV DS,AX
MOV BX,530h
MOV [DS:BX],DL
MOV AX,60h
MOV DS,AX
XOR AX,AX
MOV SS,AX
MOV SP,5FEh
MOV SP,AX
STI
MOV SI,WelcomeMessage
CALL PrintString
MOV SI,TheEndOfTheLine
CALL PrintString
MOV AL,[CDDriveNumber]
CMP AL,0
JE Failure
GetBootedCDStatus:
MOV DL,[CDDriveNumber]
MOV AH,4Bh
MOV AL,1
MOV SI,DiskResultsBuffer
INT 13h
JC Failure
MOV AH,255
MOV DL,[DiskResultsBuffer+2]
CMP [CDDriveNumber],DL
JNE Failure
GetINT13hExtenstions:
MOV DL,[CDDriveNumber]
MOV AH,41h
MOV BX,55AAh
INT 13h
JC Failure
if defined DEBUG_MESSAGES
MOV [VersionEnhancedDiskDriveExtensions],AH
MOV [InternalUseEnhancedDiskDriveExtensions],AL
MOV [InterfaceSupportBitMask],CX
MOV AL,[VersionEnhancedDiskDriveExtensions]
MOV CL,8
CALL ToHex
MOV SI,HexBuffer
Call PrintString
MOV SI,AddTheHAtTheEnd
CALL PrintString
MOV SI,EnhancedDiskDriveVersionMessage
CALL PrintString
MOV AX,[InterfaceSupportBitMask]
MOV CL,16
CALL ToHex
MOV SI,HexBuffer
CALL PrintString
MOV SI,AddTheHAtTheEnd
CALL PrintString
MOV SI,IsEqualToTheCX
CALL PrintString
MOV SI,TheEndOfTheLine
call PrintString
end if
MOV DL,[CDDriveNumber]
MOV AH,42h
MOV SI,DiskAddressPacket
INT 13h
JC Failure
MOV ES,[DiskAddressPacket.Segment]
MOV DI,[DiskAddressPacket.Offset]
MOV BX,40
VolumeLabelLoop:
MOV CL,[ES:DI+BX]
CMP CL,' '
JE .VolumeLabelDone
MOV [VolumeLabel+BX-40],CL
INC BX
JMP VolumeLabelLoop
.VolumeLabelDone:
MOV byte [VolumeLabel+BX-40],0
MOV EAX,[ES:DI+158]
MOV [DiskAddressPacket.End],EAX
MOV DL,[CDDriveNumber]
MOV AH,42h
MOV SI,DiskAddressPacket
INT 13h
JC Failure
CALL PrintDirectory
Failure:
mov AL,AH
mov cl,8
call ToHex
MOV SI,FailureMessage
CALL PrintString
mov si,HexBuffer
CALL PrintString
MOV SI,AddTheHAtTheEnd
CALL PrintString
MOV SI,TheEndOfTheLine
CALL PrintString
mov SI,PressAnyKeyMessage
CALL PrintString
MOV AH,0
INT 16h
INT 19h
PrintDirectory:
MOV ES,[DiskAddressPacket.Segment]
MOV DI,[DiskAddressPacket.Offset]
MOV SI,DriveDisplayMessage
CALL PrintString
CMP byte [VolumeLabel],0
JE .NoLabel
MOV SI,VolumeLabel
CALL PrintString
JMP .LabelDone
.NoLabel:
MOV SI,HasNoLabel
CALL PrintString
.LabelDone:
MOV SI,TheEndOfTheLine
CALL PrintString
MOV SI,TheEndOfTheLine
CALL PrintString
.GrabDirectoryEntry:
MOV AL,[ES:DI]
MOV [DirectoryEntrySize],AL
MOV EAX,[ES:DI+2]
MOV [FileSector],EAX
MOV EAX,[ES:DI+10]
MOV [FileSize],EAX
MOV AL,[ES:DI+32]
MOV [FileNameLength],AL
XOR BX,BX
XOR CX,CX
MOV SI,DI
ADD SI,33
MOV BX,FileNameEntry
MOV AL,[FileNameLength]
CMP AL,1
JE .DotAndDotDotEntries
.LoopFileNameEntry:
MOV AL,[ES:SI]
MOV [DS:BX],AL
INC BX
INC CX
INC SI
XOR AX,AX
MOV AL,[FileNameLength]
CMP CX,AX
JB .LoopFileNameEntry
MOV byte [DS:BX],0
JMP .FileNameEntryDisplay
.DotAndDotDotEntries:
MOV AL,[FileEntryNumber]
CMP AL,0
JA .DoDotDotEntry
MOV word [FileNameEntry],'.'
MOV byte [FileNameEntry+1],0
JMP .FileNameEntryDisplay
.DoDotDotEntry:
MOV word [FileNameEntry],'..'
MOV byte [FileNameEntry+2],0
.FileNameEntryDisplay:
MOV SI,FileNameEntry
CALL PrintString
MOV SI,FileNameEntry
PUSH DI
MOV DI,FileName
CALL StringCompare
POP DI
JC .EndOfTheLine
MOV SI,TheEndOfTheLine
CALL PrintString
MOV EAX,[FileSector]
MOV [DiskAddressPacket.End],EAX
MOV EAX,[FileSize]
XOR EDX,EDX
MOV EBX,2048
DIV EBX
INC EAX
MOV [DiskAddressPacket.SectorsToRead],AX
if defined DEBUG_MESSAGES
MOV CL,16
CALL ToHex
MOV SI,HexBuffer
Call PrintString
MOV SI,AddTheHAtTheEnd
CALL PrintString
MOV SI,TheEndOfTheLine
CALL PrintString
MOV EAX,[FileSector]
MOV CL,32
CALL ToHex
MOV SI,HexBuffer
CALL PrintString
MOV SI,AddTheHAtTheEnd
CALL PrintString
MOV SI,TheEndOfTheLine
call PrintString
end if
MOV DL,[CDDriveNumber]
MOV AH,42h
MOV SI,DiskAddressPacket
INT 13h
JC Failure
MOV DL,[CDDriveNumber]
PUSH WORD 0202h
PUSH WORD 0000h
RETF
.EndOfTheLine:
MOV SI,TheEndOfTheLine
CALL PrintString
XOR CX,CX
MOV CL,[DirectoryEntrySize]
ADD DI,CX
CMP byte [ES:DI],0
JE .End
XOR CX,CX
MOV BX,FileNameEntry
.ClearFileNameEntry:
MOV byte [DS:BX],0
INC BX
INC CX
CMP CX,254
JB .ClearFileNameEntry
MOV byte [DS:BX],0
INC byte [FileEntryNumber]
JMP .GrabDirectoryEntry
.End:
RET
PrintString:
PUSHA
.Loop:
LODSB
OR AL,AL
JZ .Done
MOV AH,0Eh
MOV BH,0
MOV BL,7
INT 10h
JMP .Loop
.Done:
POPA
RET
StringCompare:
PUSH SI
PUSH DI
.Loop:
MOV AL,[SI]
MOV BL,[DI]
CMP AL,BL
JNE .NotEqual
CMP AL,0
JE .Done
INC DI
INC SI
JMP .Loop
.NotEqual:
STC
JMP .End
.Done:
CLC
.End:
POP DI
POP SI
RET
StringLength:
XOR EAX,EAX
.Loop:
CMP byte [ESI+EAX],0
JE .End
INC EAX
JMP .Loop
.End:
RET
DirectoryEntrySize: db 0
FileSector: dd 0
FileSize: dd 0
FileNameLength: db 0
FileNameEntry: TIMES 255 db ' '
FileEntryNumber: db 0
DriveDisplayMessage: db 'Volume in drive: ',0
HasNoLabel: db 'no label',0
FileNamePointer: dw 0
DataSector: DW 0
CDDriveNumber: db 0
RootDirectorySector dd 0
absoluteSector: DB 0
absoluteHead: DB 0
absoluteTrack: DB 0
BootDotNumber: DB '1'
Cluster: DW 0
FileName: DB 'KERNEL',0
VersionEnhancedDiskDriveExtensions: db 0
InternalUseEnhancedDiskDriveExtensions: db 0
InterfaceSupportBitMask: dw 0
EnhancedDiskDriveVersionMessage: db ' - Enhanced Disk Drive Extensions Version Number.',13,10,0
DirectoryEntrySizeMessage: db ' - Directory entry size.',13,10,0
DiskResultsBufferMessage: db 'Disk Buffer on in here...',13,10,0
IsEqualToTheCX db ' = CX contents from INT 13h Function 41h.',13,10,0
IsEqualToTheEAX db ' = EAX contents is the sector of the root directory contents.',13,10,0
WelcomeMessage: DB 'smiddy OS CD boot v1.00',225,13,10,0 ; Version of CD-Boot
FailureMessage: db 'Failure: ',0
DriveNumberReported: db 'Drive number reported: ',0
PressAnyKeyMessage: db 'Press any key to reboot...',13,10,0
AddTheHAtTheEnd: db 'h',0
TheEndOfTheLine: db 13,10,0
SizeOfPacketInBytes: db 'The size of packet in bytes: ',0
BootMediaType: db 'The boot media type: ',0
DriveNumberFromPacket: db 'Drive number from packet: ',0
VolumeLabel: TIMES 33 db 0 ; Where the volume label is stored
DiskAddressPacket: db 16,0
.SectorsToRead: dw 1
.Offset: dw 0
.Segment: dw 0202h
.End: dq 16
ResultsBuffer: times 30 db 0
HexBuffer: DB 0,0,0,0,0,0,0,0,0
TheEAX: dd 0
TheCL: db 0
TIMES 2046-($-BootSector) DB 0
DW 0AA55h
in pratica , compilando questo codice con nasm ottengo un fine bin , un'immagine di boot che inserisco nel settore di boot di un cd rom , in modo tale che all'avvio del cd venga eseguito.
Cosi' ottengo svariate informazioni ma non l'avvio del kernel . Per quale motivo?