int 13h help...
Posted: Sat May 11, 2002 11:00 pm
[BITS 16]
[SECTION .text]
[ORG 0]
jmp short reloc
nop
reloc:
; currently at 0:7C00
cld
int 12h ; get conventional memory size (in KBs)
shl ax, 6 ; and convert it to paragraphs
sub ax, 512 / 16 ; reserve 512 bytes for the boot sector code
mov es, ax ; es:0 -> top - 512
sub ax, 2048 / 16 ; reserve 2048 bytes for the stack
mov ss, ax ; ss:0 -> top - 512 - 2048
mov sp, 2048 ; 2048 bytes for the stack
mov cx, 256
mov si, 7C00h
xor di, di
mov ds, di
rep movsw
push es
push word start
retf
start:
push cs
pop ds
; mov al, 0x0
;; sub al, 0x1
; jz sig
recalibrate:
mov ah, 0
int 13h ; drive reinitialization
jc recalibrate
read_fs:
push es
push bx
mov ax, 1000h ; ES:BX = 1000:0000
mov es, ax
mov bx, 0
mov ah, 2 ; Load disk data to ES:BX
mov al, 1 ; Load 1 sector
mov ch, 0 ; Cylinder=0
mov cl, 2 ; Sector=2
mov dh, 0 ; Head=0
int 13h ; Read
jc short read_fs ; error, retry
mov si, word [es:bx] ; ***Here is where I want to load two characters previously loaded in ES:BX (1000h:0000h) from sector 2...
; It returns the first two characters of the boot sector code, which it isn't supposed to do
; Why won't it work?. It is not the character display code, which is used below in sig, and
; that works fine...
mov ah, 0Eh
mov bx, 7
lodsb
int 10h ; 1st char
lodsb
int 10h ; 2nd char
pop bx
pop es
jmp short sig
jmp short $
sig:
mov si, signal
mov ah, 0Eh
mov bx, 7
lodsb
int 10h ; 1st char
lodsb
int 10h ; 2nd char
lodsb
int 10h ; 3rd char
lodsb
int 10h ; 4th char
lodsb
int 10h ; 5th char
lodsb
int 10h ; 6th char
retf
; this procedure turns off the floppy drive motor, so
; the ring 0 loader is entered in a known state, and
; shall not be worried about later.
kill_motor:
push dx
push ax
mov dx,0x3f2
xor al,al
out dx,al
pop ax
pop dx
ret
signal db "SIGNAL"
times 510 - ($ - $$) db 0
dw 0AA55h
[SECTION .text]
[ORG 0]
jmp short reloc
nop
reloc:
; currently at 0:7C00
cld
int 12h ; get conventional memory size (in KBs)
shl ax, 6 ; and convert it to paragraphs
sub ax, 512 / 16 ; reserve 512 bytes for the boot sector code
mov es, ax ; es:0 -> top - 512
sub ax, 2048 / 16 ; reserve 2048 bytes for the stack
mov ss, ax ; ss:0 -> top - 512 - 2048
mov sp, 2048 ; 2048 bytes for the stack
mov cx, 256
mov si, 7C00h
xor di, di
mov ds, di
rep movsw
push es
push word start
retf
start:
push cs
pop ds
; mov al, 0x0
;; sub al, 0x1
; jz sig
recalibrate:
mov ah, 0
int 13h ; drive reinitialization
jc recalibrate
read_fs:
push es
push bx
mov ax, 1000h ; ES:BX = 1000:0000
mov es, ax
mov bx, 0
mov ah, 2 ; Load disk data to ES:BX
mov al, 1 ; Load 1 sector
mov ch, 0 ; Cylinder=0
mov cl, 2 ; Sector=2
mov dh, 0 ; Head=0
int 13h ; Read
jc short read_fs ; error, retry
mov si, word [es:bx] ; ***Here is where I want to load two characters previously loaded in ES:BX (1000h:0000h) from sector 2...
; It returns the first two characters of the boot sector code, which it isn't supposed to do
; Why won't it work?. It is not the character display code, which is used below in sig, and
; that works fine...
mov ah, 0Eh
mov bx, 7
lodsb
int 10h ; 1st char
lodsb
int 10h ; 2nd char
pop bx
pop es
jmp short sig
jmp short $
sig:
mov si, signal
mov ah, 0Eh
mov bx, 7
lodsb
int 10h ; 1st char
lodsb
int 10h ; 2nd char
lodsb
int 10h ; 3rd char
lodsb
int 10h ; 4th char
lodsb
int 10h ; 5th char
lodsb
int 10h ; 6th char
retf
; this procedure turns off the floppy drive motor, so
; the ring 0 loader is entered in a known state, and
; shall not be worried about later.
kill_motor:
push dx
push ax
mov dx,0x3f2
xor al,al
out dx,al
pop ax
pop dx
ret
signal db "SIGNAL"
times 510 - ($ - $$) db 0
dw 0AA55h