I have been working on my Verbum project (a legacy BIOS boot loader that loads off a floppy image) and have come across an odd problem. I have written some diagnostics to show the memory map as collected via INT 0x15, EAX=E820, including a section which prints the descriptive explanation of what a given entry type is.
However, as you can see in the screenshot, after the first entry, each subsequent entry has an unwanted digit '1' before the length, type, and extended information fields. I can't seem to figure out where these digts are coming from, and why they are appearing where they are. Any advice on this would be appreciated.
the relevant code (not including the support functions for printing values) is:
Code: Select all
;;; print_hi_mem_map - prints the memory table
;;; Inputs:
;;; BP = the number of entries found
;;; [DI] = the memory map table
;;; Outputs:
;;; screen
;;; Clobbers:
;;; AX, CX, SI
print_hi_mem_map:
jc .failed ; if the interrupt isn't supported, fail
cmp bp, 0
jz .failed ; if there are no valid entries, fail
write mmap_prologue
mov si, print_buffer ; print the description of the section...
push ax
mov ax, bp
call print_decimal_word ; including the number of entries found...
write mmap_entries_label
pop ax
write mmap_headers ;and the headers for the columns.
write mmap_separator
mov cx, bp ; set the # of entries as the loop index
push si
push di
.loop:
; write each of the structure fields with a spacer separating them
push di
add di, High_Mem_Map.base ; print the base value
call print_hex_qword
write mmap_space
pop di
push di
add di, High_Mem_Map.length ; print the length value
call print_hex_qword
write mmap_space
pop di
push di
add di, High_Mem_Map.type ; use the type value as an index into the array of strings
mov si, mmap_types ; get the array head
mov ax, [di] ; get the offset
mov bl, mmap_types_size ; multiply the offset by the size of the array elements
imul bl
add si, ax ; print the appropriate array element
call print_str
write lparen ; print the actual value of the type in parentheses
mov si, print_buffer
mov ax, [di]
call print_decimal_word
write rparen
write mmap_space
pop di
push di
add di, High_Mem_Map.ext ; print the extended ACPI 3.x value
mov ax, [di]
call print_decimal_word
write newline
pop di
add di, ext_mmap_size ; advance to the next entry
loop .loop
.finish:
pop di
pop si
ret
.failed:
write mmap_failed
ret