Assembler coding help needed.
Martin Nilsson
martin at gneto.com
Sun Jan 11 05:52:41 PST 2004
I'm trying to find out why I can't boot 5.2 from USB CDROM on Supermicro
motherboards. (I have an old Gateway P3 that can!).
I've found out that that only 0x20 of 0x4c sectors of the loader are
read in and it therfor traps when executed. (read is only called once).
My last attempt at programming x86 assembler was ~15years ago so I'm a
bit rusty :-)
The below loop from cdboot.s is what I'm having problem understanding,
how can this fail on one box but not on another?
#
# Load the binary into the buffer. Due to real mode addressing limitations
# we have to read it in in 64k chunks.
#
mov DIR_SIZE(%bx),%eax # Read file length
add $SECTOR_SIZE-1,%eax # Convert length to sectors
shr $11,%eax
%eax is 0x4c here on both machines!
cmp $BUFFER_LEN,%eax
jbe load_sizeok
mov $msg_load2big,%si # Error message
call error
load_sizeok: movzbw %al,%cx # Num sectors to read
mov DIR_EXTENT(%bx),%eax # Load extent
xor %edx,%edx
mov DIR_EA_LEN(%bx),%dl
add %edx,%eax # Skip extended
mov $MEM_READ_BUFFER,%ebx # Read into the buffer
load_loop: mov %cl,%dh
cmp $MAX_READ_SEC,%cl # Truncate to max read size
jbe load_notrunc
mov $MAX_READ_SEC,%dh
load_notrunc: sub %dh,%cl # Update count
push %eax # Save
call read # Read it in
pop %eax # Restore
add $MAX_READ_SEC,%eax # Update LBA
add $MAX_READ,%ebx # Update dest addr
jcxz load_done # Done?
jmp load_loop # Keep going
load_done:
More information about the freebsd-hackers
mailing list