Question on clearing RAM
Posted: Sun Sep 08, 2013 10:29 am
I am running into a problem that I have never had before...
I am trying to clear the RAM from 0x0000:0x0000 to 0x0000:0x0100 in x86 real mode. To do this I built a loop, but my loop is only running 0x40 times... Any ideas?
Note: FS has already been set to 0x0000 when I setup my stacks.
I am trying to clear the RAM from 0x0000:0x0000 to 0x0000:0x0100 in x86 real mode. To do this I built a loop, but my loop is only running 0x40 times... Any ideas?
Note: FS has already been set to 0x0000 when I setup my stacks.
Code: Select all
;Clear ram from 0x0000 to 0x0100
mov bx, 0x0000 ;Counter
.clear_loop:
mov byte [fs:bx], 0x00 ;Clear value at (FS:BX) 0x0000:BX
inc bx ;Increment counter, BX
%if DEBUG_CLEAR_LOOP_PRINT_ADDRESS
push bx ;Store BX, counter
mov dx, bx ;Move BX into DX for print of counter
mov bx, 0x000F ;Bios color white for print
call print_dx ;Print DX, value of counter
pop bx ;Restore BX, counter
%endif
;Check if done
cmp bx, 0x0100
jbe .clear_loop ;If BX is less than or equal to 0x0100, go back to .clear_loop
;if done continue on...