Originally Posted by
matsp
Signed and unsigned values are only different in two situations:
1. Translation between binary and string in either direction (e.g printf, scanf, strtol, etc).
2. Comparisons of greater/lesser (e.g 2^15 > 2^14 in unsigned, but not in signed values).
So if you say you "get a signed value in an unsigned variable", I suspect you are using %d to print it, and you should be using %u or %x, which are unsigned formats.
Or you are comparing two unsigned values and getting the wrong result because the compiler generates the wrong comparison code.
Without seeing the code, it would be impossible to comment on what is correct and what isn't. But my guess is that you are simply using a "binary to string" conversion that uses the wrong interpretation.
Also: If you are running in a Windows "DOS box", INT 13H is not a low-level function, it just pretends to be, it still uses the OpenFile/ReadFile/WriteFile/CloseFile I/O functions that any Windows program would use. Of course, if you are using plain DOS or some other real-mode OS, then yes, you are calling directly to the real BIOS code (unless it has somehow been replaced by some other driver code, which is entirely possible in DOS).
--
Mats
Mats,
Below is a small section of code that the problem is occurring in:
Code:
find_offset(sect, cyl, hd)
unsigned long sect, hd, cyl;
{
char sectorsize = 512;
unsigned long offset = 0;
sect = 3;
hd = 1;
cyl = 6;
offset = (cyl*2)*18;
printf("offset = %d\n", offset);
if(hd == 1)
{
offset = (offset + 18);
}
printf("offset = %u\n", offset);
offset = (offset + sect);
printf("offset = %u\n", offset);
offset = (offset * 512);
printf("offset = %u\n", offset);
offset = (offset - 512);
printf("offset = %u\n", offset);
return(offset);
the printf statements previously contained %d values as you pointed out but once consulting the manual and changing these to %u I am no longer getting negative values but instead i am now getting the wrong value. In the last printf statement i should have the value of 120832 but instead i am getting 55296.
Also as you pointed out the DOS environment does pretend to use INT13h as a low level call but I am using assembler language within an ASM function to make the calls to the disk.
Regards,
Dinklebaga