Mixing 32 bit calculation in 16 bit program NASM

Hello all, i am new here and this is my first post. 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 ??
Code:
;; 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_
My code is right coz the result 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. Regards and thanx in advance.
 
How do you expect anyone to answer without telling what are you trying to calculate, and giving examples of input and output data of what you expect and what you actually get?

BTW: This is probably wrong forum (should ask on some asm forum instead of FreeBSD forum)
And it's defiantly wrong section
 
umm sorry, i am trying to get the starting LBA of a cluster.
The formula i am using is
starting_LBA = offset_from_partition_table + data_area_start + (cluster_no - 2) * sector_per_cluster

in my code:
offset_from_partition_table = LBAStart
data_area_start = DataAreaStart
cluster_no = AX
sector_per_cluseter = SectorsPerCluster

and in my code DAP is the DiskAddressPacket for LBA read (int 0x13 ah = 0x42).
and plz don't suggest using 32 bit code, as i have to have to do it in 16 bit code.
And the EAX comes in play as the file i am trying to find may be situated long distance from start (big LBA). Plz help. And Thanx for replying. :D
 
And yeah LBAStart is a DWORD value and so is the sector number field of DAP, so i have no choice but resort to EAX.
P.S. : I am not sure, which value i am getting as i am starting and restarting my pc each time to test instead of VMS. But its certainly not 969434 (where the kernel is). Elemeneting the top half of EAX i get is 346, (printed in binary form).
 
You run it on read PC?
I have suggestion for you:
1) User virtual machine
2) user qmeu

qemu has building debugger, so once you master it (I haven't used qemu debugger), you can actually see what is going on with your code.
Qemu downside is low speed, so installing Vista would take forever

Also for which os are you doing this (not important, but still curious)
 
Yeah i could do that but the point is i don't understand how the mixing up of 32 bit register with 16 bit code is done actually (heard of prefixing with 0x66 in case of address 0x67 etc but no real sample to learn from). which OS, (under win xp sp2 the development is going on), and my OS is nothing but a desire to learn. I dont use VMS because i don't know how to configure it to boot from USB. :D regards and plz help regarding the actual topic sir.
 
Yeah i get your point. But I came here step by step, all other values are tested by printing integer, yeah i could afford that coz then the bootloader size was really small. But yeah, i guess i do need a debugger. Thanx for ur help :D. But still u could have tought me how to mix 32 bit calculation within 16 bit program though. Regards and thanx. :D
 
If no one can come up with any relevance to the FreeBSD operating system I will delete this topic.
 
Back
Top