Here is the code :
The boot loader part :
Code: Select all
[BITS 16]
[ORG 0x7C00]
main:
cli
xor bx,bx
mov es,bx
mov fs,bx
mov gs,bx
mov ds,bx
mov ss,bx
mov sp,0x7C00
sti
MOV SI, Hello
CALL PrintString
MOV AH,0x03
MOV BH,0x00
INT 0x10
ADD DH,2
XOR DL,DL
MOV AH,0x02
XOR BH,BH
INT 0x10
XOR BX,BX
ReadPass:
MOV AH,0x00
INT 0x16
CMP AL,13
JE Verify
MOV [read+BX],AL
PUSH BX
CALL PrintChar
POP BX
INC BX
CMP BX,6
JE Verify
JMP ReadPass
Verify:
MOV SI,read
MOV DI,pass
MOV CX,6
REP CMPSB
JNE the_end
Done:
MOV SI,succ
call PrintString
MOV AH,0x02
MOV AL,1
MOV CH,0
MOV CL,2
MOV DX,0x0080
MOV BX,1000h
MOV ES, BX
XOR BX,BX
INT 13h
CMP AH,0
JNE Done
jmp 0x1000:0x0000
the_end:
INT 0x19
PrintChar:
MOV AH,0x0E
MOV BH,0x04
MOV BL,0x10
INT 0x10
RET
PrintString:
MOV AL,[SI]
CMP AL,0
JE theret
INC SI
CALL PrintChar
JMP PrintString
theret:
ret
pass db 'MUKMIK',0
read times 7 db 0
succ db 'Success booting...',0
Hello db 'Enter password',0
times 510 - ($ - $$) DB 0
dw 0xAA55
The part wich loads the original MBR at 7C00h and jumps to it
Code: Select all
[BITS 16]
[ORG 0x0000]
Start:
MOV AH,0x02
MOV AL,1
MOV CH,0
MOV CL,4
MOV DX,0x0080
MOV BX,0x0000
MOV ES,BX
MOV BX,0x7C00
INT 13h
CMP AH,0
JNE Fail
cli
xor bx,bx
mov es,bx
mov fs,bx
mov gs,bx
mov dl,0x80
mov ds,bx
mov ss,bx
mov sp,0x7C00
sti
JMP 0x0000:0x7C00
Fail:
INT 0x19
times 512 - ($ - $$) DB 0