NASM Forum > Programming with NASM

Disk Reading Routines under NASM

(1/2) > >>

Deskman243:
Greetings

Here is a pretty intriguing post for review today. I have been practicing the BIOS functions and now the program itself is as compact as I could get it. I'm mainly looking at program segmentation for file management. The good thing is that I've learned how to run files larger than the typical 512 b environment. Right now the program uses the built-in 13h disk function but the new design only gets through the first 18 sections. I've tried changing each of the other variable but I can't get it to run the code. Here is a copy of the main boot file.


--- Code: ---;    ReTimerOS
;    Copyright (C) 2022,2023  Christopher Hoy
;
; This file is part of ReTimerOS
;    ReTimerOS is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    This program is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU General Public License for more details.
;
;    You should have received a copy of the GNU General Public License
;    along with this program.  If not, see <https://www.gnu.org/licenses/>.


[org 0x7c00]

[bits 16]

mov cx,0
mov ds,cx
mov es,cx


cld

mov si,msgString
call kprint


disk_read:
mov cx,0
mov ds,cx
mov es,cx

mov bx,0x0000_e600
mov cl,0x24
mov bx,msgString
mov bx,0x0000_e600
mov cl,0x24
mov al,1
call read_section2
mov cx,0xe60
mov es,cx
mov bx,0
mov cx,00000h
mov cl,0x24
;mov bx,0x0000_8000
mov al,1
call read_section2
;mov bx,0x0000_7e00


mov bx,0x0000_8400
;mov bx,0x0000_A000
mov cl,5
mov bx,msgString
mov bx,0x0000_8400
;mov bx,0x0000_9000
;mov bx,0x0000_A000
mov cl,5
mov al,0x30
call read_section
mov cx,0x840
;mov cx,0x900
;mov cx,0xA00
mov es,cx
mov bx,0
mov cx,00000h
;mov al,1
mov cl,5
;mov bx,0x0000_8000
mov al,0x30
call read_section


mov bx,0x0000_8000
mov cl,3
mov bx,msgString
mov bx,0x0000_8000
mov cl,3
mov al,2
call read_section
mov cx,0x800
mov es,cx
mov bx,0
mov cx,00000h
mov cl,3
;mov bx,0x0000_8000
mov al,2
call read_section
;mov bx,0x0000_7e00


mov bx,0x0000_7e00
mov cl,2
mov bx,msgString
mov bx,0x0000_7e00
mov cl,2
mov al,1
call read_section
mov cx,0x7e0
mov es,cx
mov bx,0
mov cx,00000h
mov cl,2
;mov bx,0x0000_8000
mov al,1
call read_section
mov bx,0x0000_7e00

;mov cx,0
;mov es,cx


pusha

jmp 0x7e00
;jmp 0x9200
;jmp 0xD000

;jmp 0x11000

;jmp 0x0000_7e0:0x0000
;jmp 0x7e0:0x0000
;jmp 0x900:0x0000
;jmp 0xfc0:0x0000


jmp $

kprint:
cld
mov ah,0x0E

kstring:
lodsb
int 0x10
cmp al,0x00
jnz kstring
ret

read_section:

mov ah,0x02
; mov al,1
mov ch,0
mov dh,0
int 0x13
jc disk_check
;mov si,checkString2
;call kprint

;lea si,[checkString]
;call printstr

ret

read_section2:

mov ah,0x02
; mov al,1
mov ch,0
mov dh,1
int 0x13
jc disk_check


ret


disk_check:
;lea si,[checkString]
;call printstr

mov si,checkString
call kprint
jmp $
.done:
ret


;section .data

align 4
BOOT_DRIVE: db 0
msgString: db 'Game platform premier',10,13,0
checkString: db 'section incomplete',10,13,0
checkString2: db 'disk complete',10,13,0

times 510 -($-$$) db 0
dw 0xaa55


--- End code ---

As I mentioned earlier you can notice the other disk read here (read_section2). Most of the configurations I reference say that each of the drive variables uses 18 sections however anytime I try to change this I get no changes on my screen. I really hope I'm not the only one that has been around this type of configuration and would really appreciate correspondence on this here.
The code is based on my most previous posts and while I believe most of disk reading is contained inside the boot file you can let me know if anyone else would like another copy of the source code for review.

Deskman243:
Reference to full source posted here

Deskman243:
Branch 2 Review

I have a revision of the first part of the previous file for simplification.

--- Code: ---check_0:

mov bx,msgString
;mov bx,0x0000_a000
mov cl,1
mov al,1
call read_section2
;mov cx,0xa00
;mov es,cx
mov bx,0
mov cx,00000h
mov cl,1
mov al,1
call read_section2

check_1:
mov bx,0x0000_9e00
mov cl,18
mov bx,msgString
mov bx,0x0000_9e00
mov cl,18
mov al,1
call read_section
mov cx,0x9e0
mov es,cx
mov bx,0
mov cl,18
mov al,1
call read_section


mov bx,0x0000_9C00
mov cl,17
mov bx,msgString
mov bx,0x0000_9C00
mov cl,17
mov al,1
call read_section
mov cx,0x9c0
mov es,cx
mov bx,0
mov cx,00000h
mov cl,17
mov al,1
call read_section


mov bx,0x0000_8000
mov cl,3
mov bx,msgString
mov bx,0x0000_8000
mov cl,3
;mov al,16
mov al,14
call read_section
mov cx,0x800
mov es,cx
mov bx,0
mov cx,00000h
mov cl,3
mov al,14
call read_section


mov bx,0x0000_7e00
mov cl,2
mov bx,msgString
mov bx,0x0000_7e00
mov cl,2
mov al,1
call read_section
mov cx,0x7e0
mov es,cx
mov bx,0
mov cx,00000h
mov cl,2
mov al,1
call read_section
mov bx,0x0000_7e00


.1:
pusha

jmp 0x7e00


read_section:

mov ah,0x02
; mov al,1
mov ch,0
mov dh,0
; mov dl,0x80
int 0x13
jc disk_check

call disk_reset

ret
read_section2:

mov ch,1
mov cl,1
mov ah,0x02
mov dh,0
int 0x13
.check:
jc disk_check
call disk_reset
ret


--- End code ---

This is now simplified to

--- Code: ---read:
mov cx,0x7c0
mov es,cx

      xor bx, bx
      mov bx,0x0200
      mov ah, 0x02   ; Load disk data to ES:BX
      mov al, 17   ; Load 17 sectors
      mov ch, 0           ; Cylinder=0
      mov cl, 2            ; Sector=2
      mov dh, 0          ; Head=0
      mov dl, 0  ; Drive=0
; mov dl,0x80
      int 13h               ; Read!
;      jc read   ; Error, try again

jc disk_check

ret

read2:
mov cx,0x7c0
mov es,cx

      mov bx, 0x2400
      mov ah, 0x02   ; Load disk data to ES:BX
      mov al, 18   ; Load 18 sectors
      mov ch, 1           ; Cylinder=0
      mov cl, 1            ; Sector=2


      mov dh, 0   
      mov dl, 0 
; mov dl,0x80
      int 13h               ; Read!
;      jc read2   ; Error, try again

jc disk_check

ret

--- End code ---

Curiously these halts at the same place (the 2nd cylinder passed the first 18 sections).  I think this illustrated more obviously what the object in question is.

Deskman243:
Debugger Review 1

Apparently I can change the section size larger than the cylinder count.Curiously this can go until al=65.

Frank Kotler:
Hi Deskman,

Do you mean "sections" or "sectors"?

Best,
Frank

Navigation

[0] Message Index

[#] Next page

Go to full version