pbs: dont rely on chainloader to hand us a partition table and properly get the partition offset from nhidden in the fat header, add compare after mul because MUL doesnt set ZF but makes it undefined!
parent
e3e5702780
commit
cd5cef000f
|
@ -36,8 +36,10 @@ TEXT _nhiddenhi(SB), $0
|
||||||
TEXT _bigvolsize(SB), $0
|
TEXT _bigvolsize(SB), $0
|
||||||
BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x00;
|
BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x00;
|
||||||
/* FAT32 structure, starting @0x24 */
|
/* FAT32 structure, starting @0x24 */
|
||||||
TEXT _fatsz32(SB), $0
|
TEXT _fatsz32lo(SB), $0
|
||||||
BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x00
|
BYTE $0x00; BYTE $0x00
|
||||||
|
TEXT _fatsz32hi(SB), $0
|
||||||
|
BYTE $0x00; BYTE $0x00
|
||||||
TEXT _extflags(SB), $0
|
TEXT _extflags(SB), $0
|
||||||
BYTE $0x00; BYTE $0x00
|
BYTE $0x00; BYTE $0x00
|
||||||
TEXT _fsver(SB), $0
|
TEXT _fsver(SB), $0
|
||||||
|
@ -76,14 +78,12 @@ _start0x5A:
|
||||||
MTSR(rAX, rES)
|
MTSR(rAX, rES)
|
||||||
|
|
||||||
LWI(0x100, rCX)
|
LWI(0x100, rCX)
|
||||||
MW(rSI,rBX) /* address of partition record -> rBX */
|
|
||||||
LWI(RELOC, rSI)
|
LWI(RELOC, rSI)
|
||||||
MW(rSI, rSP)
|
MW(rSI, rSP)
|
||||||
LWI(_magic(SB), rDI)
|
LWI(_magic(SB), rDI)
|
||||||
CLD
|
CLD
|
||||||
REP; MOVSL /* MOV DS:[(E)SI] -> ES:[(E)DI] */
|
REP; MOVSL /* MOV DS:[(E)SI] -> ES:[(E)DI] */
|
||||||
|
|
||||||
PUSHA
|
|
||||||
MW(rSP, rBP)
|
MW(rSP, rBP)
|
||||||
|
|
||||||
PUSHR(rCX)
|
PUSHR(rCX)
|
||||||
|
@ -96,39 +96,41 @@ _halt:
|
||||||
|
|
||||||
TEXT start16(SB), $0
|
TEXT start16(SB), $0
|
||||||
STI
|
STI
|
||||||
|
|
||||||
LWI(hello(SB), rSI)
|
LWI(hello(SB), rSI)
|
||||||
CALL16(print16(SB))
|
CALL16(print16(SB))
|
||||||
|
|
||||||
PUSHR(rDX)
|
PUSHR(rDX) /* drive */
|
||||||
PUSHR(rBX)
|
|
||||||
|
|
||||||
LB(_nfats(SB), rCL) /* # of fats */
|
CLR(rDX)
|
||||||
LW(_fatsize(SB), rAX) /* fat size */
|
LW(_fatsize(SB), rAX)
|
||||||
MUL(rCX) /* DX:AX = #sectors */
|
CLR(rCX)
|
||||||
JNE _fatszok /* zero? it's FAT32 */
|
LB(_nfats(SB), rCL)
|
||||||
|
MUL(rCX)
|
||||||
|
OR(rCX, rCX)
|
||||||
|
JNE _fatszok /* zero? it's FAT32 */
|
||||||
|
|
||||||
LW(_fatsz32+2(SB), rBX) /* hi word */
|
LW(_fatsz32hi(SB), rBX)
|
||||||
IMUL(rCX, rBX) /* ... in sectors */
|
IMUL(rCX, rBX)
|
||||||
LW(_fatsz32(SB), rAX) /* lo word */
|
LW(_fatsz32lo(SB), rAX)
|
||||||
MUL(rCX) /* ... in sectors */
|
MUL(rCX)
|
||||||
ADD(rBX, rDX) /* DX:AX = #sectors */
|
ADD(rBX, rDX)
|
||||||
|
|
||||||
_fatszok:
|
_fatszok:
|
||||||
POPR(rBX) /* address of partition record */
|
LW(_nhiddenlo(SB), rCX)
|
||||||
|
|
||||||
LXW(8, xBX, rCX) /* lo partition LBA */
|
|
||||||
ADD(rCX, rAX)
|
ADD(rCX, rAX)
|
||||||
LXW(10, xBX, rCX) /* hi partition LBA */
|
LW(_nhiddenhi(SB), rCX)
|
||||||
ADC(rCX, rDX)
|
ADC(rCX, rDX)
|
||||||
|
|
||||||
CLR(rBX)
|
CLR(rBX)
|
||||||
LW(_nresrv(SB), rCX) /* # of reserved */
|
LW(_nresrv(SB), rCX)
|
||||||
ADD(rCX, rAX)
|
ADD(rCX, rAX)
|
||||||
ADC(rDX, rBX)
|
ADC(rDX, rBX)
|
||||||
|
|
||||||
SW(rAX, _volid(SB)) /* save for later use */
|
SW(rAX, _volid(SB)) /* save for later use */
|
||||||
SW(rDX, _volid+2(SB))
|
SW(rBX, _volid+2(SB))
|
||||||
POPR(rDX)
|
|
||||||
|
POPR(rDX) /* drive */
|
||||||
|
|
||||||
PUSHR(rBP)
|
PUSHR(rBP)
|
||||||
LW(_sectsize(SB), rCX)
|
LW(_sectsize(SB), rCX)
|
||||||
|
@ -164,7 +166,7 @@ _nextdir:
|
||||||
JMP _nextsect
|
JMP _nextsect
|
||||||
|
|
||||||
_found:
|
_found:
|
||||||
PUSHR(rDX)
|
PUSHR(rDX) /* drive */
|
||||||
|
|
||||||
CLR(rBX)
|
CLR(rBX)
|
||||||
|
|
||||||
|
@ -208,7 +210,7 @@ _found:
|
||||||
MW(rAX, rCX)
|
MW(rAX, rCX)
|
||||||
POPR(rBX)
|
POPR(rBX)
|
||||||
POPR(rAX)
|
POPR(rAX)
|
||||||
POPR(rDX)
|
POPR(rDX) /* drive */
|
||||||
|
|
||||||
LWI(RELOC, rSI)
|
LWI(RELOC, rSI)
|
||||||
PUSHR(rSI)
|
PUSHR(rSI)
|
||||||
|
|
Loading…
Reference in New Issue