fix: set_mem_size: use right index

This commit is contained in:
Starnakin 2024-11-08 13:15:15 +01:00
parent 3c87632b0c
commit 719c615c92

View File

@ -4,24 +4,25 @@
.global set_mem_size .global set_mem_size
set_mem_size: set_mem_size:
xor ebx, ebx jmp end_mem
xor ebx, ebx // i = 0
.L1: .L1:
// loop condition // loop condition
cmp ebx, [eax + 64] cmp ebx, [eax + 44] // mbd->mmap_length
jge end_mem jge end_mem
// declare mmmt // declare mmmt
mov ecx, [eax + 68] mov ecx, [eax + 48] // mbd->mmap_addr
add ecx, ebx add ecx, ebx // + i
// check if the mmmt->type is available (1) // check if the mmmt->type is available (1)
cmp DWORD PTR [ecx + 20], 1 mov edx, [ecx + 20]
cmp edx, 1
jne .L2 jne .L2
// add the size of the block // add the size of the block
mov edx, [ecx + 12] mov edx, [ecx + 0] // mmmt->size
add DWORD PTR mem_size, edx add mem_size, edx
mov edx, [ecx + 16]
add DWORD PTR mem_size + 4, edx
.L2: .L2:
add ebx, 24 add ebx, 24 // i += sizeof(multiboot_memory_map_t)
jmp .L1 jmp .L1