Browse Source

Start to use this repo as submodule

master
Rhodez-x 7 years ago
parent
commit
259be82bc8
  1. 11
      notes.txt
  2. 131
      slrboot.nasm

11
notes.txt

@ -11,11 +11,18 @@
0x0017: mov cx, 0x200
0x001a: rep movsb byte ptr es:[di], byte ptr [si]
0x001c: ljmp 0:0x621
0x0021: mov si, 0x7be
0x0024: cmp byte ptr [si], al
0x0026: jne 0x33
0x0028: add si, 0x10
0x002b: cmp si, 0x7fe
0x002f: jne 0x24
0x0031: jmp 0x49
0x0033: mov ah, 2
@ -27,3 +34,7 @@
0x0042: int 0x13
0x0044: ljmp 0:0x7c00
0x0049: jmp 0x49
// This is test for workshop.

131
slrboot.nasm

@ -3,25 +3,28 @@ BITS 16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SLRboot
; Bootloader for SingOS
; version 0.2.0.0-exp
; version 0.2.0.3-exp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cli
mov [disk_identifier], dl
cli
jmp long 0x0000:start
start:
mov ax, 0x1000
mov ss, ax
mov sp, 0xb000
mov ax, 0
mov ds, ax
mov es, ax
sti
mov [disk_identifier], dl
sti
mov si, 0x7c00
mov di, 0x600
mov cx, 0x200
rep movsb
mov cx, 0x100
rep movsw
mov bx, relocated
sub bx, 0x7600 ; Calculate the offset.
sub bx, 0x7600 ; Calculate the offset.
push bx
retf ; Return far
ret ; Return far
;jmp long 0:bx
relocated:
@ -29,34 +32,29 @@ relocated:
mov si, message ; Put address of the null-terminated string to output into 'si'
call print ; Call our string-printing routine
;mov ax, 0x0050
;mov es, ax ;Section to write into
;mov ah, 0x2 ;Read sectors from drive
;mov al, 0x08 ;Number of sectors to read (31 * 512 = 15872 bytes)
;mov ch, 0x0 ;Low 8 bits of cylinder
;mov cl, 0x11 ;First sector to read (bits 0-5), upper bits of cylinder (bits 6-7)
;mov dh, 0x0 ;Head number
;mov dl, [disk_identifier] ;Drive number
;mov bx, 0x0000 ;Offset into section
;int 0x13 ;Low level disk services
mov ah, 2
mov al, 0x08
mov bx, 0x7c00
mov BYTE dl, [disk_identifier]
mov BYTE dh, [partition_2.start_CHS + 1] ;byte [si + 1]
mov BYTE cl, [partition_2.start_CHS + 2]
mov BYTE ch, [partition_2.start_CHS] ;First sector to read (bits 0-5), upper bits of cylinder (bits 6-7)
mov bx, [partition_1.start_LBA]
mov WORD [DAPACK.lba_addr_dw_low], bx
mov bx, [partition_1.start_LBA + 1]
mov WORD [DAPACK.lba_addr_dw_low + 1], bx
mov bx, [partition_1.start_LBA + 2]
mov WORD [DAPACK.lba_addr_dw_low + 2], bx
mov bx, [partition_1.start_LBA + 3]
mov WORD [DAPACK.lba_addr_dw_low + 3], bx
mov WORD [DAPACK.blkcnt], 0x01
mov WORD [DAPACK.db_addr_segment], 0x0000
mov WORD [DAPACK.db_addr_offset], 0x7c00
mov si, DAPACK ; address of "disk address packet"
mov ah, 0x42 ; READ
mov dl, [disk_identifier]
int 0x13
;mov ax, 0x0
;mov ds, ax
mov ax, 89 ; lba adress
jmp long 0x0:0x7c00
cli
hlt
%IF 1
%IF 0
cli
jmp long 0x0000:start
@ -144,36 +142,37 @@ hlt
.welcome_debug db 'This is debug mode', 0
printCRLF:
mov ah, 0xE
mov al, 13
int 0x10
mov al, 10
int 0x10
ret
%ENDIF
;Routine for printing a 'ax' as hex
dumpax:
pusha ; save registers
pusha ; save registers
mov bx, ax
mov ah, 0xE ; Teletype output
mov ah, 0xE ; Teletype output
mov cx, 4 ; 4 nipples in a 16 bit word
mov cx, 4 ; 4 nipples in a 16 bit word
.loop:
rol bx, 4 ; rotate to next nipple
mov al, bl ; we copy to al because we need to mask only the low 4 bits
and al, 1111b ; Do the masking
add al, '0' ; convert to ASCII
cmp al, '9' ; If we are greater than 9 ascii, we add 7 to make digit 10 be represented as 'A'
jbe .skip ; -|-
add al, 7 ; -|-
.skip: ; -|-
int 0x10 ; BIOS call 'output'
rol bx, 4 ; rotate to next nipple
mov al, bl ; we copy to al because we need to mask only the low 4 bits
and al, 1111b ; Do the masking
add al, '0' ; convert to ASCII
cmp al, '9' ; If we are greater than 9 ascii, we add 7 to make digit 10 be represented as 'A'
jbe .skip ; -|-
add al, 7 ; -|-
.skip: ; -|-
int 0x10 ; BIOS call 'output'
loop .loop
popa ; restore registers
popa ; restore registers
ret
printCRLF:
mov ah, 0xE
mov al, 13
int 0x10
mov al, 10
int 0x10
ret
%ENDIF
; Routine for outputting string in 'si' register to screen
print:
mov ah, 0xE ; Specify 'int 0x10' 'teletype output' function
@ -188,27 +187,37 @@ jmp .printchar ; Repeat for the next character
ret
data:
message db 'SLRboot for SingOS! v0.2.0.0-exp',13,10,0
enter_debug_mode db 'Press d to enter bootloader debug mode',13,10,0
enter_system_check db 'Performing system check:',13,10,0
sys_check_ok db 'System check ok', 13, 10, 0
boot_system db 'Read SingOS from disk', 13, 10, 0
error_str db 'Error', 0
success_str db 'Success', 0
message db 'SLRboot for SingOS! v0.2.0.3-exp',13,10,0
;enter_debug_mode db 'Press d to enter bootloader debug mode',13,10,0
;enter_system_check db 'Performing system check:',13,10,0
;sys_check_ok db 'System check ok', 13, 10, 0
;boot_system db 'Read SingOS from disk', 13, 10, 0
;error_str db 'Error', 0
;success_str db 'Success', 0
disk_identifier db 0
DAPACK:
.dap_Size: db 0x10 ; This is always 16 bytes (0x10)
.rev_byte: db 0x0 ; reserved byte, should always be zero
.blkcnt: dw 0x0 ; int 13 resets this to # of blocks actually read/written
.db_addr_offset: dw 0x0 ; memory buffer destination address (0:7c00)
.db_addr_segment: dw 0x0 ; in memory page zero
.lba_addr_dw_low: dd 0x0 ; put the lba to read in this spot
.lba_addr_dw_high: dd 0x0 ; more storage bytes only for big lba's ( > 4 bytes )
; Pad to 510 bytes (boot sector size minus 2) with 0s, and finish with the two-byte standard boot signature
times 446-($-$$) db 0 ; First partion entry
partition_1:
.active_partition db 0x00
.active_partition db 0x80
.start_CHS db 0x00, 0x00, 0x11;0x20, 0x21, 0x00
.disk_type db 0x83
.end_CHS db 0x8C, 0x3D, 0x0F
.start_LBA db 0x00, 0x08, 0x00, 0x00
.start_LBA db 0x10, 0x00, 0x00, 0x00
.size db 0x00, 0xC8, 0x03, 0x00
partition_2:
.active_partition db 0x80
.active_partition db 0x00
.start_CHS db 0x8C, 0x3E, 0x0F
.disk_type db 0x83
.end_CHS db 0xFF, 0xFF, 0xFF

Loading…
Cancel
Save