Mixing 32 bit calculation in 16 bit program NASM
Posted: Tue Dec 28, 2010 2:11 pm
I am a n00b in this case, and really don't know how to do it. so it would be great if u kindly show me the right way to do it.
For instance the following instructions provides wrong result, how to make it right ?? (i heard something of 0x66 prefix and incase of address 0x67 -- but how to use them ??)
Code:
Rest of my code is right coz the result (EAX after those instruction) should be 969434 and if i put it directly it gives desired result. But the formula isn't wrong either, plz help me understand mixing up 32 Bit calculation in 16 bit program.
The formula i am using is
LBA_addr = offset_from_partition_table + DataAreaStart + (cluster_no - 2) * sectors_per_cluster
In my code
offset_from_partition_table = LBAStart
DataAreaStart = DataAreaStart
cluster_no = AX
sectors_per_clusetr = SectorsPerCluster
Just assume other values of my bootloaders are correct, i have tested it.
U c the Sector Number field of DAP and the LBAStart is both DWORD so had no way but resort to EAX.
Regards and thanx in advance.
For instance the following instructions provides wrong result, how to make it right ?? (i heard something of 0x66 prefix and incase of address 0x67 -- but how to use them ??)
Code:
Code: Select all
;; just to remind you [BITS 16]
AND EAX, 0x0000FFFF
SUB EAX, 2
XOR ECX, ECX
MOV CL, [SectorsPerCluster]
MUL ECX
ADD EAX, DWORD [DataAreaStart]
ADD EAX, [LBAStart]
;MOV EAX, 969434
MOV [DAP + 8], EAX
CALL ReadSectorsLBA_
The formula i am using is
LBA_addr = offset_from_partition_table + DataAreaStart + (cluster_no - 2) * sectors_per_cluster
In my code
offset_from_partition_table = LBAStart
DataAreaStart = DataAreaStart
cluster_no = AX
sectors_per_clusetr = SectorsPerCluster
Just assume other values of my bootloaders are correct, i have tested it.
U c the Sector Number field of DAP and the LBAStart is both DWORD so had no way but resort to EAX.
Regards and thanx in advance.