You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
4.3 KiB
NASM

[org 0x7c00]
5 years ago
[bits 16]
5 years ago
pre:
cmp ah, 0x0F
je welcome
mov [bootdev], dl ; Save boot device number
5 years ago
jmp welcome
welcome:
xor ax,ax ; We want a segment of 0 for DS for this question
mov ds,ax ; Set AX to appropriate segment value for your situation
mov es,ax ; In this case we'll default to ES=DS
mov bx,0x8000 ; Stack segment can be any usable memory
mov ss,bx ; This places it with the top of the stack @ 0x80000.
mov sp,ax ; Set SP=0 so the bottom of stack will be @ 0x8FFFF
5 years ago
cld ; Set the direction flag to be positive direction
5 years ago
5 years ago
mov ah, 01h ;make cursor invisible
mov cx, 2607h
int 10h
mov ah, 06h ; Scroll up function
xor al, al ; Clear entire screen
xor cx, cx ; Upper left corner CH=row, CL=column
mov dx, 184FH ; lower right corner DH=row, DL=column
mov bh, 1Eh ; YellowOnBlue
int 10H ; execute interrupt
mov ah, 02h ;sets cursor to top to write
mov bh, 0h
mov dh, 2h
mov dl, 2h
int 10h
mov si, wolf_wel_msg
call wolf_print
mov si, xpub
call wolf_print
start:
mov ah, 0x00
int 0x16
cmp al, "0"
je load_it_all_0
cmp al, "1"
je load_it_all_1
jmp over
load_it_all_0:
mov si, wolf_kernel_load
call wolf_print
pushf
stc
mov ah,00
int 13h
.read_sector:
mov ax, 0x0
mov es, ax ; ES = 0
mov bx, 0x2000 ; BX = 0x1000. ES:BX=0x0:0x1000
; ES:BX = starting address to read sector(s) into
mov ah, 02 ; Int 13h/AH=2 = Read Sectors From Drive
mov al, 01 ; Sectors to read = 1
mov ch, 00 ; CH=Cylinder. Second sector of disk
; is at Cylinder 0 not 1
mov cl, 03 ; Sector to read = 2
mov dh, 00 ; Head to read = 0
; DL hasn't been destroyed by our bootloader code and still
; contains boot drive # passed to our bootloader by the BIOS
mov dl, [bootdev]
int 13h
jc wolf_error
popf
jmp 0x0:0x2000
cli
hlt
load_it_all_1:
mov si, wolf_kernel_load
call wolf_print
pushf
stc
mov ah,00
int 13h
.read_sector:
mov ax, 0x0
mov es, ax ; ES = 0
mov bx, 0x1000 ; BX = 0x1000. ES:BX=0x0:0x1000
; ES:BX = starting address to read sector(s) into
mov ah, 02 ; Int 13h/AH=2 = Read Sectors From Drive
mov al, 01 ; Sectors to read = 1
mov ch, 00 ; CH=Cylinder. Second sector of disk
; is at Cylinder 0 not 1
mov cl, 02 ; Sector to read = 2
mov dh, 00 ; Head to read = 0
; DL hasn't been destroyed by our bootloader code and still
; contains boot drive # passed to our bootloader by the BIOS
mov dl, [bootdev]
int 13h
jc wolf_error
popf
jmp 0x0:0x1000
cli
hlt
wolf_error:
mov si, wolf_error_msg
call wolf_print
mov si, wolf_error_msg1
call wolf_print
mov ah,00
int 16h
xor ax,ax
int 19h
wolf_print:
lodsb
or al,al
jz exit
5 years ago
mov ah,0x0e
int 10h
jmp wolf_print
exit:
ret
over:
jmp start
; Moved the data before the boot signature but after the code
wolf_wel_msg db 'Welcome to this publication..., press a key',0x0D,0x0A,0
wolf_kernel_load db 'Loading program',0x0D,0x0A,0
wolf_error_msg db 'Program not found!',0x0D,0x0A,0
wolf_error_msg1 db 'Press any key to restart..',0
xpub db 0x0D, 0x0A, 0x20, 0xB1, 0x20, 0x20, 0x20, 0xB1, 0x20, 0xB1, 0xB1, 0xB1, 0x20, 0x20, 0xB1, 0x20, 0x20, 0x20, 0xB1,0x20,0xB1,0xB1,0xB1, 0x20, 0x0D, 0x0A,0x20,0x20,0xB1,0x20,0xB1,0x20,0x20,0xB1,0x20,0x20,0xB1, 0x20,0xB1,0x20,0x20,0x20,0xB1,0x20,0xB1,0x20,0x20, 0xB1, 0x0D,0x0A,0x20,0x20,0x20,0xB1, 0x20,0x20,0x20,0xB1,0xB1, 0xB1,0x20,0x20,0xB1,0x20,0x20,0x20,0xB1,0x20,0xB1,0xB1,0xB1,0x20,0x0D,0x0A,0x20,0x20,0xB1,0x20,0xB1, 0x20,0x20,0xB1,0x20,0x20,0x20,0x20,0xB1,0x20,0x20,0x20,0xB1,0x20,0xB1,0x20,0x20,0xB1,0x0D,0x0A,0x20,0xB1, 0x20,0x20,0x20,0xB1,0x20,0xB1,0x20,0x20,0x20,0x20,0x20,0xB1,0xB1,0xB1,0x20,0x20,0xB1,0xB1,0xB1, 0x20, 0
5 years ago
bootdev db 0x80 ; Boot device number
times 510-($-$$) db 0
dw 0xAA55