1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
BITS 16
start:
mov ax, 07C0h ; Set up 4K stack space after this bootloader
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096
mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax
mov si, text_string ; Put string position into SI
call print_string ; Call our string-printing routine
jmp find
jmp $ ; Jump here - infinite loop!
text_string db 'Ram contents from 0x7c0:0x0000 are : ', 0
ram_byte db 65
print_string: ; Routine: output string in SI to screen
mov ah, 0Eh ; int 10h 'print char' function
.repeat:
lodsb ; Get character from string
cmp al, 0
je .done ; If char is zero, end of string
int 10h ; Otherwise, print it
jmp .repeat
.done:
ret
find:
mov cx,65535
mov edx,0
again:
mov al,[edx]
cmp al,0
jne print
inc edx
dec cx
cmp cx,0
jne again
hlt
print:
mov ah,0eh
mov cx,512
print_again: mov al,[edx]
int 10h
inc edx
dec cx
cmp cx,0
jne print_again
sub edx,512 ;Make edx equal to the loaction where it first found the non-zero byte
ror edx,24 ;
mov al,dl ;
int 10h ;
rol edx,8 ;
mov al,dl ;
int 10h ;
rol edx,8 ; Output the contentes of edx
mov al,dl ;
int 10h ;
rol edx,8 ;
mov al,dl ;
int 10h ;
jmp $ ; Jump here
times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s
dw 0xAA55 ; The standard PC boot signature
|