Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ---------------------------[bryoboot1.asm]--------------------
- ; 1. constants
- ; 2. directives
- ; + fat12 header
- ; 3. main
- ; 4. functions
- ; 5. messages
- ; 6. footer
- ; ---------------------------[CONSTANTS]------------------------
- BL1_ADDR equ 0x7c00 ; origin address of loader1
- BL2_ADDR equ 0x7fee ; origin address of loader2
- BL2_c equ 0 ; cylinder for bl2
- BL2_h equ 0 ; head for bl2
- BL2_s equ 2 ; sector for bl2
- BL2_sec_count equ 1 ; Number of sectors to read
- ; Drive number is autoset by BIOS
- CR equ 0x0d ; Carriage Return
- LF equ 0x0a ; Line feed/ Newline
- ;----------------------------[DIRECTIVES]------------------------
- org BL1_ADDR ; origin
- bits 16 ; real mode 16 bit
- ;----------------------------[FAT12 HEADER]----------------------
- jmp main ; First two bytes - jump to main
- nop ; Null byte making the begining 3 bytes
- bpb_oem: db 'bryoboot' ; oem header 8 bytes
- bpb_bps: dw 512 ; bytes per sector
- bpb_sps: db 1 ; sectors per cluster
- bpb_rs: dw 1 ; reserved sector - 1 for bryoboot1
- bpb_fc: db 2 ; number of file allocation tables
- bpb_dir_ent: dw 0xe0 ; number of dir entries
- bpd_ts: dw 2880 ; Total sectors
- bpb_md: dw 0xf0 ; Type of disk/Media descriptor
- bpb_spt: dw 18 ; Sectors per track
- bpb_hc: dw 2 ; head count
- bpb_hsc: dw 0 ; hidden sector count
- bpb_lsc: dw 0 ; Large sector count
- drive_num: dw 0 ; Drive number, floppy 0
- db 0 ; reserved
- signature: db 0x29
- volume_id:
- db 0x0,0x0,0x0,0x0 ; volume id - irrelevant to functionality
- volume_label:
- db ' BRYO BOOT ' ; space padded 11 bytes
- sysID: db 'FAT12 ' ; space padded 8 bytes
- ;----------------------------[MAIN]------------------------------
- main:
- ; Segmentation registers setup
- xor ax,ax
- mov ds,ax
- mov es,ax
- mov ss,ax
- ; Printing Initial Boot message
- mov si,initial_boot_msg
- call print
- ; Attempt to load bl2
- call bl2_loader
- jmp $
- ;----------------------------[FUNCTIONS]--------------------------
- print:
- .loop:
- lodsb
- or al,al
- jz .break
- mov ah,0x0e
- int 0x10
- jmp .loop
- .break:
- ret
- bl2_loader:
- mov al,0x02 ; BIOS Read function
- mov al,BL2_sec_count ; How many Sectors to read
- ; CHS address
- mov ch,BL2_c
- mov dh,BL2_h
- mov cl,BL2_s
- mov bx,BL2_ADDR/16 ; Loading second stage address
- mov es,bx ; Pointing to extra segment from disk with es
- xor bx,bx
- int 0x13
- jc .drive_read_err
- jmp BL2_ADDR/16 : 0 ; Jumping to second loader
- .drive_read_err:
- mov si, drive_error_msg
- call print
- jmp $
- ;-----------------------------[MESSAGES]--------------------------
- initial_boot_msg:
- db '[BL1] BRYOBOOT loaded sucessfully',CR,LF,0
- drive_error_msg:
- db '[BL1] DISK READING ERROR - Couldnt Load BL2',CR,LF,0
- ;-----------------------------[FOOTER]----------------------------
- times 510-($-$$) db 0 ; Padding to 512 bytes
- dw 0xaa55 ; Magic Number for BIOS identification
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement