INT 13,2 - Read Disk Sectors Error
Posted: Sat Jan 12, 2019 3:34 pm
Hi guys, I try read ascii text from sector but I didn't. I can't see anything on the screen
Updated.
build.sh
asd.txt
boot.asm
stage2.asm
Updated.
build.sh
Code: Select all
#!/bin/bash
echo 'Starting.'
nasm -f bin boot.asm -o boot.bin
nasm -f bin stage2.asm -o stage2.bin
dd if=boot.bin of=loader.img bs=512 count=1
dd if=stage2.bin of=loader.img bs=512 count=7 seek=1
dd if=asd.txt of=loader.img bs=512 count=1 seek=7
rm boot.bin
rm stage2.bin
echo 'OK!'
qemu-system-x86_64 -fda loader.img
Code: Select all
Helloooo
Code: Select all
; initialize the environment
mov ax, 0x07c0
mov ds, ax
; the segment of the stage2
mov ax, 0x07e0
mov ch, 0x00
mov cl, 0x02
mov dh, 0x00
mov dl, 0x00
mov es, ax
mov bx, 0x0000
read:
mov al, 0x07
mov ah, 0x02
int 0x13
jc read
mov ax, 0x07e0
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x07e0:0x0000
times 510 - ($ - $$) db 0
dw 0xaa55
Code: Select all
start:
mov ax, 0x7e00
mov ss, ax
mov sp, 0x2000
mov al, 0x03
mov ah, 0x00
int 0x10
call clearScreen
push 0x0000
call moveCursor
add sp, 0x2
push INTRO
call print
add sp, 0x2
mov ah, 0x0
int 0x16
call clearScreen
push 0x0000
call moveCursor
add sp, 0x2
push HEADER
call print
add sp, 0x2
call checkDisk
call readInput
; cli
; hlt
checkDisk:
pusha
mov ah, 0x2
mov al, 0x1
mov cl, 0x8
mov ch, 0x0
mov dh, 0x0
mov dl, 0x0
int 0x13
jc diskError
push bx
call print
popa
ret
diskError:
pusha
push DISK_ERROR
call print
popa
ret
clearScreen:
push bp
mov bp, sp
pusha
mov ah, 0x7
mov al, 0x0
mov bh, 0x4
mov cx, 0x0
mov dh, 0x18
mov dl, 0x4F
int 0x10
popa
mov sp, bp
pop bp
ret
moveCursor:
push bp
mov bp, sp
pusha
mov dx, [bp+4]
mov ah, 0x2
mov bh, 0x0
int 0x10
popa
mov sp, bp
pop bp
ret
print:
push bp
mov bp, sp
pusha
mov si, [bp+4]
mov bh, 0x0
mov bl, 0x0
mov ah, 0x0e
.char:
mov al, [si]
add si, 1
or al, 0x0
je .return
int 0x10
jmp .char
.return:
popa
mov sp, bp
pop bp
ret
readInput:
xor ax,ax
readInputLoop:
xor ax,ax
int 0x16
; cmp al, 0x8 ; Backspace
; je backSpace
cmp al, 0x0D ; Enter
je readInputEnd
call putChar
mov BYTE [es:KEY_OFFSET + bx], al
inc bl
cmp bl, KEY_SIZE
jne readInputLoop
readInputEnd:
;backSpace:
putChar:
push bx
mov ah, 0x0e
xor bx, bx
int 0x10
pop bx
ret
DISK_ERROR: db 'Disk read error', 0x0
DISK_ERROR1: db 'Disk write error', 0x0
SECTORS_ERROR: db "Incorrect number of sectors read", 0
INTRO: db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db '', 0xA, 0xD
db 'Press any key...', 0x0
HEADER: db 'Simple Bootloader', 0xA, 0xD, 0xA, 0xD, 'jkljkl', 0xA, 0xD, 0xA, 0xD, 'kjljkl', 0xA, 0xD, 0xA, 0xD, 'jkl', 0xA, 0xD, 0xA, 0xD, 'jkljkl', 0xA, 0xD, 0xA, 0xD, 'jkljkl', 0xA, 0xD, 0xA, 0xD, 'jkljkl', 0xA, 0xD, 'asdasd', 0xA, 0xD, 0xA, 0xD, 'asdasd', 0xA, 0xD, 0xA, 0xD, 'asd', 0x0
KEY_OFFSET equ 0x500
KEY_SIZE equ 0x50
times 3584 - ($ - $$) db 0x0