diff --git a/x86_64/bootsector.asm b/x86_64/bootsector.asm index 80e40e834f28e0db13a7c9e812b0a1e1c04bdb5a..8ae4db3d00d547b4a68fc80db20a78d92543209d 100644 --- a/x86_64/bootsector.asm +++ b/x86_64/bootsector.asm @@ -86,45 +86,6 @@ load: jc error ret - ; store some sectors to disk from a buffer in memory - ; buffer has to be below 1MiB - ; IN - ; ax: start sector - ; bx: offset of buffer - ; cx: number of sectors (512 Bytes each) - ; dx: segment of buffer - ; CLOBBER - ; ax, bx, cx, dx, si - ; TODO rewrite to (eventually) move larger parts at once - ; if that is done increase buffer_size_sectors in startup-common to that (max 0x80000 - startup_end) - store: - cmp cx, 127 - jbe .good_size - - pusha - mov cx, 127 - call store - popa - add ax, 127 - add dx, 127 * 512 / 16 - sub cx, 127 - - jmp store - .good_size: - mov [DAPACK.addr], eax - mov [DAPACK.buf], bx - mov [DAPACK.count], cx - mov [DAPACK.seg], dx - - call print_dapack - - mov dl, [disk] - mov si, DAPACK - mov ah, 0x43 - int 0x13 - jc error - ret - print_dapack: mov al, 13 call print_char diff --git a/x86_64/config.asm b/x86_64/config.asm index 8e3b220c667dcf69501d18e04613ad0112937485..80e35e160ecf5095bd9d8fa15d39490c03df9d9a 100644 --- a/x86_64/config.asm +++ b/x86_64/config.asm @@ -16,3 +16,42 @@ save_config: xor dx, dx call store ret + +; store some sectors to disk from a buffer in memory +; buffer has to be below 1MiB +; IN +; ax: start sector +; bx: offset of buffer +; cx: number of sectors (512 Bytes each) +; dx: segment of buffer +; CLOBBER +; ax, bx, cx, dx, si +; TODO rewrite to (eventually) move larger parts at once +; if that is done increase buffer_size_sectors in startup-common to that (max 0x80000 - startup_end) +store: + cmp cx, 127 + jbe .good_size + + pusha + mov cx, 127 + call store + popa + add ax, 127 + add dx, 127 * 512 / 16 + sub cx, 127 + + jmp store +.good_size: + mov [DAPACK.addr], eax + mov [DAPACK.buf], bx + mov [DAPACK.count], cx + mov [DAPACK.seg], dx + + call print_dapack + + mov dl, [disk] + mov si, DAPACK + mov ah, 0x43 + int 0x13 + jc error + ret