summaryrefslogtreecommitdiff
path: root/syslinux.asm
diff options
context:
space:
mode:
authorhpa <hpa>1998-02-03 10:16:14 +0000
committerhpa <hpa>1998-02-03 10:16:14 +0000
commitcef0fd80434153eee525e9bf385511499fe9eeeb (patch)
tree2162e163aa7e5601018604a3b04e35192d4826cb /syslinux.asm
parent15baf6b9b375781c41f6799ff1f17d20962c82a7 (diff)
downloadsyslinux-cef0fd80434153eee525e9bf385511499fe9eeeb.tar.gz
Bug fixes; first beginnings of FAT16 support
Diffstat (limited to 'syslinux.asm')
-rw-r--r--syslinux.asm74
1 files changed, 68 insertions, 6 deletions
diff --git a/syslinux.asm b/syslinux.asm
index 84e5ef4e..f0e0261c 100644
--- a/syslinux.asm
+++ b/syslinux.asm
@@ -19,8 +19,8 @@
;
absolute 0080h
-psp_cmdlen resb 1
-psp_cmdline resb 127
+psp_cmdlen: resb 1
+psp_cmdline: resb 127
section .text
org 0100h
@@ -48,7 +48,7 @@ cmdscan1: jcxz bad_usage ; End of command line?
mov [DriveNo],al ; Save away drive index
section .bss
-DriveNo resb 1
+DriveNo: resb 1
section .text
;
@@ -78,13 +78,14 @@ bad_usage: mov dx,msg_unfair
int 21h
section .data
-msg_unfair db 'Usage: syslinux <drive>:', 0Dh, 0Ah, '$'
+msg_unfair: db 'Usage: syslinux <drive>:', 0Dh, 0Ah, '$'
section .text
;
; Parsed the command line OK, now get to work
;
got_cmdline: ; BUG: check sector size == 512
+ ; Use INT 21h:32h
mov bx,SectorBuffer
mov al,[DriveNo]
@@ -100,9 +101,61 @@ got_cmdline: ; BUG: check sector size == 512
mov di,BootSector+11
mov cx,51 ; Superblock = 51 bytes
rep movsb ; Copy the superblock
+;
+; Writing LDLINUX.SYS
+;
+ ; 1. If the file exists, strip its attributes and delete
+
+ xor cx,cx ; Clear attributes
+ mov dx,ldlinux_sys_str
+ mov ax,4301h ; Set file attributes
+ int 21h
+
+ mov dx,ldlinux_sys_str
+ mov ah,41h ; Delete file
+ int 21h
+
+ section .data
+ldlinux_sys_str: db 'LDLINUX.SYS', 0
+
+ section .text
+
+ ; 2. Create LDLINUX.SYS and write data to it
+
+ mov dx,ldlinux_sys_str
+ xor cx,cx ; Normal file
+ mov ah,3Ch ; Create file
+ int 21h
+ jc file_write_error
+ mov [FileHandle],ax
+
+ mov bx,ax
+ mov cx,ldlinux_size
+ mov dx,LDLinuxSYS
+ mov ah,40h ; Write data
+ int 21h
+ jc file_write_error
+ cmp ax,ldlinux_size
+ jne file_write_error
+
+ mov bx,[FileHandle]
+ mov ah,3Eh ; Close file
+ int 21h
+
+ section .bss
+FileHandle: resw 1
+
+ section .text
- ; Write LDLINUX.SYS here (*before* writing boot sector)
+ ; 3. Set the readonly flag on LDLINUX.SYS
+ mov dx,ldlinux_sys_str
+ mov cx,1 ; Read only
+ mov ax,4301h ; Set attributes
+ int 21h
+;
+; Writing boot sector
+;
mov bx,BootSector
mov cx,1 ; One sector
xor dx,dx ; Absolute sector 0
@@ -115,13 +168,22 @@ all_done: mov ax,4C00h ; Exit good status
disk_read_error:
disk_write_error:
- mov ax,4C01h
+file_write_error:
+ mov dx,msg_bummer
+ mov ah,09h ; Write string
int 21h
+ mov ax,4C01h ; Exit error status
+ int 21h
+
+ section .data
+msg_bummer: db 'Disk write error', 0Dh, 0Ah, '$'
+
section .data
align 4, db 0
BootSector: incbin "bootsect.bin"
LDLinuxSYS: incbin "ldlinux.sys"
+ldlinux_size: equ $-LDLinuxSYS
section .bss
alignb 4