Don't assume things about ds/es
This commit is contained in:
parent
2a3200fc73
commit
565fff50b4
23
ponydos.asm
23
ponydos.asm
|
@ -195,8 +195,13 @@ modify_sector:
|
|||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push ds
|
||||
|
||||
mov cx, 18
|
||||
xor cx, cx
|
||||
mov ds, cx
|
||||
|
||||
;mov cx, 18
|
||||
mov cl, 18
|
||||
div cx
|
||||
|
||||
; cl = sector (1…18)
|
||||
|
@ -212,7 +217,7 @@ modify_sector:
|
|||
mov ch, al
|
||||
|
||||
; dl = drive number
|
||||
mov dl, [boot_disk]
|
||||
mov dl, [ds:boot_disk]
|
||||
|
||||
.retry:
|
||||
mov ax, 0x0201 ; read/write one sector
|
||||
|
@ -220,6 +225,7 @@ modify_sector:
|
|||
int 0x13
|
||||
jc .error
|
||||
|
||||
pop ds
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
|
@ -240,7 +246,7 @@ modify_sector:
|
|||
wallpaper_name: db 'wallpaper.bin', 0
|
||||
|
||||
; in:
|
||||
; es:si = file name
|
||||
; ds:si = file name
|
||||
; out:
|
||||
; ax = LBA of first sector, 0 if no space left
|
||||
; cx = length in sectors
|
||||
|
@ -248,8 +254,11 @@ open_file:
|
|||
push si
|
||||
push di
|
||||
push bx
|
||||
push es
|
||||
|
||||
; Stolen from https://stackoverflow.com/a/72746473, get strlen in cx
|
||||
mov cx, ds
|
||||
mov es, cx
|
||||
mov di, si
|
||||
mov cx, -1
|
||||
xor ax, ax
|
||||
|
@ -257,6 +266,7 @@ open_file:
|
|||
not cx
|
||||
dec cx
|
||||
|
||||
mov es, ax
|
||||
;mov ax, 1
|
||||
mov al, 1
|
||||
mov bx, DIRENTS
|
||||
|
@ -266,7 +276,7 @@ open_file:
|
|||
mov ax, 2
|
||||
mov di, bx
|
||||
.loop:
|
||||
cmp word [di], 0
|
||||
cmp word [es:di], 0
|
||||
je .create_file
|
||||
|
||||
inc di
|
||||
|
@ -290,8 +300,9 @@ open_file:
|
|||
xor ax, ax
|
||||
; Return with mangled cx
|
||||
.success:
|
||||
mov cx, [di - 2]
|
||||
mov cx, [es:di - 2]
|
||||
.return:
|
||||
pop es
|
||||
pop bx
|
||||
pop di
|
||||
pop si
|
||||
|
@ -299,7 +310,7 @@ open_file:
|
|||
|
||||
.create_file:
|
||||
; TODO: zero out the sector for this file?
|
||||
inc word [di]
|
||||
inc word [es:di]
|
||||
inc di
|
||||
inc di
|
||||
rep movsb
|
||||
|
|
Loading…
Reference in New Issue