From 919723032fb1bda50a8a8be50805441d7863c685 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Mon, 12 Aug 2024 04:51:06 +0100 Subject: [PATCH] Write data to file, bug fixes and improvements --- build/chimaera.img | Bin 368640 -> 368640 bytes build/chimaera.vhd | Bin 34120704 -> 34120704 bytes src/apps/hello/hello.asm | 247 ++++++-- src/apps/pcomm/del.asm | 374 ++++++++++-- src/apps/pcomm/dir.asm | 267 +++++++- src/apps/pcomm/mkdir.asm | 328 +++++++++- src/apps/pcomm/rmdir.asm | 367 +++++++++-- src/apps/pcomm/touch.asm | 362 +++++++++-- src/apps/pcomm/type.asm | 387 ++++++++++-- src/apps/pcomm/xstrcpy.asm | 6 +- src/kernel/file.asm | 1173 +++++++++++++++++++++++++++++++----- src/kernel/int21.asm | 19 +- 12 files changed, 3038 insertions(+), 492 deletions(-) diff --git a/build/chimaera.img b/build/chimaera.img index 2979e9a6ab4ad936b400bfd86c80bf5a0f0bdb0b..1a20b316af9aa033ee77c59245a1204993a22ae1 100644 GIT binary patch delta 9506 zcmbVR3s_Xu_CMzg%zzFf$|K&)@EBflWYkoI89`ytKo}SU1`zE1vRm=cd##x9P9eu3 zGItO4R#z^S|FCWrRLI;L;FL&88B%HXxTSUXI9e)(sL1@+J~IO(WPX?Ln>l;d-h1tJ z*7~jAUVCHc@;7w(Z;5ex`-fxqyqz$e363_{V+>5(P9~v?N&F8phY~2Hf_Z6zn+^8X zeC9{N^#=(5EzsX07wg12iXu;n|67`uw@T{x^LEHx{S4o)F38Nx$taL&bz13f``syB zJVj+^7UX8;NT=xcrUZo)wJdMt%Jkd}DLkdrOnzb40&=P*wUs_{yVuqL$;yeAIaX#_ zr(II%HI_LncUcCbuIU$mH(nKh*1U;Y1^l$%*ZSM{U8c^u=6&6$D$v_3ctgLW74}wPFS3fUONbW|vEHu4BT9TpiHDRXHAUt; zcNyeZiGNh$AC&kzC3hC)far52?pNYZmH3d78^)KFAlj$Iol5*KCElwnhAAM~qr`72 zaf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RDAqCwai!xEmX^xlSVE#ZxGyqEIWHd0`9GQDwE$denc&kHWQDx2 zctl<}W0BG&J@_X}0KK#ai;u|1ec?xjmV`t8q1Rc3aM~|gVtB#gXm0P!N6^=s4Ea=>T zP?rDMEeQQX*!DMsgd+V;go-3fDTJQ)U$GjYL*D;-6QL6S&q5HY^SP%-=w4t7gib}s zz~2#)hgTFKR25$M1473Xzn?b@VPvbP?HJ^ZXpJ{O)M5x7P8^2Np~SI1R7d{p0f*r3 zL^{1jmh_6yb-9lwj`g8Ki6hRHIJgV067)_OUyS@9l&*zAG4crK*^*7i$z2b4{OG}t zy~iCV*E~onvHy*!=cO<80`;6_Z++-ce(`kv?l`id%kiGC{}$TFcREm)4EIMiJzqi7 zvqg*x+Jaa8k)QDY>3ymcq(*FO1)!1u2D+t6K8#Zp-zK9%AfP6qk9 z>_>4bm%DM&!!I9Bq$W2d98e%9$@e+{RK0?4em+rtEePD1e*h9BGR1O>bP&s69 zk5We}1tSc8Uo_I-J|%P*o8fnhU$%Qa%3s+$*zZl7;O_TAC-5dGP9T35fXVCT^8H>? zK6zU}&~4y- zjzDD?6bA+Uyr;=AZsA#7hd3;Jt@b c_12C}TRSNDr{Q1l`PL5MAI+w%9rdIC4{zZsvH$=8 diff --git a/build/chimaera.vhd b/build/chimaera.vhd index cb81b9896e35a529d13f514c119092e474b81155..3868ac93db139f313cd27c6f5df927a8404a7437 100644 GIT binary patch delta 30420 zcmeHQdstIfwm;_tk{t~J(0&5flPega8%@AZYD#rkzfC=-jqf(wkN} zhBD6daayMjDQ%t7cE&0dG@XJ*MXLBfYPD#cR@>PzS|3k8b&#T%+)K{0O|IkFOVbwm1mlkuB$= z^N~wPcg*lfBM3qVS2|q%4u|*4isky~B~U1Zs|>ECa4m!DLAaK~^$=VS!}W;i$>nRF zTu#D8!6jm!T<-C^%@6vJ|Hmp{dj!d=7pi0inSmgX_<;q>ca?8K0(aSUbHABD^&qc1>wsN>>eP4s7l&G zQV)`^J%;3qMw;dvnx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uakudx)9N0DG`ZZJgjrxG+Y$Toz})`wiz9XhV;x zH~R}}^B2t2J(#?sQUwOw6hIMJhni^@2nGfRD+^~!zEi0NX8z=&F}09Lc5e2M<1bpv z1NZ{AI9u*4Ol7uJoz{u~+SU(>oRexMXFwH)OxDf*X1Y>f&e!f!BIwelesugD+uTn2 z>;u~$JL${qB-C9sX?VGx07nrMw9B{&QF((V%*)fj`2>bv0Edp@MZ zT{YOV+^-g(Vss?x$UmPyymQO&LKy`%Y8!Mu8O6_{fV@{B4~Nq(}40;P!FI)IRS+~2Mf8%8^Y^K zFyty6B9N7<57Ijr9zSDY>Rb_*PI4?x@7?NuSL68nW3} z^=VMKP!U1qDtyqpINA@z(OLz`^i%mS`VV2o|E5SE6LyN?wP!xf+O0`0jv|USE z+yuh53~F>bs&iKxIhXgoesD+c?YT7%)gp* z9u1=La$5&z-405z)sJ+KwSJ`Q(Yj4%q6M;ET7T*Ggw`E8C`H!5*C$UFhi$rFDBfKi zjvVZ&4ub{@dPfhYf0cpW%O?xfVN3@7L`Kn7dxW5T%nk?I`6v`Fx>^YLAijy;{q+R* zrPx%#k{3c$1Bcjt=io{O5iiPJwrSJ#vQ013IG7JijH(jq$3+bLQ5d;7NR`B35;Iuk zAR11ULSCY{KU+Vn*PX`I5$`mvj(DeWb;LW3t0UfNoSm^fjKn*Qlh}QyadpHyjjJQx zX*e*ja0AesOG diff --git a/src/apps/hello/hello.asm b/src/apps/hello/hello.asm index 805c24e..5f26689 100644 --- a/src/apps/hello/hello.asm +++ b/src/apps/hello/hello.asm @@ -19,60 +19,188 @@ _main: mov bx, offset _msg_hello call _writestr - mov ah, HEX (39) - mov dx, offset _new_dir - int HEX (21) - jc .exit - - mov ah, HEX (3A) - mov dx, offset _new_dir - int HEX (21) - jc .exit - - mov bx, offset _msg_status - call _writestr - - mov ah, HEX (3C) - mov cx, HEX (20) - mov dx, offset _new_file - int HEX (21) - jc .exit - - call _writehex - call _crlf - - mov bx, ax - - mov ax, HEX (4202) - mov cx, 4096 - xor dx, dx - int HEX (21) - jc .exit - - call _writehex - call _crlf - - mov ah, HEX (40) - xor cx, cx - xor dx, dx - int HEX (21) - jc .exit - - mov ax, HEX (4200) - mov cx, 1000 - xor dx, dx - int HEX (21) - jc .exit - - call _writehex - call _crlf - - mov ah, HEX (40) - xor cx, cx - xor dx, dx - int HEX (21) - jc .exit - +; mov ax, offset _flags +; push ax +; +; mov ax, offset _existing_file +; push ax +; +; call _fopen +; add sp, 4 +; +; and ax, ax +; jz .exit +; +; mov cs:[_file_pointer], ax +; +; mov bx, offset _msg_status +; call _writestr +; +; mov ax, cs:[_file_pointer] +; push ax +; +; mov ax, 512 +; push ax +; +; mov ax, 1 +; push ax +; +; mov ax, offset _buffer +; push ax +; +; call _fread +; add sp, 8 +; +; and ax, ax +; jz .exit +; +; mov cs:[_to_write], ax +; +; mov ax, cs:[_file_pointer] +; push ax +; +; call _fclose +; add sp, 2 +; +; mov bx, offset _msg_status +; call _writestr +; +; mov ax, offset _flags +; push ax +; +; mov ax, offset _new_file +; push ax +; +; call _fopen +; add sp, 4 +; +; and ax, ax +; jz .exit +; +; mov cs:[_file_pointer], ax +; +; mov bx, offset _msg_status +; call _writestr +; +; mov cx, 5 +; +;.write_loop: +; +; mov ax, cs:[_file_pointer] +; push ax +; +; mov ax, cs:[_to_write] +; push ax +; +; mov ax, 1 +; push ax +; +; mov ax, offset _buffer +; push ax +; +; call _fwrite +; add sp, 8 +; +; cmp ax, cs:[_to_write] +; jne .exit +; +; mov bx, offset _msg_write +; call _writestr +; +; loop .write_loop +; +; mov ah, HEX (3C) +; mov cx, HEX (20) +; mov dx, offset _new_file +; int HEX (21) +; jc .exit +; +; call _writehex +; call _crlf +; +; mov bx, ax +; +; mov ax, HEX (4202) +; mov cx, 4096 +; xor dx, dx +; int HEX (21) +; jc .exit +; +; call _writehex +; call _crlf +; +; mov ah, HEX (40) +; xor cx, cx +; xor dx, dx +; int HEX (21) +; jc .exit +; +; mov ax, HEX (4200) +; xor cx, cx +; xor dx, dx +; int HEX (21) +; jc .exit +; +; mov ah, HEX (40) +; mov cx, 15 +; mov dx, offset _msg_hello +; int HEX (21) +; jc .exit +; +; mov ah, HEX (39) +; mov dx, offset _new_dir +; int HEX (21) +; jc .exit +; +; mov ah, HEX (3A) +; mov dx, offset _new_dir +; int HEX (21) +; jc .exit +; +; mov bx, offset _msg_status +; call _writestr +; +; mov ah, HEX (3C) +; mov cx, HEX (20) +; mov dx, offset _new_file +; int HEX (21) +; jc .exit +; +; call _writehex +; call _crlf +; +; mov bx, ax +; +; mov ax, HEX (4202) +; mov cx, 4096 +; xor dx, dx +; int HEX (21) +; jc .exit +; +; call _writehex +; call _crlf +; +; mov ah, HEX (40) +; xor cx, cx +; xor dx, dx +; int HEX (21) +; jc .exit +; +; mov ax, HEX (4200) +; mov cx, 1000 +; xor dx, dx +; int HEX (21) +; jc .exit +; +; call _writehex +; call _crlf +; +; mov ah, HEX (40) +; xor cx, cx +; xor dx, dx +; int HEX (21) +; jc .exit +; ; mov ah, HEX (3C) ; mov cx, HEX (20) ; mov dx, offset _new_file @@ -194,7 +322,12 @@ _main: ;; Data area. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _msg_hello: db "Hello, world!", HEX (0D), HEX (0A), HEX (00) -_msg_status: db "File tests", HEX (0D), HEX (0A), HEX (00) -_new_dir: db "temp", HEX (00) -_new_file: db "temp.txt", HEX (00) +;_msg_write: db "Bytes written", HEX (0D), HEX (0A), HEX (00) +;_msg_status: db "File tests", HEX (0D), HEX (0A), HEX (00) +;_new_dir: db "temp", HEX (00) +;_new_file: db "temp.txt", HEX (00) ;_existing_file: db "\\boot\\freeldr\\freeldr.cfg", HEX (00) +;_file_pointer: dw HEX (0000) +;_flags: db "w+b", HEX (00) +;_buffer: db 512 dup (0) +;_to_write: dw HEX (0000) diff --git a/src/apps/pcomm/del.asm b/src/apps/pcomm/del.asm index d9c086e..abd4bd1 100644 --- a/src/apps/pcomm/del.asm +++ b/src/apps/pcomm/del.asm @@ -1,5 +1,5 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; @file type.asm +;; @file del.asm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %ifndef HEX % define HEX(y) 0x##y @@ -14,7 +14,7 @@ _handler_del: push bp mov bp, sp - sub sp, 4 + sub sp, 6 push ax push bx @@ -25,6 +25,7 @@ _handler_del: push es push ds + mov word ptr [bp - 6], 0 mov word ptr [bp - 4], 0 mov word ptr [bp - 2], 0 @@ -57,7 +58,7 @@ _handler_del.ok: _handler_del.store_arg: cmp byte ptr [bx], 0 - je _handler_del.next + je _handler_del.check2 mov si, bx push si @@ -80,7 +81,7 @@ _handler_del.check: add sp, 4 and ax, ax - jz _handler_del.next + jz _handler_del.check2 mov bx, ax mov byte ptr [bx], 0 @@ -90,7 +91,7 @@ _handler_del.check: _handler_del.skip: cmp byte ptr [bx], 0 - je _handler_del.next + je _handler_del.check2 cmp byte ptr [bx], ' ' ja _handler_del.store_arg @@ -98,15 +99,20 @@ _handler_del.skip: inc bx jmp _handler_del.skip +_handler_del.check2: + + cmp word ptr cs:[_vec_files + 4], 1 + jbe _handler_del.next + _handler_del.next: - mov ax, word ptr [bp - 4] + mov ax, word ptr [bp - 6] inc ax cmp ax, cs:[_vec_files + 4] ja _handler_del.cleanup - mov word ptr [bp - 4], ax + mov word ptr [bp - 6], ax dec ax xor dx, dx @@ -121,107 +127,363 @@ _handler_del.next: mov es, ax mov ax, es:[bx] - mov bx, ax + mov dx, ax pop es + + call _delete_file + jmp _handler_del.next + +_handler_del.cleanup: + + mov ax, cs:[_vec_files + 0] + push ax + + call _free + add sp, 2 + + mov ax, cs + mov es, ax + + mov di, offset _vec_files + xor al, al + + mov cx, 6 + rep stosb -_handler_del.delete: +_handler_del.done: + pop ds + pop es + pop di + pop si + pop dx + pop cx + pop bx + pop ax + + add sp, 6 + pop bp + + ret + +;****************************************************************************** +; @function _delete_file +;****************************************************************************** +_delete_file: + + push ax push bx + push dx + push ds + push cx + + mov di, offset _file_path + mov cx, 256 + + xor al, al + rep stosb + + mov ah, HEX (19) + int HEX (21) + + mov byte ptr [bp - 4], al + mov si, dx + + push si + + call _strlen + add sp, 2 + + cmp ax, 2 + jb _delete_file.got_drive + + cmp byte ptr [si + 1], ':' + jne _delete_file.got_drive + + mov al, [si] + + cmp al, HEX (7A) + ja _delete_file.no_adjust + + cmp al, HEX (61) + jb _delete_file.no_adjust + + mov bl, HEX (20) + not bl + + sub al, 'a' + + mov byte ptr [bp - 4], al + add si, 2 + + jmp _delete_file.got_drive + +_delete_file.no_adjust: + + cmp al, HEX (5A) + ja _delete_file.got_drive + + cmp al, HEX (41) + jb _delete_file.got_drive + + sub al, 'A' + + mov byte ptr [bp - 4], al + add si, 2 + +_delete_file.got_drive: + + mov di, offset _file_path + + mov al, byte ptr [bp - 4] + add al, 'A' + stosb + + mov al, ':' + stosb + + cmp byte ptr [si], '\\' + je _delete_file.initial_setup + + mov al, '\\' + stosb + + push dx + push si + + mov dl, byte ptr [bp - 4] + mov si, di + + mov ah, HEX (47) + int HEX (21) + + pop si + pop dx + + mov di, offset _file_path + push di + + call _strlen + add sp, 2 + + add di, ax + +_delete_file.initial_setup: + + cmp byte ptr es:[di - 1], '\\' + je _delete_file.no_slash + + mov al, '\\' + stosb + +_delete_file.no_slash: + + mov bx, si + +_delete_file.loop: + + mov ax, si + sub ax, bx + cmp ax, 65 + ja _delete_file.check_path + + lodsb + + and al, al + jz _delete_file.check_path + + cmp al, '.' + je _delete_file.check_curr + + cmp al, '\\' + jne _delete_file.convert_alpha + + cmp si, bx + je _delete_file.loop + + cmp byte ptr es:[di - 1], '\\' + je _delete_file.loop + +_delete_file.convert_alpha: + + xor ah, ah + push ax + + call _isalpha + + and ax, ax + jz _delete_file.no_alpha + + call _toupper + add sp, 2 + + jmp _delete_file.char_ok2 + +_delete_file.no_alpha: + + pop ax + jmp _delete_file.char_ok2 + +_delete_file.check_curr: + + cmp byte ptr [si], 0 + je _delete_file.loop + + cmp byte ptr [si], '\\' + je _delete_file.loop + + cmp byte ptr [si], '.' + je _delete_file.check_prev + + jmp _delete_file.char_ok2 + +_delete_file.check_prev: + + cmp byte ptr [si + 1], 0 + je _delete_file.get_prev + + cmp byte ptr [si + 1], '\\' + jne _delete_file.char_ok2 + +_delete_file.get_prev: + + mov cx, offset _file_path + add cx, 3 + + cmp di, cx + je _delete_file.no_slash2 + + cmp byte ptr es:[di - 1], '\\' + jne _delete_file.no_slash2 + + mov byte ptr es:[di - 1], 0 + +_delete_file.no_slash2: + + push si + push ds + + mov ax, cs + mov ds, ax + + mov ax, '\\' + push ax + + mov ax, offset _file_path + push ax + + call _strrchr + add sp, 4 + + pop ds + pop si + + and ax, ax + jnz _delete_file.got_index + + mov di, offset _file_path + jmp _delete_file.zero + +_delete_file.got_index: + + mov di, ax + inc di + +_delete_file.zero: + + mov byte ptr es:[di], 0 + jmp _delete_file.loop + +_delete_file.char_ok2: + + stosb + jmp _delete_file.loop + +_delete_file.check_path: + + cmp byte ptr es:[di - 1], '\\' + jne _delete_file.null + + dec di + +_delete_file.null: + + xor al, al + stosb + +_delete_file.delete: + mov ah, HEX (41) - mov dx, bx + mov dx, offset _file_path int HEX (21) - jnc _handler_del.close + jnc _delete_file.close + + mov cx, offset _file_path cmp ax, 2 - jne _handler_del.check3 + jne _delete_file.check mov bx, offset _err_no_file - jmp _handler_del.error - -_handler_del.check3: + jmp _delete_file.error +_delete_file.check: + cmp ax, 3 - jne _handler_del.unhandled + jne _delete_file.unhandled - mov bx, offset _err_no_dir - jmp _handler_del.error + mov bx, offset _err_no_path + jmp _delete_file.error -_handler_del.unhandled: +_delete_file.unhandled: - pop bx mov bx, offset _err_unhandled -_handler_del.error: +_delete_file.error: call _writestr cmp ax, 3 - ja _handler_del.next + ja _delete_file.done cmp ax, 2 - jb _handler_del.next + jb _delete_file.done - pop bx + mov bx, offset _file_path call _writestr call _crlf - jmp _handler_del.next + jmp _delete_file.done -_handler_del.close: +_delete_file.close: - pop bx mov bx, ax mov ah, HEX (3E) int HEX (21) - - jmp _handler_del.next -_handler_del.cleanup: - - mov ax, cs:[_vec_files + 0] - push ax - - call _free - add sp, 2 - - mov ax, cs - mov es, ax - - mov di, offset _vec_files - xor al, al - - mov cx, 6 - rep stosb - -_handler_del.done: +_delete_file.done: + pop cx pop ds - pop es - pop di - pop si pop dx - pop cx pop bx pop ax - - add sp, 4 - pop bp - ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data area. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _vec_files: db 6 dup (0) + _cmdline: db 256 dup (0) +_file_path: db 256 dup (0) _err_invalid: db "Invalid number of parameters", HEX (0D), HEX (0A), HEX (00) -_err_no_dir: db "Path not found: ", HEX (00) +_err_no_path: db "Path not found: ", HEX (00) _err_no_file: db "File not found: ", HEX (00) _err_unhandled: db "Unhandled error code", HEX (0D), HEX (0A), HEX (00) diff --git a/src/apps/pcomm/dir.asm b/src/apps/pcomm/dir.asm index 8a86bf5..cbf62ac 100644 --- a/src/apps/pcomm/dir.asm +++ b/src/apps/pcomm/dir.asm @@ -14,7 +14,7 @@ _handler_dir: push bp mov bp, sp - sub sp, 6 + sub sp, 10 push ax push bx @@ -25,8 +25,9 @@ _handler_dir: push es push ds + mov word ptr [bp - 4], 1 + mov word ptr [bp - 6], 0 - mov word ptr [bp - 4], 0 mov word ptr [bp - 2], 0 mov ax, 64 @@ -53,6 +54,7 @@ _handler_dir: jne _handler_dir.got_path mov bx, offset _fn_wild + mov word ptr [bp - 4], 0 _handler_dir.got_path: @@ -200,7 +202,7 @@ _handler_dir.done: pop bx pop ax - add sp, 6 + add sp, 10 pop bp ret @@ -216,22 +218,251 @@ _walk_dir: push ds push cx + mov di, offset _file_path + mov cx, 256 + + xor al, al + rep stosb + mov word ptr [bp - 2], 0 - mov si, offset _file_path + + cmp word ptr [bp - 4], 1 + jb _walk_dir.find_first + + mov ah, HEX (19) + int HEX (21) + + mov byte ptr [bp - 10], al + mov si, dx + + push si + + call _strlen + add sp, 2 + + cmp ax, 2 + jb _walk_dir.got_drive + + cmp byte ptr [si + 1], ':' + jne _walk_dir.got_drive + + mov al, [si] + + cmp al, HEX (7A) + ja _walk_dir.no_adjust + + cmp al, HEX (61) + jb _walk_dir.no_adjust + + mov bl, HEX (20) + not bl + + sub al, 'a' + + mov byte ptr [bp - 10], al + add si, 2 + + jmp _walk_dir.got_drive + +_walk_dir.no_adjust: + + cmp al, HEX (5A) + ja _walk_dir.got_drive + + cmp al, HEX (41) + jb _walk_dir.got_drive + + sub al, 'A' + + mov byte ptr [bp - 10], al + add si, 2 + +_walk_dir.got_drive: + + mov di, offset _file_path + + mov al, byte ptr [bp - 10] + add al, 'A' + stosb + + mov al, ':' + stosb + + cmp byte ptr [si], '\\' + je _walk_dir.initial_setup + + mov al, '\\' + stosb push dx push si - call _xstrcpy + mov dl, byte ptr [bp - 10] + mov si, di + + mov ah, HEX (47) + int HEX (21) + + pop si + pop dx + + mov di, offset _file_path + push di + + call _strlen + add sp, 2 + + add di, ax + +_walk_dir.initial_setup: + + cmp byte ptr es:[di - 1], '\\' + je _walk_dir.no_slash + + mov al, '\\' + stosb + +_walk_dir.no_slash: + + mov bx, si + +_walk_dir.loop: + + mov ax, si + sub ax, bx + + cmp ax, 65 + ja _walk_dir.check_path + + lodsb + + and al, al + jz _walk_dir.check_path + + cmp al, '.' + je _walk_dir.check_curr + + cmp al, '\\' + jne _walk_dir.convert_alpha + + cmp si, bx + je _walk_dir.loop + + cmp byte ptr es:[di - 1], '\\' + je _walk_dir.loop + +_walk_dir.convert_alpha: + + xor ah, ah + push ax + + call _isalpha + + and ax, ax + jz _walk_dir.no_alpha + + call _toupper + add sp, 2 + + jmp _walk_dir.char_ok + +_walk_dir.no_alpha: + + pop ax + jmp _walk_dir.char_ok + +_walk_dir.check_curr: + + cmp byte ptr [si], 0 + je _walk_dir.loop + + cmp byte ptr [si], '\\' + je _walk_dir.loop + + cmp byte ptr [si], '.' + je _walk_dir.check_prev + + jmp _walk_dir.char_ok + +_walk_dir.check_prev: + + cmp byte ptr [si + 1], 0 + je _walk_dir.get_prev + + cmp byte ptr [si + 1], '\\' + jne _walk_dir.char_ok + +_walk_dir.get_prev: + + mov cx, offset _file_path + add cx, 3 + + cmp di, cx + je _walk_dir.no_slash2 + + cmp byte ptr es:[di - 1], '\\' + jne _walk_dir.no_slash2 + + mov byte ptr es:[di - 1], 0 + +_walk_dir.no_slash2: + + push si + push ds + + mov ax, cs + mov ds, ax + + mov ax, '\\' + push ax + + mov ax, offset _file_path + push ax + + call _strrchr add sp, 4 - cmp word ptr [bp - 4], 1 - jb _walk_dir.find_first + pop ds + pop si + + and ax, ax + jnz _walk_dir.got_index + + mov di, offset _file_path + jmp _walk_dir.zero + +_walk_dir.got_index: + + mov di, ax + inc di + +_walk_dir.zero: + + mov byte ptr es:[di], 0 + jmp _walk_dir.loop + +_walk_dir.char_ok: + + stosb + jmp _walk_dir.loop + +_walk_dir.check_path: + + ;cmp byte ptr es:[di - 1], '\\' + ;jne _walk_dir.null + ; + ;dec di + +_walk_dir.null: + + xor al, al + stosb _walk_dir.find_first: mov ah, HEX (4E) xor cx, cx + mov dx, offset _file_path int HEX (21) jnc _walk_dir.check5 @@ -274,7 +505,7 @@ _walk_dir.error: _walk_dir.check5: cmp word ptr [bp - 4], 2 - jb _walk_dir.setup + jb _walk_dir.setup mov bx, offset _file_path call _writestr @@ -290,22 +521,20 @@ _walk_dir.setup: mov ax, cs:[_dta_addr] mov ds, ax -_walk_dir.find: +_walk_dir.found: cmp word ptr [bp - 2], 0 je _walk_dir.ok + mov cx, 4 + +_walk_dir.seperate: + mov ah, HEX (02) mov dl, ' ' int HEX (21) - mov ah, HEX (02) - mov dl, ':' - int HEX (21) - - mov ah, HEX (02) - mov dl, ' ' - int HEX (21) + loop _walk_dir.seperate _walk_dir.ok: @@ -333,7 +562,7 @@ _walk_dir.check: _walk_dir.period_check: - cmp byte ptr [si - 1], '.' + cmp byte ptr [si - 2], '.' jne _walk_dir.pad _walk_dir.output: @@ -367,7 +596,7 @@ _walk_dir.final_pad: int HEX (21) dec cx - jmp short _walk_dir.final_pad + jnz _walk_dir.final_pad _walk_dir.check2: @@ -383,7 +612,7 @@ _walk_dir.next: mov ah, HEX (4F) int HEX (21) - jnc _walk_dir.find + jnc _walk_dir.found cmp word ptr [bp - 2], 0 je _walk_dir.check4 diff --git a/src/apps/pcomm/mkdir.asm b/src/apps/pcomm/mkdir.asm index 416d917..2ecc9e9 100644 --- a/src/apps/pcomm/mkdir.asm +++ b/src/apps/pcomm/mkdir.asm @@ -14,7 +14,7 @@ _handler_mkdir: push bp mov bp, sp - sub sp, 4 + sub sp, 6 push ax push bx @@ -25,6 +25,7 @@ _handler_mkdir: push es push ds + mov word ptr [bp - 6], 0 mov word ptr [bp - 4], 0 mov word ptr [bp - 2], 0 @@ -57,7 +58,7 @@ _handler_mkdir.ok: _handler_mkdir.store_arg: cmp byte ptr [bx], 0 - je _handler_mkdir.next + je _handler_mkdir.check2 mov si, bx push si @@ -80,7 +81,7 @@ _handler_mkdir.check: add sp, 4 and ax, ax - jz _handler_mkdir.next + jz _handler_mkdir.check2 mov bx, ax mov byte ptr [bx], 0 @@ -90,7 +91,7 @@ _handler_mkdir.check: _handler_mkdir.skip: cmp byte ptr [bx], 0 - je _handler_mkdir.next + je _handler_mkdir.check2 cmp byte ptr [bx], ' ' ja _handler_mkdir.store_arg @@ -98,15 +99,20 @@ _handler_mkdir.skip: inc bx jmp _handler_mkdir.skip +_handler_mkdir.check2: + + cmp word ptr cs:[_vec_files + 4], 1 + jbe _handler_mkdir.next + _handler_mkdir.next: - mov ax, word ptr [bp - 4] + mov ax, word ptr [bp - 6] inc ax cmp ax, cs:[_vec_files + 4] ja _handler_mkdir.cleanup - mov word ptr [bp - 4], ax + mov word ptr [bp - 6], ax dec ax xor dx, dx @@ -121,29 +127,11 @@ _handler_mkdir.next: mov es, ax mov ax, es:[bx] - mov bx, ax + mov dx, ax pop es - -_handler_mkdir.open: - - mov ah, HEX (39) - mov dx, bx - int HEX (21) - jnc _handler_mkdir.next - -_handler_mkdir.error: - - push bx - - mov bx, offset _err_failed - call _writestr - - pop bx - - call _writestr - call _crlf + call _create_dir jmp _handler_mkdir.next _handler_mkdir.cleanup: @@ -174,16 +162,302 @@ _handler_mkdir.done: pop bx pop ax - add sp, 4 + add sp, 6 pop bp ret +;****************************************************************************** +; @function _create_dir +;****************************************************************************** +_create_dir: + + push ax + push bx + push dx + push ds + push cx + + mov di, offset _file_path + mov cx, 256 + + xor al, al + rep stosb + + mov ah, HEX (19) + int HEX (21) + + mov byte ptr [bp - 4], al + mov si, dx + + push si + + call _strlen + add sp, 2 + + cmp ax, 2 + jb _create_dir.got_drive + + cmp byte ptr [si + 1], ':' + jne _create_dir.got_drive + + mov al, [si] + + cmp al, HEX (7A) + ja _create_dir.no_adjust + + cmp al, HEX (61) + jb _create_dir.no_adjust + + mov bl, HEX (20) + not bl + + sub al, 'a' + + mov byte ptr [bp - 4], al + add si, 2 + + jmp _create_dir.got_drive + +_create_dir.no_adjust: + + cmp al, HEX (5A) + ja _create_dir.got_drive + + cmp al, HEX (41) + jb _create_dir.got_drive + + sub al, 'A' + + mov byte ptr [bp - 4], al + add si, 2 + +_create_dir.got_drive: + + mov di, offset _file_path + + mov al, byte ptr [bp - 4] + add al, 'A' + stosb + + mov al, ':' + stosb + + cmp byte ptr [si], '\\' + je _create_dir.initial_setup + + mov al, '\\' + stosb + + push dx + push si + + mov dl, byte ptr [bp - 4] + mov si, di + + mov ah, HEX (47) + int HEX (21) + + pop si + pop dx + + mov di, offset _file_path + push di + + call _strlen + add sp, 2 + + add di, ax + +_create_dir.initial_setup: + + cmp byte ptr es:[di - 1], '\\' + je _create_dir.no_slash + + mov al, '\\' + stosb + +_create_dir.no_slash: + + mov bx, si + +_create_dir.loop: + + mov ax, si + sub ax, bx + + cmp ax, 65 + ja _create_dir.check_path + + lodsb + + and al, al + jz _create_dir.check_path + + cmp al, '.' + je _create_dir.check_curr + + cmp al, '\\' + jne _create_dir.convert_alpha + + cmp si, bx + je _create_dir.loop + + cmp byte ptr es:[di - 1], '\\' + je _create_dir.loop + +_create_dir.convert_alpha: + + xor ah, ah + push ax + + call _isalpha + + and ax, ax + jz _create_dir.no_alpha + + call _toupper + add sp, 2 + + jmp _create_dir.char_ok2 + +_create_dir.no_alpha: + + pop ax + jmp _create_dir.char_ok2 + +_create_dir.check_curr: + + cmp byte ptr [si], 0 + je _create_dir.loop + + cmp byte ptr [si], '\\' + je _create_dir.loop + + cmp byte ptr [si], '.' + je _create_dir.check_prev + + jmp _create_dir.char_ok2 + +_create_dir.check_prev: + + cmp byte ptr [si + 1], 0 + je _create_dir.get_prev + + cmp byte ptr [si + 1], '\\' + jne _create_dir.char_ok2 + +_create_dir.get_prev: + + mov cx, offset _file_path + add cx, 3 + + cmp di, cx + je _create_dir.no_slash2 + + cmp byte ptr es:[di - 1], '\\' + jne _create_dir.no_slash2 + + mov byte ptr es:[di - 1], 0 + +_create_dir.no_slash2: + + push si + push ds + + mov ax, cs + mov ds, ax + + mov ax, '\\' + push ax + + mov ax, offset _file_path + push ax + + call _strrchr + add sp, 4 + + pop ds + pop si + + and ax, ax + jnz _create_dir.got_index + + mov di, offset _file_path + jmp _create_dir.zero + +_create_dir.got_index: + + mov di, ax + inc di + +_create_dir.zero: + + mov byte ptr es:[di], 0 + jmp _create_dir.loop + +_create_dir.char_ok2: + + stosb + jmp _create_dir.loop + +_create_dir.check_path: + + ;cmp byte ptr es:[di - 1], '\\' + ;jne _create_dir.null + ; + ;dec di + +_create_dir.null: + + xor al, al + stosb + +_create_dir.create: + + mov ah, HEX (39) + mov dx, offset _file_path + int HEX (21) + jnc _create_dir.done + +_create_dir.error: + + mov bx, offset _err_failed + call _writestr + + cmp ax, 3 + jne _create_dir.done + + mov bx, offset _file_path + + call _writestr + call _crlf + + jmp _create_dir.done + +_create_dir.close: + + mov bx, ax + + mov ah, HEX (3E) + int HEX (21) + +_create_dir.done: + + pop cx + pop ds + pop dx + pop bx + pop ax + ret + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data area. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _vec_files: db 6 dup (0) + _cmdline: db 256 dup (0) +_file_path: db 256 dup (0) _err_invalid: db "Invalid number of parameters", HEX (0D), HEX (0A), HEX (00) _err_failed: db "Unable to create directory - ", HEX (00) diff --git a/src/apps/pcomm/rmdir.asm b/src/apps/pcomm/rmdir.asm index bc06adc..4c50cd6 100644 --- a/src/apps/pcomm/rmdir.asm +++ b/src/apps/pcomm/rmdir.asm @@ -1,5 +1,5 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; @file type.asm +;; @file rmdir.asm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %ifndef HEX % define HEX(y) 0x##y @@ -14,7 +14,7 @@ _handler_rmdir: push bp mov bp, sp - sub sp, 4 + sub sp, 6 push ax push bx @@ -25,6 +25,7 @@ _handler_rmdir: push es push ds + mov word ptr [bp - 6], 0 mov word ptr [bp - 4], 0 mov word ptr [bp - 2], 0 @@ -57,7 +58,7 @@ _handler_rmdir.ok: _handler_rmdir.store_arg: cmp byte ptr [bx], 0 - je _handler_rmdir.next + je _handler_rmdir.check2 mov si, bx push si @@ -80,7 +81,7 @@ _handler_rmdir.check: add sp, 4 and ax, ax - jz _handler_rmdir.next + jz _handler_rmdir.check2 mov bx, ax mov byte ptr [bx], 0 @@ -90,7 +91,7 @@ _handler_rmdir.check: _handler_rmdir.skip: cmp byte ptr [bx], 0 - je _handler_rmdir.next + je _handler_rmdir.check2 cmp byte ptr [bx], ' ' ja _handler_rmdir.store_arg @@ -98,15 +99,20 @@ _handler_rmdir.skip: inc bx jmp _handler_rmdir.skip +_handler_rmdir.check2: + + cmp word ptr cs:[_vec_files + 4], 1 + jbe _handler_rmdir.next + _handler_rmdir.next: - mov ax, word ptr [bp - 4] + mov ax, word ptr [bp - 6] inc ax cmp ax, cs:[_vec_files + 4] ja _handler_rmdir.cleanup - mov word ptr [bp - 4], ax + mov word ptr [bp - 6], ax dec ax xor dx, dx @@ -121,99 +127,366 @@ _handler_rmdir.next: mov es, ax mov ax, es:[bx] - mov bx, ax + mov dx, ax pop es + + call _delete_dir + jmp _handler_rmdir.next + +_handler_rmdir.cleanup: + + mov ax, cs:[_vec_files + 0] + push ax + + call _free + add sp, 2 + + mov ax, cs + mov es, ax + + mov di, offset _vec_files + xor al, al + + mov cx, 6 + rep stosb + +_handler_rmdir.done: + + pop ds + pop es + pop di + pop si + pop dx + pop cx + pop bx + pop ax + + add sp, 6 + pop bp + + ret + +;****************************************************************************** +; @function _delete_dir +;****************************************************************************** +_delete_dir: + + push ax + push bx + push dx + push ds + push cx + + mov di, offset _file_path + mov cx, 256 + + xor al, al + rep stosb + + mov ah, HEX (19) + int HEX (21) + + mov byte ptr [bp - 4], al + mov si, dx + + push si + + call _strlen + add sp, 2 + + cmp ax, 2 + jb _delete_dir.got_drive + + cmp byte ptr [si + 1], ':' + jne _delete_dir.got_drive + + mov al, [si] + + cmp al, HEX (7A) + ja _delete_dir.no_adjust + + cmp al, HEX (61) + jb _delete_dir.no_adjust + + mov bl, HEX (20) + not bl + + sub al, 'a' + + mov byte ptr [bp - 4], al + add si, 2 + + jmp _delete_dir.got_drive + +_delete_dir.no_adjust: + + cmp al, HEX (5A) + ja _delete_dir.got_drive + + cmp al, HEX (41) + jb _delete_dir.got_drive + + sub al, 'A' + + mov byte ptr [bp - 4], al + add si, 2 + +_delete_dir.got_drive: + + mov di, offset _file_path + + mov al, byte ptr [bp - 4] + add al, 'A' + stosb + + mov al, ':' + stosb + + cmp byte ptr [si], '\\' + je _delete_dir.initial_setup + + mov al, '\\' + stosb + + push dx + push si + + mov dl, byte ptr [bp - 4] + mov si, di + + mov ah, HEX (47) + int HEX (21) + + pop si + pop dx + + mov di, offset _file_path + push di + + call _strlen + add sp, 2 + + add di, ax + +_delete_dir.initial_setup: + + cmp byte ptr es:[di - 1], '\\' + je _delete_dir.no_slash + + mov al, '\\' + stosb + +_delete_dir.no_slash: + + mov bx, si + +_delete_dir.loop: + + mov ax, si + sub ax, bx + + cmp ax, 65 + ja _delete_dir.check_path + + lodsb + + and al, al + jz _delete_dir.check_path + + cmp al, '.' + je _delete_dir.check_curr + + cmp al, '\\' + jne _delete_dir.convert_alpha + + cmp si, bx + je _delete_dir.loop + + cmp byte ptr es:[di - 1], '\\' + je _delete_dir.loop + +_delete_dir.convert_alpha: + + xor ah, ah + push ax + + call _isalpha + + and ax, ax + jz _delete_dir.no_alpha + + call _toupper + add sp, 2 + + jmp _delete_dir.char_ok2 + +_delete_dir.no_alpha: + + pop ax + jmp _delete_dir.char_ok2 + +_delete_dir.check_curr: -_handler_rmdir.delete: + cmp byte ptr [si], 0 + je _delete_dir.loop + + cmp byte ptr [si], '\\' + je _delete_dir.loop + + cmp byte ptr [si], '.' + je _delete_dir.check_prev + + jmp _delete_dir.char_ok2 + +_delete_dir.check_prev: + + cmp byte ptr [si + 1], 0 + je _delete_dir.get_prev + + cmp byte ptr [si + 1], '\\' + jne _delete_dir.char_ok2 + +_delete_dir.get_prev: + + mov cx, offset _file_path + add cx, 3 + + cmp di, cx + je _delete_dir.no_slash2 + + cmp byte ptr es:[di - 1], '\\' + jne _delete_dir.no_slash2 + + mov byte ptr es:[di - 1], 0 + +_delete_dir.no_slash2: + + push si + push ds + + mov ax, cs + mov ds, ax + + mov ax, '\\' + push ax + + mov ax, offset _file_path + push ax + + call _strrchr + add sp, 4 + + pop ds + pop si + + and ax, ax + jnz _delete_dir.got_index + + mov di, offset _file_path + jmp _delete_dir.zero + +_delete_dir.got_index: + + mov di, ax + inc di + +_delete_dir.zero: + + mov byte ptr es:[di], 0 + jmp _delete_dir.loop + +_delete_dir.char_ok2: + + stosb + jmp _delete_dir.loop + +_delete_dir.check_path: + + cmp byte ptr es:[di - 1], '\\' + jne _delete_dir.null + + dec di + +_delete_dir.null: + + xor al, al + stosb + +_delete_dir.delete: mov ah, HEX (3A) - mov dx, bx + mov dx, offset _file_path int HEX (21) - jnc _handler_rmdir.next + jnc _delete_dir.close - mov cx, bx + mov cx, offset _file_path cmp ax, 3 - jne _handler_rmdir.check3 + jne _delete_dir.check mov bx, offset _err_failed - jmp _handler_rmdir.error - -_handler_rmdir.check3: + jmp _delete_dir.check2 +_delete_dir.check: + cmp ax, 16 - jne _handler_rmdir.unhandled + jne _delete_dir.unhandled mov bx, offset _err_current - jmp _handler_rmdir.error + jmp _delete_dir.check2 -_handler_rmdir.unhandled: +_delete_dir.unhandled: mov bx, offset _err_unhandled -_handler_rmdir.error: +_delete_dir.check2: cmp ax, 3 - jne _handler_rmdir.error2 + jne _delete_dir.error xchg bx, cx call _writestr xchg bx, cx -_handler_rmdir.error2: +_delete_dir.error: call _writestr cmp ax, 16 - jne _handler_rmdir.next + jne _delete_dir.done mov bx, cx call _writestr call _crlf - jmp _handler_rmdir.next + jmp _delete_dir.done -_handler_rmdir.cleanup: +_delete_dir.close: - mov ax, cs:[_vec_files + 0] - push ax - - call _free - add sp, 2 - - mov ax, cs - mov es, ax - - mov di, offset _vec_files - xor al, al + mov bx, ax - mov cx, 6 - rep stosb + mov ah, HEX (3E) + int HEX (21) -_handler_rmdir.done: +_delete_dir.done: + pop cx pop ds - pop es - pop di - pop si pop dx - pop cx pop bx pop ax - - add sp, 4 - pop bp - ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data area. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _vec_files: db 6 dup (0) + _cmdline: db 256 dup (0) +_file_path: db 256 dup (0) _err_invalid: db "Invalid number of parameters", HEX (0D), HEX (0A), HEX (00) diff --git a/src/apps/pcomm/touch.asm b/src/apps/pcomm/touch.asm index ca254e9..2f8c2b4 100644 --- a/src/apps/pcomm/touch.asm +++ b/src/apps/pcomm/touch.asm @@ -14,7 +14,7 @@ _handler_touch: push bp mov bp, sp - sub sp, 4 + sub sp, 6 push ax push bx @@ -25,6 +25,7 @@ _handler_touch: push es push ds + mov word ptr [bp - 6], 0 mov word ptr [bp - 4], 0 mov word ptr [bp - 2], 0 @@ -57,7 +58,7 @@ _handler_touch.ok: _handler_touch.store_arg: cmp byte ptr [bx], 0 - je _handler_touch.next + je _handler_touch.check2 mov si, bx push si @@ -80,7 +81,7 @@ _handler_touch.check: add sp, 4 and ax, ax - jz _handler_touch.next + jz _handler_touch.check2 mov bx, ax mov byte ptr [bx], 0 @@ -90,7 +91,7 @@ _handler_touch.check: _handler_touch.skip: cmp byte ptr [bx], 0 - je _handler_touch.next + je _handler_touch.check2 cmp byte ptr [bx], ' ' ja _handler_touch.store_arg @@ -98,15 +99,20 @@ _handler_touch.skip: inc bx jmp _handler_touch.skip +_handler_touch.check2: + + cmp word ptr cs:[_vec_files + 4], 1 + jbe _handler_touch.next + _handler_touch.next: - mov ax, word ptr [bp - 4] + mov ax, word ptr [bp - 6] inc ax cmp ax, cs:[_vec_files + 4] ja _handler_touch.cleanup - mov word ptr [bp - 4], ax + mov word ptr [bp - 6], ax dec ax xor dx, dx @@ -121,100 +127,354 @@ _handler_touch.next: mov es, ax mov ax, es:[bx] - mov bx, ax + mov dx, ax pop es + + call _create_file + jmp _handler_touch.next + +_handler_touch.cleanup: + + mov ax, cs:[_vec_files + 0] + push ax + + call _free + add sp, 2 + + mov ax, cs + mov es, ax + + mov di, offset _vec_files + xor al, al + + mov cx, 6 + rep stosb + +_handler_touch.done: + + pop ds + pop es + pop di + pop si + pop dx + pop cx + pop bx + pop ax + + add sp, 6 + pop bp + + ret -_handler_touch.open: +;****************************************************************************** +; @function _create_file +;****************************************************************************** +_create_file: + push ax push bx + push dx + push ds + push cx + + mov di, offset _file_path + mov cx, 256 + + xor al, al + rep stosb + + mov ah, HEX (19) + int HEX (21) + + mov byte ptr [bp - 4], al + mov si, dx + push si + + call _strlen + add sp, 2 + + cmp ax, 2 + jb _create_file.got_drive + + cmp byte ptr [si + 1], ':' + jne _create_file.got_drive + + mov al, [si] + + cmp al, HEX (7A) + ja _create_file.no_adjust + + cmp al, HEX (61) + jb _create_file.no_adjust + + mov bl, HEX (20) + not bl + + sub al, 'a' + + mov byte ptr [bp - 4], al + add si, 2 + + jmp _create_file.got_drive + +_create_file.no_adjust: + + cmp al, HEX (5A) + ja _create_file.got_drive + + cmp al, HEX (41) + jb _create_file.got_drive + + sub al, 'A' + + mov byte ptr [bp - 4], al + add si, 2 + +_create_file.got_drive: + + mov di, offset _file_path + + mov al, byte ptr [bp - 4] + add al, 'A' + stosb + + mov al, ':' + stosb + + cmp byte ptr [si], '\\' + je _create_file.initial_setup + + mov al, '\\' + stosb + + push dx + push si + + mov dl, byte ptr [bp - 4] + mov si, di + + mov ah, HEX (47) + int HEX (21) + + pop si + pop dx + + mov di, offset _file_path + push di + + call _strlen + add sp, 2 + + add di, ax + +_create_file.initial_setup: + + cmp byte ptr es:[di - 1], '\\' + je _create_file.no_slash + + mov al, '\\' + stosb + +_create_file.no_slash: + + mov bx, si + +_create_file.loop: + + mov ax, si + sub ax, bx + + cmp ax, 65 + ja _create_file.check_path + + lodsb + + and al, al + jz _create_file.check_path + + cmp al, '.' + je _create_file.check_curr + + cmp al, '\\' + jne _create_file.convert_alpha + + cmp si, bx + je _create_file.loop + + cmp byte ptr es:[di - 1], '\\' + je _create_file.loop + +_create_file.convert_alpha: + + xor ah, ah + push ax + + call _isalpha + + and ax, ax + jz _create_file.no_alpha + + call _toupper + add sp, 2 + + jmp _create_file.char_ok2 + +_create_file.no_alpha: + + pop ax + jmp _create_file.char_ok2 + +_create_file.check_curr: + + cmp byte ptr [si], 0 + je _create_file.loop + + cmp byte ptr [si], '\\' + je _create_file.loop + + cmp byte ptr [si], '.' + je _create_file.check_prev + + jmp _create_file.char_ok2 + +_create_file.check_prev: + + cmp byte ptr [si + 1], 0 + je _create_file.get_prev + + cmp byte ptr [si + 1], '\\' + jne _create_file.char_ok2 + +_create_file.get_prev: + + mov cx, offset _file_path + add cx, 3 + + cmp di, cx + je _create_file.no_slash2 + + cmp byte ptr es:[di - 1], '\\' + jne _create_file.no_slash2 + + mov byte ptr es:[di - 1], 0 + +_create_file.no_slash2: + + push si + push ds + + mov ax, cs + mov ds, ax + + mov ax, '\\' + push ax + + mov ax, offset _file_path + push ax + + call _strrchr + add sp, 4 + + pop ds + pop si + + and ax, ax + jnz _create_file.got_index + + mov di, offset _file_path + jmp _create_file.zero + +_create_file.got_index: + + mov di, ax + inc di + +_create_file.zero: + + mov byte ptr es:[di], 0 + jmp _create_file.loop + +_create_file.char_ok2: + + stosb + jmp _create_file.loop + +_create_file.check_path: + + ;cmp byte ptr es:[di - 1], '\\' + ;jne _create_file.null + ; + ;dec di + +_create_file.null: + + xor al, al + stosb + +_create_file.open: + mov ax, HEX (3D02) - mov dx, bx + mov dx, offset _file_path int HEX (21) - jnc _handler_touch.close + jnc _create_file.close mov ah, HEX (3C) mov cx, HEX (20) - mov dx, bx + mov dx, offset _file_path int HEX (21) - jnc _handler_touch.close + jnc _create_file.close cmp ax, 3 - jne _handler_touch.unhandled + jne _create_file.unhandled mov bx, offset _err_no_path - jmp _handler_touch.error + jmp _create_file.error -_handler_touch.unhandled: +_create_file.unhandled: - pop bx mov bx, offset _err_unhandled -_handler_touch.error: +_create_file.error: call _writestr cmp ax, 3 - jne _handler_touch.next + jne _create_file.done - pop bx + mov bx, offset _file_path call _writestr call _crlf - jmp _handler_touch.next + jmp _create_file.done -_handler_touch.close: +_create_file.close: - pop bx mov bx, ax mov ah, HEX (3E) int HEX (21) - - jmp _handler_touch.next -_handler_touch.cleanup: - - mov ax, cs:[_vec_files + 0] - push ax - - call _free - add sp, 2 - - mov ax, cs - mov es, ax - - mov di, offset _vec_files - xor al, al - - mov cx, 6 - rep stosb - -_handler_touch.done: +_create_file.done: + pop cx pop ds - pop es - pop di - pop si pop dx - pop cx pop bx pop ax - - add sp, 4 - pop bp - ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data area. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _vec_files: db 6 dup (0) + _cmdline: db 256 dup (0) +_file_path: db 256 dup (0) _err_invalid: db "Invalid number of parameters", HEX (0D), HEX (0A), HEX (00) -_err_no_path: db "Path not found: ", HEX (00) +_err_no_path: db "Path not found: ", HEX (00) _err_unhandled: db "Unhandled error code", HEX (0D), HEX (0A), HEX (00) diff --git a/src/apps/pcomm/type.asm b/src/apps/pcomm/type.asm index da8d569..95c126a 100644 --- a/src/apps/pcomm/type.asm +++ b/src/apps/pcomm/type.asm @@ -14,7 +14,7 @@ _handler_type: push bp mov bp, sp - sub sp, 4 + sub sp, 6 push ax push bx @@ -25,6 +25,7 @@ _handler_type: push es push ds + mov word ptr [bp - 6], 0 mov word ptr [bp - 4], 0 mov word ptr [bp - 2], 0 @@ -57,7 +58,7 @@ _handler_type.ok: _handler_type.store_arg: cmp byte ptr [bx], 0 - je _handler_type.next + je _handler_type.check2 mov si, bx push si @@ -80,7 +81,7 @@ _handler_type.check: add sp, 4 and ax, ax - jz _handler_type.next + jz _handler_type.check2 mov bx, ax mov byte ptr [bx], 0 @@ -90,7 +91,7 @@ _handler_type.check: _handler_type.skip: cmp byte ptr [bx], 0 - je _handler_type.next + je _handler_type.check2 cmp byte ptr [bx], ' ' ja _handler_type.store_arg @@ -98,15 +99,20 @@ _handler_type.skip: inc bx jmp _handler_type.skip +_handler_type.check2: + + cmp word ptr cs:[_vec_files + 4], 1 + jbe _handler_type.next + _handler_type.next: - mov ax, word ptr [bp - 4] + mov ax, word ptr [bp - 6] inc ax cmp ax, cs:[_vec_files + 4] ja _handler_type.cleanup - mov word ptr [bp - 4], ax + mov word ptr [bp - 6], ax dec ax xor dx, dx @@ -121,80 +127,358 @@ _handler_type.next: mov es, ax mov ax, es:[bx] - mov bx, ax + mov dx, ax pop es + + call _read_file + jmp _handler_type.next + +_handler_type.cleanup: + + mov ax, cs:[_vec_files + 0] + push ax + + call _free + add sp, 2 + + mov ax, cs + mov es, ax + + mov di, offset _vec_files + xor al, al + + mov cx, 6 + rep stosb -_handler_type.open: +_handler_type.done: + pop ds + pop es + pop di + pop si + pop dx + pop cx + pop bx + pop ax + + add sp, 6 + pop bp + + ret + +;****************************************************************************** +; @function _read_file +;****************************************************************************** +_read_file: + + push ax push bx + push dx + push ds + push cx + + mov di, offset _file_path + mov cx, 256 + + xor al, al + rep stosb + + mov ah, HEX (19) + int HEX (21) + + mov byte ptr [bp - 4], al + mov si, dx + push si + + call _strlen + add sp, 2 + + cmp ax, 2 + jb _read_file.got_drive + + cmp byte ptr [si + 1], ':' + jne _read_file.got_drive + + mov al, [si] + + cmp al, HEX (7A) + ja _read_file.no_adjust + + cmp al, HEX (61) + jb _read_file.no_adjust + + mov bl, HEX (20) + not bl + + sub al, 'a' + + mov byte ptr [bp - 4], al + add si, 2 + + jmp _read_file.got_drive + +_read_file.no_adjust: + + cmp al, HEX (5A) + ja _read_file.got_drive + + cmp al, HEX (41) + jb _read_file.got_drive + + sub al, 'A' + + mov byte ptr [bp - 4], al + add si, 2 + +_read_file.got_drive: + + mov di, offset _file_path + + mov al, byte ptr [bp - 4] + add al, 'A' + stosb + + mov al, ':' + stosb + + cmp byte ptr [si], '\\' + je _read_file.initial_setup + + mov al, '\\' + stosb + + push dx + push si + + mov dl, byte ptr [bp - 4] + mov si, di + + mov ah, HEX (47) + int HEX (21) + + pop si + pop dx + + mov di, offset _file_path + push di + + call _strlen + add sp, 2 + + add di, ax + +_read_file.initial_setup: + + cmp byte ptr es:[di - 1], '\\' + je _read_file.no_slash + + mov al, '\\' + stosb + +_read_file.no_slash: + + mov bx, si + +_read_file.loop: + + mov ax, si + sub ax, bx + + cmp ax, 65 + ja _read_file.check_path + + lodsb + + and al, al + jz _read_file.check_path + + cmp al, '.' + je _read_file.check_curr + + cmp al, '\\' + jne _read_file.convert_alpha + + cmp si, bx + je _read_file.loop + + cmp byte ptr es:[di - 1], '\\' + je _read_file.loop + +_read_file.convert_alpha: + + xor ah, ah + push ax + + call _isalpha + + and ax, ax + jz _read_file.no_alpha + + call _toupper + add sp, 2 + + jmp _read_file.char_ok2 + +_read_file.no_alpha: + + pop ax + jmp _read_file.char_ok2 + +_read_file.check_curr: + + cmp byte ptr [si], 0 + je _read_file.loop + + cmp byte ptr [si], '\\' + je _read_file.loop + + cmp byte ptr [si], '.' + je _read_file.check_prev + + jmp _read_file.char_ok2 + +_read_file.check_prev: + + cmp byte ptr [si + 1], 0 + je _read_file.get_prev + + cmp byte ptr [si + 1], '\\' + jne _read_file.char_ok2 + +_read_file.get_prev: + + mov cx, offset _file_path + add cx, 3 + + cmp di, cx + je _read_file.no_slash2 + + cmp byte ptr es:[di - 1], '\\' + jne _read_file.no_slash2 + + mov byte ptr es:[di - 1], 0 + +_read_file.no_slash2: + + push si + push ds + + mov ax, cs + mov ds, ax + + mov ax, '\\' + push ax + + mov ax, offset _file_path + push ax + + call _strrchr + add sp, 4 + + pop ds + pop si + + and ax, ax + jnz _read_file.got_index + + mov di, offset _file_path + jmp _read_file.zero + +_read_file.got_index: + + mov di, ax + inc di + +_read_file.zero: + + mov byte ptr es:[di], 0 + jmp _read_file.loop + +_read_file.char_ok2: + + stosb + jmp _read_file.loop + +_read_file.check_path: + + ;cmp byte ptr es:[di - 1], '\\' + ;jne _read_file.null + ; + ;dec di + +_read_file.null: + + xor al, al + stosb + +_read_file.open: + mov ax, HEX (3D02) - mov dx, bx + mov dx, offset _file_path int HEX (21) - jnc _handler_type.file_open + jnc _read_file.file_open cmp ax, 2 - jne _handler_type.check3 + jne _read_file.check3 mov bx, offset _err_no_file - jmp _handler_type.error + jmp _read_file.error -_handler_type.check3: +_read_file.check3: cmp ax, 3 - jne _handler_type.unhandled + jne _read_file.unhandled mov bx, offset _err_no_dir - jmp _handler_type.error + jmp _read_file.error -_handler_type.unhandled: +_read_file.unhandled: - pop bx mov bx, offset _err_unhandled -_handler_type.error: +_read_file.error: call _writestr cmp ax, 3 - ja _handler_type.cleanup + ja _read_file.done cmp ax, 2 - jb _handler_type.cleanup + jb _read_file.done - pop bx + mov bx, offset _file_path call _writestr call _crlf - jmp _handler_type.cleanup + jmp _read_file.done -_handler_type.file_open: +_read_file.file_open: - pop bx mov bx, ax -_handler_type.clear_and_read: +_read_file.clear_and_read: mov ah, HEX (3F) mov cx, 255 mov dx, offset _buffer int HEX (21) - jc _handler_type.close + jc _read_file.close and ax, ax - jz _handler_type.close + jz _read_file.close mov si, dx mov cx, ax -_handler_type.print_loop: +_read_file.print_loop: lodsb cmp al, HEX (0A) - jne _handler_type.char_ok + jne _read_file.char_ok push ax @@ -204,66 +488,41 @@ _handler_type.print_loop: pop ax -_handler_type.char_ok: +_read_file.char_ok: mov ah, HEX (02) mov dl, al int HEX (21) dec cx - jnz _handler_type.print_loop + jnz _read_file.print_loop -_handler_type.read_done: +_read_file.read_done: - jmp _handler_type.clear_and_read + jmp _read_file.clear_and_read -_handler_type.close: +_read_file.close: mov ah, HEX (3E) int HEX (21) - - jmp _handler_type.next - -_handler_type.cleanup: - - mov ax, cs:[_vec_files + 0] - push ax - - call _free - add sp, 2 - - mov ax, cs - mov es, ax - - mov di, offset _vec_files - xor al, al - - mov cx, 6 - rep stosb -_handler_type.done: +_read_file.done: + pop cx pop ds - pop es - pop di - pop si pop dx - pop cx pop bx pop ax - - add sp, 4 - pop bp - ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data area. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _vec_files: db 6 dup (0) - _cmdline: db 256 dup (0) -_buffer: db 256 dup (0) + +_file_path: db 256 dup (0) +_buffer: dw 256 dup (0) _err_invalid: db "Invalid number of parameters", HEX (0D), HEX (0A), HEX (00) diff --git a/src/apps/pcomm/xstrcpy.asm b/src/apps/pcomm/xstrcpy.asm index cbe9400..4812b53 100644 --- a/src/apps/pcomm/xstrcpy.asm +++ b/src/apps/pcomm/xstrcpy.asm @@ -19,14 +19,14 @@ _xstrcpy: push si push di - mov si, [bp + 6] - mov di, [bp + 4] + mov si, word ptr [bp + 6] + mov di, word ptr [bp + 4] _xstrcpy.loop: lodsb - or al, al + and al, al jz _xstrcpy.done cmp al, HEX (7A) diff --git a/src/kernel/file.asm b/src/kernel/file.asm index 92957e2..091aef0 100644 --- a/src/kernel/file.asm +++ b/src/kernel/file.asm @@ -566,6 +566,8 @@ _open_file.found_dir: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; test cl, HEX (18) jz _open_file.got_file + + jmp _open_file.error _open_file.name_error: @@ -1162,7 +1164,7 @@ _write_file: push bp mov bp, sp - sub sp, 16 + sub sp, 26 push bx push cx @@ -1187,49 +1189,66 @@ _write_file: ;; If theres zero byte to write then truncate/extend. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; and cx, cx - jz _write_file.zero + jz .L5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; For now we'll jump to error + ;; Check if the file needs expaning. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - jmp _write_file.error - -_write_file.zero: - - mov ax, es:[si + 66] - mov dx, es:[si + 68] + mov word ptr [bp - 22], dx + mov word ptr [bp - 20], cx - cmp dx, es:[si + 64] - ja _write_file.truncate + mov ax, es:[si + 62] + mov dx, es:[si + 64] - cmp dx, es:[si + 64] - jne _write_file.extend + cmp dx, es:[si + 68] + ja .L20 - cmp ax, es:[si + 62] - jb _write_file.extend + cmp dx, es:[si + 68] + jne .L19 + + cmp ax, es:[si + 66] + jbe .L19 -_write_file.truncate: +.L20: - mov bx, es:[si + 58] - or bx, es:[si + 60] + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Make sure the disk buffer is cleared. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + push es + push di + push ax - and bx, bx - jz _write_file.done + mov cx, es:[si + 50] + xor di, di + + mov ax, cs:[_disk_scratch] + mov es, ax + + xor al, al + rep stosb + + pop ax + pop di + pop es + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Now we need to figure out how many clusters are in use and how many + ;; are in total. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov cx, es:[si + 50] div cx mov bx, ax and dx, dx - jz .L3 + jz .L21 inc bx -.L3: +.L21: - mov ax, es:[si + 62] - mov dx, es:[si + 64] + mov ax, es:[si + 66] + mov dx, es:[si + 68] mov cx, es:[si + 50] div cx @@ -1237,122 +1256,116 @@ _write_file.truncate: mov cx, ax and dx, dx - jz .L3 + jz .L22 inc cx -.L4: +.L22: + mov word ptr [bp - 12], bx xchg bx, cx + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Check if we have a starting cluster. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov ax, es:[si + 58] mov dx, es:[si + 60] - -_write_file.truncate_walk: - - mov word ptr [bp - 6], ax - mov word ptr [bp - 4], dx - - and bx, bx - jz _write_file.truncate_ok - - dec cx - - call cs:[_next_cluster] - jc _write_file.truncate_ok - - dec bx - jnz _write_file.truncate_walk - -_write_file.truncate_ok: - - mov ax, word ptr [bp - 6] - mov dx, word ptr [bp - 4] - - mov word ptr [bp - 16], ax - mov word ptr [bp - 14], dx - - mov word ptr [bp - 12], cx - -_write_file.truncate_loop: - - and cx, cx - jz _write_file.truncate_done - call cs:[_next_cluster] - jc _write_file.truncate_done - - push si - push di + mov di, ax + or di, dx - mov si, ax - mov di, dx + and di, di + jnz .L27 - mov ax, word ptr [bp - 6] - mov dx, word ptr [bp - 4] + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Try find a new cluster. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + call cs:[_find_free] + jc _write_file.done - mov word ptr [bp - 6], si - mov word ptr [bp - 4], di + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx - pop di - pop si + dec cx push bx push cx - xor bx, bx - xor cx, cx - + mov bx, HEX (FFFF) + mov cx, HEX (FFF8) call cs:[_update_cluster] pop cx pop bx - mov ax, word ptr [bp - 6] - mov dx, word ptr [bp - 4] + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the file info. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov es:[si + 58], ax + mov es:[si + 60], dx - dec cx - jnz _write_file.truncate_loop - -_write_file.truncate_done: - - mov ax, word ptr [bp - 6] - mov dx, word ptr [bp - 4] + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the sector on disk. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + push bx + push cx + call cs:[_convert_cluster] + + pop cx + pop bx + jc _write_file.done + push es push bx push cx - xor bx, bx - xor cx, cx + xor ch, ch + mov cl, cs:[_sectors_per_cluster] - call cs:[_update_cluster] + mov bx, cs:[_disk_scratch] + mov es, bx + + xor bx, bx + call _write_sectors pop cx pop bx + pop es - xor ax, ax - xor dx, dx - - mov bx, es:[si + 62] - or bx, es:[si + 64] + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Jump straight to writing the sectors. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + jmp .L26 + +.L27: + + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx and bx, bx - jz _write_file.truncate_update + jz .L26 - mov cx, word ptr [bp - 12] + call cs:[_next_cluster] + jc .L26 - cmp cx, 2 - jb _write_file.truncate_expand_done + dec word ptr [bp - 12] + dec cx - sub cx, 2 + dec bx + jnz .L27 -_write_file.truncate_expand: +.L26: + + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] + +.L28: and cx, cx - jz _write_file.truncate_expand_done + jz .L29 call cs:[_find_free] - jc _write_file.truncate_expand_done + jc _write_file.done push bx push cx @@ -1360,44 +1373,97 @@ _write_file.truncate_expand: mov bx, dx mov cx, ax - mov ax, word ptr [bp - 16] - mov dx, word ptr [bp - 14] + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] call cs:[_update_cluster] - mov word ptr [bp - 16], cx - mov word ptr [bp - 14], bx + push bx + push cx + call cs:[_convert_cluster] + + pop cx + pop bx + jc .L29 + + push es + push bx + push cx + + xor ch, ch + mov cl, cs:[_sectors_per_cluster] + + mov bx, cs:[_disk_scratch] + mov es, bx + + xor bx, bx + call _write_sectors + + pop cx + pop bx + pop es + + mov ax, cx + mov dx, bx + + mov bx, HEX (FFFF) + mov cx, HEX (FFF8) + call cs:[_update_cluster] pop cx pop bx + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx + dec cx - jnz _write_file.truncate_expand + jnz .L28 -_write_file.truncate_expand_done: +.L29: + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Preserve registers. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + push es push bx push cx + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Mark the current cluster as EOF. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov bx, HEX (FFFF) mov cx, HEX (FFF8) - mov ax, word ptr [bp - 16] - mov dx, word ptr [bp - 14] + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] call cs:[_update_cluster] + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the sector on disk. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + call cs:[_convert_cluster] + jc _write_file.done + + xor ch, ch + mov cl, cs:[_sectors_per_cluster] + + mov bx, cs:[_disk_scratch] + mov es, bx + + xor bx, bx + call _write_sectors + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Restore registers. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pop cx pop bx + pop es - mov ax, es:[si + 58] - mov dx, es:[si + 60] - -_write_file.truncate_update: - - mov es:[si + 58], ax - mov es:[si + 60], dx - + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the stack variables. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov ax, es:[si + 58] mov word ptr [bp - 6], ax @@ -1462,11 +1528,15 @@ _write_file.truncate_update: mov ax, cs:[_info_sector] and ax, ax - jz _write_file.done + jz .L19 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Update the free clusters. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + push es + push bx + push cx + xor dx, dx add ax, cs:[_hidden_sectors] @@ -1484,8 +1554,8 @@ _write_file.truncate_update: mov ax, es:[di + 8] mov dx, es:[di + 10] - add ax, word ptr [bp - 12] - adc dx, 0 + sub ax, word ptr [bp - 12] + sbb dx, 0 mov es:[di + 8], ax mov es:[di + 10], dx @@ -1499,34 +1569,781 @@ _write_file.truncate_update: mov cx, 1 call _write_sectors - jmp _write_file.done + pop cx + pop bx + pop es -_write_file.extend: +.L19: - push es - push di - push ax - - xor cx, es:[si + 50] - - mov ax, cs:[_disk_scratch] - mov es, ax - xor di, di - - xor al, al - rep stosb + mov word ptr [bp - 12], 0 + mov word ptr [bp - 2], 0 - pop ax - pop di - pop es + mov ax, es:[si + 62] + mov dx, es:[si + 64] mov cx, es:[si + 50] div cx - mov bx, ax - and dx, dx - jz .L2 + jz .L30 + + inc ax + +.L30: + + mov word ptr [bp - 26], ax + + mov ax, es:[si + 66] + mov dx, es:[si + 68] + + mov cx, es:[si + 50] + div cx + + and dx, dx + jz .L31 + + inc ax + +.L31: + + mov word ptr [bp - 24], ax + +.L32: + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Make sure the disk buffer is cleared. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + push es + push di + push ax + + mov cx, es:[si + 50] + xor di, di + + mov ax, cs:[_disk_scratch] + mov es, ax + + xor al, al + rep stosb + + pop ax + pop di + pop es + +.L34: + + mov cx, word ptr [bp - 20] + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; If we don't have any data left then we're done. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + and cx, cx + jz .L42 + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Figure out what cluster we need to write to. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov ax, es:[si + 62] + mov dx, es:[si + 64] + + mov cx, es:[si + 50] + div cx + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Copy the value in the dx register (offset into the cluster) into + ;; the di register. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov di, dx + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Calaculate how many bytes need to be write. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov cx, es:[si + 50] + sub cx, di + + cmp cx, word ptr [bp - 20] + jb .L35 + + mov cx, word ptr [bp - 20] + +.L35: + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Are we writing to an existing cluster or a new one? + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + cmp ax, word ptr [bp - 24] + jae .L36 + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Copy the cluster count to the bx register. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov bx, ax + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Get the starting cluster. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov ax, es:[si + 58] + mov dx, es:[si + 60] + +.L37: + + and bx, bx + jz .L38 + + call cs:[_next_cluster] + jc .L42 + + dec bx + jnz .L37 + +.L38: + + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx + + push si + push es + push ds + push cx + + push bx + push cx + call cs:[_convert_cluster] + + pop cx + pop bx + jc .L43 + + push ax + push dx + push si + push di + push cx + + mov bx, es:[si + 70] + mov es, bx + + xor ch, ch + mov cl, cs:[_sectors_per_cluster] + + xor bx, bx + call _read_sectors + + pop cx + push cx + + mov si, word ptr [bp - 22] + rep movsb + + pop cx + pop di + pop si + pop dx + pop ax + + sub word ptr [bp - 20], cx + add word ptr [bp - 2], cx + add word ptr [bp - 22], cx + + xor ch, ch + mov cl, cs:[_sectors_per_cluster] + + xor bx, bx + call _write_sectors + + pop cx + pop ds + pop es + pop si + + add es:[si + 62], cx + adc word ptr es:[si + 64], 0 + + jmp .L34 + +.L36: + + mov ax, es:[si + 58] + mov dx, es:[si + 60] + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Do we have a starting cluster? + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov bx, ax + or bx, dx + + and bx, bx + jnz .L39 + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Try find a new cluster. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + call cs:[_find_free] + jc .L42 + + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx + + push bx + push cx + + mov bx, HEX (FFFF) + mov cx, HEX (FFF8) + call cs:[_update_cluster] + + pop cx + pop bx + + inc word ptr [bp - 12] + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the file info. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov es:[si + 58], ax + mov es:[si + 60], dx + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the sector on disk. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + push bx + push cx + call cs:[_convert_cluster] + + pop cx + pop bx + jc _write_file.done + + push es + push bx + push cx + + xor ch, ch + mov cl, cs:[_sectors_per_cluster] + + mov bx, cs:[_disk_scratch] + mov es, bx + + xor bx, bx + call _write_sectors + + pop cx + pop bx + pop es + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Jump straight to writing the sectors. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + jmp .L40 + +.L39: + + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx + + call cs:[_next_cluster] + jc .L41 + + jmp .L39 + +.L41: + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Try find a new cluster. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + call cs:[_find_free] + jc .L42 + + push bx + push cx + push ax + push dx + + mov bx, dx + mov cx, ax + + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] + call cs:[_update_cluster] + + pop dx + pop ax + pop cx + pop bx + + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx + + push bx + push cx + + mov bx, HEX (FFFF) + mov cx, HEX (FFF8) + call cs:[_update_cluster] + + pop cx + pop bx + + inc word ptr [bp - 12] + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the sector on disk. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + push bx + push cx + call cs:[_convert_cluster] + + pop cx + pop bx + jc _write_file.done + + push es + push bx + push cx + + xor ch, ch + mov cl, cs:[_sectors_per_cluster] + + mov bx, cs:[_disk_scratch] + mov es, bx + + xor bx, bx + call _write_sectors + + pop cx + pop bx + pop es + +.L40: + + push si + push es + push ds + push cx + + push ax + push di + push cx + + mov ax, es:[si + 70] + mov cx, es:[si + 50] + + mov es, ax + + xor al, al + rep stosb + + pop cx + pop di + pop ax + + push si + push di + push cx + + mov si, word ptr [bp - 22] + rep movsb + + pop cx + pop di + pop si + + push cx + push bx + + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] + call cs:[_convert_cluster] + + pop bx + pop cx + jc .L43 + + sub word ptr [bp - 20], cx + add word ptr [bp - 2], cx + add word ptr [bp - 22], cx + + xor ch, ch + mov cl, cs:[_sectors_per_cluster] + + xor bx, bx + call _write_sectors + + pop cx + pop ds + pop es + pop si + + add es:[si + 62], cx + adc word ptr es:[si + 64], 0 + + jmp .L34 + +.L43: + + pop cx + pop ds + pop es + pop si + +.L42: + + mov ax, es:[si + 62] + mov dx, es:[si + 64] + + cmp dx, es:[si + 68] + ja .L44 + + cmp dx, es:[si + 68] + jne .L45 + + cmp ax, es:[si + 66] + jb .L45 + +.L44: + + mov ax, es:[si + 62] + mov dx, es:[si + 64] + + mov es:[si + 66], ax + mov es:[si + 68], dx + +.L45: + + mov ax, es:[si + 66] + mov word ptr [bp - 10], ax + + mov ax, es:[si + 68] + mov word ptr [bp - 8], ax + + mov ax, es:[si + 58] + mov word ptr [bp - 6], ax + + mov ax, es:[si + 60] + mov word ptr [bp - 4], ax + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the entry on disk. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov ax, es:[si + 74] + mov dx, es:[si + 76] + + mov cx, es:[si + 78] + mov di, es:[si + 80] + + push es + push bx + push ax + push dx + push cx + + mov bx, cs:[_disk_scratch] + mov es, bx + + xor bx, bx + call _read_sectors + + mov ax, word ptr [bp - 6] + mov es:[di + 26], ax + + mov ax, word ptr [bp - 4] + mov es:[di + 20], ax + + mov ax, word ptr [bp - 10] + mov es:[di + 28], ax + + mov ax, word ptr [bp - 8] + mov es:[di + 30], ax + + pop cx + pop dx + pop ax + + xor bx, bx + call _write_sectors + + pop bx + pop es + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Check if we have an info sector. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + mov ax, cs:[_info_sector] + + and ax, ax + jz _write_file.done + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Update the free clusters. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + xor dx, dx + + add ax, cs:[_hidden_sectors] + adc dx, cs:[_hidden_sectors + 2] + + mov bx, cs:[_disk_scratch] + mov es, bx + xor bx, bx + + mov cx, 1 + call _read_sectors + + mov di, HEX (01E0) + + mov ax, es:[di + 8] + mov dx, es:[di + 10] + + sub ax, word ptr [bp - 12] + sbb dx, 0 + + mov es:[di + 8], ax + mov es:[di + 10], dx + + mov ax, cs:[_info_sector] + xor dx, dx + + add ax, cs:[_hidden_sectors] + adc dx, cs:[_hidden_sectors + 2] + + mov cx, 1 + call _write_sectors + + jmp _write_file.done + +.L5: + + mov ax, es:[si + 66] + mov dx, es:[si + 68] + + cmp dx, es:[si + 64] + ja .L18 + + cmp dx, es:[si + 64] + jne .L17 + + cmp ax, es:[si + 62] + jb .L17 + +.L18: + + mov bx, es:[si + 58] + or bx, es:[si + 60] + + and bx, bx + jz _write_file.done + + mov cx, es:[si + 50] + div cx + + mov bx, ax + + and dx, dx + jz .L3 + + inc bx + +.L3: + + mov ax, es:[si + 62] + mov dx, es:[si + 64] + + mov cx, es:[si + 50] + div cx + + mov cx, ax + + and dx, dx + jz .L3 + + inc cx + +.L4: + + xchg bx, cx + + mov ax, es:[si + 58] + mov dx, es:[si + 60] + +.L7: + + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx + + and bx, bx + jz .L8 + + dec cx + + call cs:[_next_cluster] + jc .L8 + + dec bx + jnz .L7 + +.L8: + + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] + + mov word ptr [bp - 16], ax + mov word ptr [bp - 14], dx + + mov word ptr [bp - 12], cx + +.L9: + + and cx, cx + jz .L10 + + call cs:[_next_cluster] + jc .L10 + + push si + push di + + mov si, ax + mov di, dx + + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] + + mov word ptr [bp - 6], si + mov word ptr [bp - 4], di + + pop di + pop si + + push bx + push cx + + xor bx, bx + xor cx, cx + + call cs:[_update_cluster] + + pop cx + pop bx + + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] + + dec cx + jnz .L9 + +.L10: + + mov ax, word ptr [bp - 6] + mov dx, word ptr [bp - 4] + + push bx + push cx + + xor bx, bx + xor cx, cx + + call cs:[_update_cluster] + + pop cx + pop bx + + xor ax, ax + xor dx, dx + + mov bx, es:[si + 62] + or bx, es:[si + 64] + + and bx, bx + jz .L12 + + mov cx, word ptr [bp - 12] + + cmp cx, 2 + jb .L6 + + sub cx, 2 + +.L11: + + and cx, cx + jz .L6 + + call cs:[_find_free] + jc .L6 + + push bx + push cx + + mov bx, dx + mov cx, ax + + mov ax, word ptr [bp - 16] + mov dx, word ptr [bp - 14] + + call cs:[_update_cluster] + + mov word ptr [bp - 16], cx + mov word ptr [bp - 14], bx + + pop cx + pop bx + + dec cx + jnz .L11 + +.L6: + + push bx + push cx + + mov bx, HEX (FFFF) + mov cx, HEX (FFF8) + + mov ax, word ptr [bp - 16] + mov dx, word ptr [bp - 14] + + call cs:[_update_cluster] + + pop cx + pop bx + + mov ax, es:[si + 58] + mov dx, es:[si + 60] + +.L12: + + mov es:[si + 58], ax + mov es:[si + 60], dx + + mov word ptr [bp - 18], 1 + jmp .L23 + +.L17: + + mov word ptr [bp - 18], 0 + + push es + push di + push ax + + mov cx, es:[si + 50] + + mov ax, cs:[_disk_scratch] + mov es, ax + xor di, di + + xor al, al + rep stosb + + pop ax + pop di + pop es + + mov cx, es:[si + 50] + div cx + + mov bx, ax + + and dx, dx + jz .L2 inc bx @@ -1546,6 +2363,8 @@ _write_file.extend: inc cx .L1: + + mov word ptr [bp - 12], cx mov ax, es:[si + 58] mov dx, es:[si + 60] @@ -1554,7 +2373,7 @@ _write_file.extend: or di, dx and di, di - jnz _write_file.extend_walk + jnz .L13 call cs:[_find_free] jc _write_file.done @@ -1562,6 +2381,16 @@ _write_file.extend: mov word ptr [bp - 6], ax mov word ptr [bp - 4], dx + push bx + push cx + + mov bx, HEX (FFFF) + mov cx, HEX (FFF8) + call cs:[_update_cluster] + + pop cx + pop bx + mov es:[si + 58], ax mov es:[si + 60], dx @@ -1587,38 +2416,39 @@ _write_file.extend: call _write_sectors pop cx + dec cx + pop bx pop es - jmp _write_file.extend_no_walk + jmp .L14 -_write_file.extend_walk: +.L13: mov word ptr [bp - 6], ax mov word ptr [bp - 4], dx and bx, bx - jz _write_file.extend_no_walk + jz .L14 call cs:[_next_cluster] - jc _write_file.extend_no_walk + jc .L14 + dec word ptr [bp - 12] dec cx dec bx - jnz _write_file.extend_walk + jnz .L13 -_write_file.extend_no_walk: +.L14: mov ax, word ptr [bp - 6] mov dx, word ptr [bp - 4] - - mov word ptr [bp - 12], cx -_write_file.extend_loop: +.L15: and cx, cx - jz _write_file.extend_update + jz .L16 call cs:[_find_free] jc _write_file.done @@ -1640,7 +2470,7 @@ _write_file.extend_loop: pop cx pop bx - jc _write_file.extend_update + jc .L16 push es push bx @@ -1659,16 +2489,23 @@ _write_file.extend_loop: pop bx pop es - mov word ptr [bp - 6], cx - mov word ptr [bp - 4], bx + mov ax, cx + mov dx, bx + + mov bx, HEX (FFFF) + mov cx, HEX (FFF8) + call cs:[_update_cluster] pop cx pop bx + mov word ptr [bp - 6], ax + mov word ptr [bp - 4], dx + dec cx - jnz _write_file.extend_loop + jnz .L15 -_write_file.extend_update: +.L16: push es push bx @@ -1697,7 +2534,9 @@ _write_file.extend_update: pop cx pop bx pop es - + +.L23: + mov ax, es:[si + 58] mov word ptr [bp - 6], ax @@ -1784,9 +2623,21 @@ _write_file.extend_update: mov ax, es:[di + 8] mov dx, es:[di + 10] + cmp word ptr [bp - 18], 1 + jb .L25 + + add ax, word ptr [bp - 12] + adc dx, 0 + + jmp .L24 + +.L25: + sub ax, word ptr [bp - 12] sbb dx, 0 - + +.L24: + mov es:[di + 8], ax mov es:[di + 10], dx @@ -1801,17 +2652,17 @@ _write_file.extend_update: _write_file.done: - mov word ptr es:[si + 54], 1 - pop ds pop es pop di pop si + mov word ptr es:[si + 54], 1 + pop dx pop cx pop bx - add sp, 16 + add sp, 26 clc mov ax, word ptr [bp - 2] @@ -1821,17 +2672,17 @@ _write_file.done: _write_file.error: - mov word ptr es:[si + 54], 1 - pop ds pop es pop di pop si + mov word ptr es:[si + 54], 1 + pop dx pop cx pop bx - add sp, 16 + add sp, 26 stc mov ax, 5 diff --git a/src/kernel/int21.asm b/src/kernel/int21.asm index 7e3899a..eb28c8f 100644 --- a/src/kernel/int21.asm +++ b/src/kernel/int21.asm @@ -2588,9 +2588,6 @@ _int21_3C: push es push ds - xor bh, bh - mov bl, al - mov si, dx call _get_disk_info @@ -2610,7 +2607,11 @@ _int21_3C.create: mov word ptr [bp - 4], si mov word ptr [bp - 2], di + push cx + call _walk_path + pop cx + jc _int21_3C.error_path ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -3452,9 +3453,6 @@ _int21_41: push es push ds - xor bh, bh - mov bl, al - mov si, dx call _get_disk_info @@ -3521,7 +3519,7 @@ _int21_41.open: or bx, dx and bx, bx - jz _int21_41.update + jz _int21_41.no_start ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Convert the size into the amount of cluster. @@ -3578,6 +3576,11 @@ _int21_41.clear: dec cx jnz _int21_41.clear +_int21_41.no_start: + + xor cx, cx + push cx + _int21_41.update: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -4183,6 +4186,8 @@ _int21_4E: push es push ds + mov word ptr [bp -8], cx + mov ax, cs:[_selected_disk] mov word ptr [bp - 10], ax -- 2.34.1