Thursday, July 24, 2008

ASM: Assume Nothing

Assume nothing... except the location at which your code has been loaded and the boot drive in register dl. That's what Frank Kotler tells me when debugging one of my bootloaders when I tried to write a bootloader a whole decade after I stopped work with assembly language.

The problem I encountered was quite odd. I had my bootloader jumping to the right labels, writing characters just fine when I fed in the ASCII values to the registers via code, but when I tried to move something from a memory location it just gave me zeroes for data.

The fix was to set the ds register to the same location as the cs register and that got things working for me. Surprisingly, I didn't find any other examples on the 'net that mention about it - they have pretty much similar code to what I had in the beginning. Maybe I encountered the issue as I was using VMWare instead of a true PC.

No comments: