int13h read question
Posted: Sat Jul 21, 2012 5:40 am
Hello, I´m writting my own bootloader and I have a question.
My print_n function:
My question is at this pointer:
How can I access to the memory read by the int 13h?
Sorry for my poor English.
Code: Select all
[bits 16]
[ORG 0]
jmp short start
nop ; No Operation (1 byte)
OEMLabel: db "KERNEL " ; 8 characters padded with spaces
BytesPerSector: dw 512 ; Bytes per sector
SectorsPerCluster: db 1 ; Sectors per cluster
ReservedSectors: dw 1 ; Reserved Sectors (for sector 0)
NumberOfFATs: db 2 ; Number of FAT´s
MaxRootEntries: dw 224 ; Number of Root Entries
NumberOfSectors: dw 2880 ; Number of sectors
DeviceDescriptor: db 0xF0 ; Device Descriptor 0xF0 => 1.44 MB floppy image
SectorsPerFAT: dw 9 ; Sectors Per FAT
SectorsPerTrack: dw 18 ; Sectors Per Track
Sides: dw 2 ; Sides of disk
HiddenSectors: dd 0 ; Number of Hidden Sectors
LengthOfSectors: dd 0 ; Length of sectors
DriveNo: db 0 ; Drive Number (0 or 1)
Flags: db 0 ; Additional flags
Signature: db 0x14 ; Signature, some number of 1 byte
VolumeID: dd 0xAABBCCDD ; Volume ID
VolumeLabel: db "DISCO TANIS " ; 11 characters padded with spaces
FileSystem: db "FAT12 " ; 8 characters padded with spaces
;**********************************************************;
; Entry Point
; Reset the floppy disk.
; Calculate the root directory CHS address and jump to
; read_root_directory.
;**********************************************************;
start:
jmp 07C0h:stage_1
stage_1:
mov ax, cs
mov ds, ax
mov es, ax
mov si, StringMsg
call print_string
xor ah, ah ; Ah = 0, reset function
mov dl, BYTE [DriveNo]
int 13h ; Reset Floppy Disk
xor ax, ax
add ax, WORD [SectorsPerFAT]
mul BYTE [NumberOfFATs]
add ax, WORD [ReservedSectors]
; AX = (SectorsPerFAT * NumberOfFATs) + ReservedSectors
call lba2chs
jmp short read_root_directory
read_root_directory:
; We have already calculated the CH = Cilynder, CL = sector and
; DH = Head.
mov ax, 1000h
mov es, ax
mov bx, 0
mov ah, 02h ; Read mode
mov al, 0Fh ; Sectors to read (512 bytes each sector)
mov dl, BYTE [DriveNo]
int 13h ;Call the interruption!
jc .root_dir_read_error
mov si, [1000h]
mov dx, 512
call print_n
...
Code: Select all
;**********************************************************;
; Print a string in screen
; SI => String pointer
; DX => Number of characters to print
;**********************************************************;
print_n:
push ax
push bx
push cx
mov ah, 0Eh
xor cx, cx
.loop:
mov al, [si]
int 10h
inc cx
cmp cx, dx
je short .end_loop
inc si
jmp short .loop
.end_loop:
pop ax
pop bx
pop cx
ret
Code: Select all
mov si, [1000h]
mov dx, 512
call print_n
Sorry for my poor English.