2021-07-04 16:16:27 +00:00
|
|
|
;Load a file named at SI as a string ending in a null to the offset BX
|
2021-07-06 18:12:15 +00:00
|
|
|
;and store the file size in CX and the error codes in AL:
|
2021-07-01 13:50:43 +00:00
|
|
|
; * AL = 0x0: Succesful load
|
|
|
|
; * AL = 0x1: Drive not found
|
|
|
|
; * AL = 0x2: Unable to read disk
|
|
|
|
; * AL = 0x4: File or command not found
|
|
|
|
; * AL = 0x8: Not enough memory
|
2021-06-22 13:05:09 +00:00
|
|
|
|
|
|
|
loadf:
|
|
|
|
|
2021-07-10 17:49:06 +00:00
|
|
|
;Store BX, DX, SI, and DI in the stack
|
2021-06-22 13:05:09 +00:00
|
|
|
push bx
|
|
|
|
push dx
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
|
2021-06-28 17:00:22 +00:00
|
|
|
;Store the current drive and offset
|
2021-06-22 13:05:09 +00:00
|
|
|
mov word [.pointer], bx
|
2021-08-27 17:25:46 +00:00
|
|
|
mov dl, byte [curdrive]
|
|
|
|
mov byte [drive], dl
|
2021-06-28 17:00:22 +00:00
|
|
|
|
|
|
|
;Change the drive if needed
|
|
|
|
;Check for a drive specification
|
|
|
|
cmp byte [si + 0x1], ":"
|
2021-07-10 17:49:06 +00:00
|
|
|
jne .convert
|
|
|
|
;Get the BIOS equipment list
|
|
|
|
int 0x11
|
|
|
|
;Get the number of floppy drives
|
|
|
|
times 0x6 shr ax, 0x1
|
|
|
|
and ax, 0x3
|
|
|
|
inc ax
|
|
|
|
;Set the loop and drive letter counters and the drive letter and number
|
|
|
|
mov cx, ax
|
|
|
|
mov di, driveletters
|
|
|
|
mov al, [si]
|
|
|
|
mov dl, 0x0
|
2021-06-28 17:00:22 +00:00
|
|
|
;Check which drive to change to
|
2021-07-10 17:49:06 +00:00
|
|
|
.checkdrive:
|
|
|
|
cmp al, [di]
|
|
|
|
je .contchdrive
|
|
|
|
inc di
|
|
|
|
cmp al, [di]
|
|
|
|
je .contchdrive
|
|
|
|
inc di
|
|
|
|
inc dl
|
|
|
|
loop .checkdrive
|
2021-07-06 18:12:15 +00:00
|
|
|
;Set AL to 0x1, CX to 0x0, and print an error message
|
2021-06-28 17:00:22 +00:00
|
|
|
mov si, .driverrormsg
|
|
|
|
mov ah, 0x2
|
|
|
|
int 0x21
|
2021-07-01 13:50:43 +00:00
|
|
|
mov al, 0x1
|
2021-07-06 18:12:15 +00:00
|
|
|
mov cx, 0x0
|
2021-06-28 17:00:22 +00:00
|
|
|
jmp .done
|
2021-07-10 17:49:06 +00:00
|
|
|
;Change the drive
|
|
|
|
.contchdrive:
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [drive], dl
|
2021-07-10 17:49:06 +00:00
|
|
|
;Move to the file name
|
2021-06-28 17:00:22 +00:00
|
|
|
add si, 0x2
|
|
|
|
|
2021-06-22 13:05:09 +00:00
|
|
|
;Set DI at .file and initialise it with spaces
|
2021-07-10 17:49:06 +00:00
|
|
|
.convert:
|
2021-06-22 13:05:09 +00:00
|
|
|
mov di, .file
|
|
|
|
mov cx, 0xb
|
|
|
|
mov al, 0x20
|
|
|
|
rep stosb
|
|
|
|
sub di, 0xb
|
|
|
|
|
2021-07-10 17:49:06 +00:00
|
|
|
;Convert the main part of the file name into FAT format
|
|
|
|
;Set the length counter
|
2021-06-22 13:05:09 +00:00
|
|
|
mov bl, 0x8
|
|
|
|
;Load a character
|
2021-07-10 17:49:06 +00:00
|
|
|
.nameloop:
|
2021-06-22 13:05:09 +00:00
|
|
|
lodsb
|
|
|
|
;Check for a period
|
|
|
|
cmp al, 0x2e
|
|
|
|
je .initext
|
|
|
|
;Check for everything else and convert to upper case
|
|
|
|
call .checkconv
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the next character
|
2021-06-22 13:05:09 +00:00
|
|
|
jmp .nameloop
|
|
|
|
|
2021-07-10 17:49:06 +00:00
|
|
|
;Convert the extension into FAT format
|
|
|
|
;Set DI and the length counter for the extension
|
2021-06-22 13:05:09 +00:00
|
|
|
.initext:
|
|
|
|
mov bl, 0x3
|
|
|
|
mov di, .file+0x8
|
|
|
|
;Load a character
|
2021-07-10 17:49:06 +00:00
|
|
|
.extloop:
|
2021-06-22 13:05:09 +00:00
|
|
|
lodsb
|
|
|
|
;Check for a period
|
|
|
|
push ax
|
|
|
|
cmp al, 0x2e
|
|
|
|
je .error
|
|
|
|
pop ax
|
|
|
|
;Check for everything else and convert to upper case
|
|
|
|
call .checkconv
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the next character
|
2021-06-22 13:05:09 +00:00
|
|
|
jmp .extloop
|
2021-07-06 18:12:15 +00:00
|
|
|
;Set AL to 0x4, CX to 0x0, and print an error message
|
2021-06-22 13:05:09 +00:00
|
|
|
.error:
|
|
|
|
pop ax
|
2021-06-28 17:00:22 +00:00
|
|
|
mov si, .filerrormsg
|
|
|
|
mov ah, 0x2
|
|
|
|
int 0x21
|
2021-07-01 13:50:43 +00:00
|
|
|
mov al, 0x4
|
2021-07-06 18:12:15 +00:00
|
|
|
mov cx, 0x0
|
2021-06-22 13:05:09 +00:00
|
|
|
jmp .done
|
|
|
|
|
|
|
|
;Find and load the file
|
|
|
|
.load:
|
|
|
|
pop ax
|
|
|
|
|
2021-06-24 15:34:41 +00:00
|
|
|
;Load the disk description table
|
|
|
|
;Set the source
|
2021-08-27 17:25:46 +00:00
|
|
|
mov dl, [drive]
|
2021-06-24 15:34:41 +00:00
|
|
|
mov ch, 0x0
|
|
|
|
mov dh, 0x0
|
|
|
|
mov cl, 0x1
|
|
|
|
;Set the destination
|
|
|
|
mov si, buffer
|
|
|
|
mov bx, si
|
|
|
|
;Set the size
|
|
|
|
mov al, 0x1
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the disk description table
|
2021-06-24 15:34:41 +00:00
|
|
|
mov ah, 0x2
|
|
|
|
int 0x13
|
2021-06-29 17:05:14 +00:00
|
|
|
jnc .storevalues
|
2021-07-06 18:12:15 +00:00
|
|
|
;Set AL to 0x2, CX to 0x0, and print an error message
|
2021-06-29 17:05:14 +00:00
|
|
|
mov si, .diskerrormsg
|
|
|
|
mov ah, 0x2
|
|
|
|
int 0x21
|
2021-07-01 13:50:43 +00:00
|
|
|
mov al, 0x2
|
2021-07-06 18:12:15 +00:00
|
|
|
mov cx, 0x0
|
2021-06-29 17:05:14 +00:00
|
|
|
jmp .done
|
2021-06-24 15:34:41 +00:00
|
|
|
|
|
|
|
;Store the disk values used for the rest of the call
|
2021-06-29 17:05:14 +00:00
|
|
|
.storevalues:
|
2021-07-10 17:49:06 +00:00
|
|
|
mov ax, [buffer + 0xb]
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [sectorsize], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
mov al, [buffer + 0xd]
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [clustersize], al
|
2021-07-10 17:49:06 +00:00
|
|
|
mov ax, [buffer + 0xe]
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [reservedsectors], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
mov al, [buffer + 0x10]
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [fats], al
|
2021-07-10 17:49:06 +00:00
|
|
|
mov ax, [buffer + 0x11]
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [rootentries], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
mov ax, [buffer + 0x16]
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [sectorsperfat], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
mov ax, [buffer + 0x18]
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [sectorspertrack], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
mov ax, [buffer + 0x1a]
|
2021-08-27 17:25:46 +00:00
|
|
|
mov [heads], ax
|
2021-06-24 15:34:41 +00:00
|
|
|
|
2021-07-10 17:49:06 +00:00
|
|
|
;Calculate and store variables not found in the BPB
|
|
|
|
;Start of the root
|
2021-06-22 13:05:09 +00:00
|
|
|
mov ah, 0x0
|
2021-08-27 17:25:46 +00:00
|
|
|
mov al, [fats]
|
|
|
|
mul word [sectorsperfat]
|
|
|
|
add ax, [reservedsectors]
|
|
|
|
mov [rootstart], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
;Size of the root in sectors
|
2021-08-27 17:25:46 +00:00
|
|
|
mov ax, [rootentries]
|
2021-06-22 13:05:09 +00:00
|
|
|
mov dx, 0x20
|
|
|
|
mul dx
|
|
|
|
mov dx, 0x0
|
2021-08-27 17:25:46 +00:00
|
|
|
div word [sectorsize]
|
|
|
|
mov [rootsectors], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
;Start of data
|
2021-08-27 17:25:46 +00:00
|
|
|
add ax, [rootstart]
|
|
|
|
mov [datastart], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
|
|
|
|
;Load the root
|
|
|
|
;Set the source
|
2021-08-27 17:25:46 +00:00
|
|
|
mov ax, [rootstart]
|
2021-07-10 17:49:06 +00:00
|
|
|
;Set the destination
|
|
|
|
mov si, buffer
|
|
|
|
mov bx, si
|
|
|
|
;Set the size
|
2021-08-27 17:25:46 +00:00
|
|
|
mov cx, [rootsectors]
|
2021-07-10 17:49:06 +00:00
|
|
|
;Store the source and the loop counter in the stack
|
|
|
|
.loadrootsector:
|
2021-07-01 17:40:28 +00:00
|
|
|
push ax
|
|
|
|
push cx
|
2021-07-10 17:49:06 +00:00
|
|
|
;Set the source
|
2021-07-01 17:40:28 +00:00
|
|
|
call .calcsource
|
|
|
|
;Set the size
|
|
|
|
mov al, 0x1
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load a sector
|
2021-06-22 13:05:09 +00:00
|
|
|
mov ah, 0x2
|
|
|
|
int 0x13
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the loop counter and the source from the stack
|
|
|
|
pop cx
|
2021-07-01 17:40:28 +00:00
|
|
|
pop ax
|
|
|
|
;Set the next sector
|
|
|
|
add ax, 0x1
|
2021-08-27 17:25:46 +00:00
|
|
|
add bx, word [sectorsize]
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the next sector
|
|
|
|
loop .loadrootsector
|
2021-06-22 13:05:09 +00:00
|
|
|
|
|
|
|
;Search the root for the file entry
|
|
|
|
;Set DI to the root
|
|
|
|
mov di, buffer
|
2021-07-10 17:49:06 +00:00
|
|
|
;Set the number of root entries
|
2021-08-27 17:25:46 +00:00
|
|
|
mov cx, word [rootentries]
|
2021-07-10 17:49:06 +00:00
|
|
|
;Set the entry pointer
|
2021-06-22 13:05:09 +00:00
|
|
|
mov ax, 0x0
|
2021-07-10 17:49:06 +00:00
|
|
|
;Store the loop counter in the stack
|
2021-06-22 13:05:09 +00:00
|
|
|
.search:
|
|
|
|
push cx
|
|
|
|
;Check for the file entry
|
|
|
|
mov si, .file
|
|
|
|
mov cx, 0xb
|
|
|
|
rep cmpsb
|
2021-07-01 13:50:43 +00:00
|
|
|
je .checksize
|
2021-07-10 17:49:06 +00:00
|
|
|
;Set DI at the next entry
|
2021-06-22 13:05:09 +00:00
|
|
|
add ax, 0x20
|
|
|
|
mov di, buffer
|
|
|
|
add di, ax
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the loop counter from the stack
|
2021-06-22 13:05:09 +00:00
|
|
|
pop cx
|
2021-07-10 17:49:06 +00:00
|
|
|
;Search the next entry
|
2021-06-22 13:05:09 +00:00
|
|
|
loop .search
|
2021-07-06 18:12:15 +00:00
|
|
|
;Set AL to 0x4, CX to 0x0, and print an error message
|
2021-06-28 17:00:22 +00:00
|
|
|
mov si, .filerrormsg
|
|
|
|
mov ah, 0x2
|
|
|
|
int 0x21
|
2021-07-01 13:50:43 +00:00
|
|
|
mov al, 0x4
|
2021-07-06 18:12:15 +00:00
|
|
|
mov cx, 0x0
|
2021-07-10 17:49:06 +00:00
|
|
|
jmp .done
|
2021-06-22 13:05:09 +00:00
|
|
|
|
2021-07-06 18:12:15 +00:00
|
|
|
;Check and store the file size
|
2021-06-22 13:05:09 +00:00
|
|
|
;Load CX from the stack
|
2021-07-10 17:49:06 +00:00
|
|
|
.checksize:
|
2021-06-22 13:05:09 +00:00
|
|
|
pop cx
|
2021-07-01 13:50:43 +00:00
|
|
|
;Check for files larger than 64 KiB
|
|
|
|
cmp word [di + 0x13], 0x0
|
|
|
|
jne .sizerror
|
|
|
|
;Get the cluster size in bytes
|
|
|
|
mov ah, 0x0
|
2021-08-27 17:25:46 +00:00
|
|
|
mov al, [clustersize]
|
|
|
|
mul word [sectorsize]
|
2021-07-01 13:50:43 +00:00
|
|
|
mov bx, ax
|
2021-07-06 18:12:15 +00:00
|
|
|
;Store the file size
|
|
|
|
mov ax, [di + 0x11]
|
|
|
|
mov word [.size], ax
|
2021-07-01 13:50:43 +00:00
|
|
|
;Check for files smaller than 64 KiB but too large to fit into memory
|
|
|
|
jc .sizerror
|
|
|
|
dec ax
|
|
|
|
mov dx, 0x0
|
|
|
|
div bx
|
|
|
|
mul bx
|
|
|
|
add ax, [.pointer]
|
2021-07-04 16:16:27 +00:00
|
|
|
jnc .loadfat
|
2021-07-06 18:12:15 +00:00
|
|
|
;Set AL to 0x8, CX to 0x0, and print an error message
|
2021-07-01 13:50:43 +00:00
|
|
|
.sizerror:
|
|
|
|
mov si, .sizerrormsg
|
|
|
|
mov ah, 0x2
|
|
|
|
int 0x21
|
|
|
|
mov al, 0x8
|
2021-07-06 18:12:15 +00:00
|
|
|
mov cx, 0x0
|
2021-07-10 17:49:06 +00:00
|
|
|
jmp .done
|
2021-07-01 13:50:43 +00:00
|
|
|
|
2021-07-04 16:16:27 +00:00
|
|
|
;Load the FAT
|
|
|
|
.loadfat:
|
2021-07-10 17:49:06 +00:00
|
|
|
;Store the address of the first cluster
|
|
|
|
mov ax, [di + 0xf]
|
|
|
|
mov [.cluster], ax
|
2021-06-22 13:05:09 +00:00
|
|
|
;Set the source
|
2021-08-27 17:25:46 +00:00
|
|
|
mov ax, [reservedsectors]
|
2021-06-22 13:05:09 +00:00
|
|
|
call .calcsource
|
|
|
|
;Set the destination
|
2021-07-10 17:49:06 +00:00
|
|
|
mov bx, buffer
|
2021-06-22 13:05:09 +00:00
|
|
|
;Set the size
|
2021-08-27 17:25:46 +00:00
|
|
|
mov ax, [sectorsperfat]
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the FAT
|
2021-06-22 13:05:09 +00:00
|
|
|
mov ah, 0x2
|
|
|
|
int 0x13
|
|
|
|
|
|
|
|
;Load a cluster
|
|
|
|
.loadcluster:
|
|
|
|
;Set the source
|
|
|
|
mov ax, word [.cluster]
|
|
|
|
sub ax, 0x2
|
2021-08-27 17:25:46 +00:00
|
|
|
mul byte [clustersize]
|
|
|
|
add ax, [datastart]
|
2021-06-22 13:05:09 +00:00
|
|
|
;Set the destination
|
|
|
|
mov bx, word [.pointer]
|
2021-07-10 17:49:06 +00:00
|
|
|
;Set the size
|
2021-06-26 15:55:47 +00:00
|
|
|
mov ch, 0x0
|
2021-08-27 17:25:46 +00:00
|
|
|
mov cl, byte [clustersize]
|
2021-07-10 17:49:06 +00:00
|
|
|
;Store the loop counter in the stack
|
2021-06-26 15:55:47 +00:00
|
|
|
.loadsector:
|
|
|
|
push cx
|
2021-07-10 17:49:06 +00:00
|
|
|
;Set the source
|
2021-06-26 15:55:47 +00:00
|
|
|
call .calcsource
|
2021-06-22 13:05:09 +00:00
|
|
|
;Set the size
|
2021-06-26 15:55:47 +00:00
|
|
|
push ax
|
|
|
|
mov al, 0x1
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load a sector
|
2021-06-22 13:05:09 +00:00
|
|
|
mov ah, 0x2
|
|
|
|
int 0x13
|
2021-06-26 15:55:47 +00:00
|
|
|
pop ax
|
|
|
|
;Set the next sector
|
|
|
|
add ax, 0x1
|
2021-08-27 17:25:46 +00:00
|
|
|
add bx, word [sectorsize]
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the loop counter from the stack
|
2021-06-26 15:55:47 +00:00
|
|
|
pop cx
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the next sector
|
2021-06-26 15:55:47 +00:00
|
|
|
loop .loadsector
|
2021-06-22 13:05:09 +00:00
|
|
|
|
|
|
|
;Calculate the next cluster
|
2021-07-10 17:49:06 +00:00
|
|
|
;Check if the cluster is even or odd
|
2021-06-22 13:05:09 +00:00
|
|
|
mov ax, [.cluster]
|
|
|
|
mov dx, 0x0
|
|
|
|
mov bx, 0x3
|
|
|
|
mul bx
|
|
|
|
mov bx, 0x2
|
|
|
|
div bx
|
|
|
|
mov si, buffer
|
|
|
|
add si, ax
|
2021-07-10 17:49:06 +00:00
|
|
|
mov ax, word [si]
|
2021-06-22 13:05:09 +00:00
|
|
|
or dx, dx
|
|
|
|
jz .even
|
2021-07-10 17:49:06 +00:00
|
|
|
;If the cluster is odd shift out the first four bits
|
|
|
|
times 0x4 shr ax, 0x1
|
2021-06-22 13:05:09 +00:00
|
|
|
jmp .contcalc
|
2021-07-10 17:49:06 +00:00
|
|
|
;If the cluster is even mask out the final four bits
|
2021-06-22 13:05:09 +00:00
|
|
|
.even:
|
|
|
|
and ax, 0xfff
|
|
|
|
.contcalc:
|
2021-07-10 17:49:06 +00:00
|
|
|
;Check for the file end
|
2021-06-22 13:05:09 +00:00
|
|
|
cmp ax, 0xff8
|
2021-07-01 13:50:43 +00:00
|
|
|
jge .success
|
2021-07-10 17:49:06 +00:00
|
|
|
;Store the address of the next cluster
|
|
|
|
mov word [.cluster], ax
|
|
|
|
;Set the destination of the next cluster
|
2021-08-27 17:25:46 +00:00
|
|
|
mov ax, [sectorsize]
|
|
|
|
mul word [clustersize]
|
2021-06-22 13:05:09 +00:00
|
|
|
add word [.pointer], ax
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the next cluster
|
2021-06-22 13:05:09 +00:00
|
|
|
jmp .loadcluster
|
|
|
|
|
2021-07-06 18:12:15 +00:00
|
|
|
;Set AL to 0x0 and load the file size to CX if the load was succesful
|
2021-07-01 13:50:43 +00:00
|
|
|
.success:
|
|
|
|
mov al, 0x0
|
2021-07-06 18:12:15 +00:00
|
|
|
mov cx, [.size]
|
2021-06-22 13:05:09 +00:00
|
|
|
|
|
|
|
;Clear the stack
|
|
|
|
.done:
|
|
|
|
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load DI, SI, DX, and BX from the stack
|
2021-06-22 13:05:09 +00:00
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop dx
|
|
|
|
pop bx
|
|
|
|
|
2021-07-01 13:50:43 +00:00
|
|
|
;Set AH to its initial value
|
|
|
|
mov ah, 0x0
|
|
|
|
|
2021-07-10 17:49:06 +00:00
|
|
|
;Return
|
2021-06-22 13:05:09 +00:00
|
|
|
iret
|
|
|
|
|
|
|
|
;Data
|
2021-06-24 15:34:41 +00:00
|
|
|
.file times 0xb db 0x20
|
2021-07-06 18:12:15 +00:00
|
|
|
.size dw 0x0
|
2021-06-24 15:34:41 +00:00
|
|
|
.cluster dw 0x0
|
|
|
|
.pointer dw 0x0
|
2021-06-28 17:00:22 +00:00
|
|
|
.driverrormsg db "Drive not found", 0x0
|
2021-07-01 13:50:43 +00:00
|
|
|
.diskerrormsg db "Unable to read disk", 0x0
|
|
|
|
.filerrormsg db "File or command not found", 0x0
|
|
|
|
.sizerrormsg db "Not enough memory", 0x0
|
2021-06-22 13:05:09 +00:00
|
|
|
|
2021-07-10 17:49:06 +00:00
|
|
|
;***
|
|
|
|
|
2021-06-27 16:22:58 +00:00
|
|
|
;Check the file name and convert to upper case
|
2021-06-22 13:05:09 +00:00
|
|
|
.checkconv:
|
2021-07-10 17:49:06 +00:00
|
|
|
|
|
|
|
;Check for the string end, length limit, and invalid characters
|
2021-06-22 13:05:09 +00:00
|
|
|
;Check for the string end
|
|
|
|
cmp al, 0x0
|
|
|
|
je .load
|
|
|
|
;Check for the length limit
|
|
|
|
cmp bl, 0x0
|
|
|
|
je .error
|
|
|
|
;Check for invalid characters
|
|
|
|
cmp al, 0x22
|
|
|
|
je .error
|
|
|
|
cmp al, 0x2a
|
|
|
|
jl .contcheck1
|
|
|
|
cmp al, 0x2c
|
|
|
|
jg .contcheck1
|
|
|
|
jmp .error
|
|
|
|
.contcheck1:
|
|
|
|
cmp al, 0x2f
|
|
|
|
je .error
|
|
|
|
cmp al, 0x3a
|
|
|
|
jl .contcheck2
|
|
|
|
cmp al, 0x3f
|
|
|
|
jg .contcheck2
|
|
|
|
jmp .error
|
|
|
|
.contcheck2:
|
|
|
|
cmp al, 0x5b
|
|
|
|
jl .contcheck3
|
|
|
|
cmp al, 0x5d
|
|
|
|
jg .contcheck3
|
|
|
|
jmp .error
|
|
|
|
.contcheck3:
|
|
|
|
cmp al, 0x7c
|
|
|
|
je .error
|
2021-07-10 17:49:06 +00:00
|
|
|
|
|
|
|
;Check for lower case and convert it to upper case
|
2021-06-22 13:05:09 +00:00
|
|
|
;Check for lower case
|
|
|
|
cmp al, 0x61
|
|
|
|
jl .storech
|
|
|
|
cmp al, 0x7a
|
|
|
|
jg .storech
|
|
|
|
;Convert lower to upper case
|
|
|
|
sub al, 0x20
|
2021-07-10 17:49:06 +00:00
|
|
|
|
2021-06-22 13:05:09 +00:00
|
|
|
;Store the character
|
2021-07-10 17:49:06 +00:00
|
|
|
.storech:
|
2021-06-22 13:05:09 +00:00
|
|
|
stosb
|
2021-07-10 17:49:06 +00:00
|
|
|
|
2021-06-24 15:34:41 +00:00
|
|
|
;Decrease the counter
|
2021-06-22 13:05:09 +00:00
|
|
|
dec bl
|
2021-07-10 17:49:06 +00:00
|
|
|
|
|
|
|
;Return
|
2021-06-22 13:05:09 +00:00
|
|
|
ret
|
|
|
|
|
2021-07-10 17:49:06 +00:00
|
|
|
;***
|
|
|
|
|
2021-06-22 13:05:09 +00:00
|
|
|
;Calculate the source arguments for loading data from the disk
|
|
|
|
.calcsource:
|
2021-07-10 17:49:06 +00:00
|
|
|
|
|
|
|
;Store AX and BX in the stack
|
2021-06-22 13:05:09 +00:00
|
|
|
push ax
|
|
|
|
push bx
|
2021-07-10 17:49:06 +00:00
|
|
|
|
|
|
|
;Calculate the cylinder, head, and sector
|
|
|
|
;Store the logical sector in BX
|
2021-06-22 13:05:09 +00:00
|
|
|
mov bx, ax
|
2021-07-10 17:49:06 +00:00
|
|
|
;Calculate the sector
|
2021-06-22 13:05:09 +00:00
|
|
|
mov dx, 0x0
|
2021-08-27 17:25:46 +00:00
|
|
|
div word [sectorspertrack]
|
2021-06-22 13:05:09 +00:00
|
|
|
add dl, 0x1
|
|
|
|
mov cl, dl
|
2021-07-10 17:49:06 +00:00
|
|
|
;Load the logical sector from BX
|
2021-06-22 13:05:09 +00:00
|
|
|
mov ax, bx
|
2021-07-10 17:49:06 +00:00
|
|
|
;Calculate the head and cylinder
|
2021-06-22 13:05:09 +00:00
|
|
|
mov dx, 0x0
|
2021-08-27 17:25:46 +00:00
|
|
|
div word [sectorspertrack]
|
2021-06-22 13:05:09 +00:00
|
|
|
mov dx, 0x0
|
2021-08-27 17:25:46 +00:00
|
|
|
div word [heads]
|
2021-07-10 17:49:06 +00:00
|
|
|
mov dh, dl ;Head
|
|
|
|
mov ch, al ;Cylinder
|
|
|
|
|
|
|
|
;Load the drive number
|
2021-08-27 17:25:46 +00:00
|
|
|
mov dl, byte [drive]
|
2021-07-10 17:49:06 +00:00
|
|
|
|
|
|
|
;Load BX and AX from the stack
|
2021-06-22 13:05:09 +00:00
|
|
|
pop bx
|
|
|
|
pop ax
|
2021-07-10 17:49:06 +00:00
|
|
|
|
|
|
|
;Return
|
2021-06-22 13:05:09 +00:00
|
|
|
ret
|