summaryrefslogtreecommitdiffstats
path: root/pathname.asm
diff options
context:
space:
mode:
Diffstat (limited to 'pathname.asm')
-rw-r--r--pathname.asm81
1 files changed, 65 insertions, 16 deletions
diff --git a/pathname.asm b/pathname.asm
index 6525ff0..0e801b9 100644
--- a/pathname.asm
+++ b/pathname.asm
@@ -31,35 +31,52 @@
.section ".rtext","ax"
/* ------------------------------------------------------------------------- *
- * genpath_asciiz
+ * get_end_path
*
- * Convert a DOS-format path in FS:SI into a walk path in (ES|DS):DI
- *
- * The DOS path is expected to be an absolute path starting with \
+ * Set up BX to point to the end of a path in FS:SI
* ------------------------------------------------------------------------- */
-GPROC(genpath_asciiz)
- pushw %bx
+GPROC(get_end_path)
pushw %ax
- movw %si,%bx
+ xchg %si,%bx
1:
- movb %fs:(%bx),%al
- incw %bx
+ fs lodsb
andb %al,%al
jnz 1b
- decw %bx
+ decw %si
+ xchg %si,%bx
popw %ax
- call genpath
- popw %bx
retw
-END(genpath_asciiz)
+END(get_end_path)
/* ------------------------------------------------------------------------- *
+ * get_dir_path
+ *
+ * Set up BX to point to the last backslash in FS:SI
+ * ------------------------------------------------------------------------- */
+GPROC(get_dir_path)
+ pushw %ax
+ pushw %si
+ xorw %bx,%bx
+1:
+ fs lodsb
+ cmpb $0x5c,%al
+ jne 2f
+ leaw -1(%si),%bx
+2:
+ andb %al,%al
+ jnz 1b
+ popw %si
+ popw %ax
+ retw
+END(get_dir_path)
+
+/* ------------------------------------------------------------------------- *
* genpath
*
* Convert a DOS-format path in FS:SI into a walk path in (ES|DS):DI
* BX marks the end of the path to convert.
*
- * The DOS path is expected to be an absolute path starting with \
+ * The DOS path is expected to be an absolute path *without* leading \
* ------------------------------------------------------------------------- */
GPROC(genpath)
@@ -86,8 +103,6 @@ GPROC(genpath)
call debug_crlf
#endif
- incw %si /* Skip leading backslash */
-
xorw %ax,%ax
stosw
@@ -125,3 +140,37 @@ GPROC(genpath)
popw %bp
retw
END(genpath)
+
+/* ------------------------------------------------------------------------- *
+ * genfilename
+ *
+ * Convert a DOS-format file name (null-terminated) in FS:SI into
+ * path element in (ES|DS):DI
+ * ------------------------------------------------------------------------- */
+
+GPROC(genfilename)
+ pushw %si
+ pushw %bx
+ pushw %ax
+
+ stosw /* Space for chunk length */
+ movw %di,%bx /* Save pointer to chunk beginning */
+
+2:
+ fs lodsb
+ andb %al,%al
+ jz 3f
+
+ call cptoutf
+ jmp 2b
+3:
+ /* Update chunk length */
+ movw %di,%ax
+ subw %bx,%ax
+ movw %ax,-2(%bx)
+
+ popw %ax
+ popw %bx
+ popw %si
+ retw
+END(genfilename)