summaryrefslogtreecommitdiffstats
path: root/pathname.S
diff options
context:
space:
mode:
Diffstat (limited to 'pathname.S')
-rw-r--r--pathname.S55
1 files changed, 55 insertions, 0 deletions
diff --git a/pathname.S b/pathname.S
new file mode 100644
index 0000000..9b6ec89
--- /dev/null
+++ b/pathname.S
@@ -0,0 +1,55 @@
+#include "v9fs.h"
+
+ .code16
+ .section ".rtext","ax"
+
+/* ------------------------------------------------------------------------- *
+ * 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.
+ * ------------------------------------------------------------------------- */
+
+ .globl genpath
+genpath:
+ pushw %bp
+ movw %sp,%bp
+ pushw %bx /* -2(%bp) - end of string */
+ pushw %di /* -4(%bp) - chunk count pointer */
+ pushw %ax /* -6(%bp) */
+
+ xorw %ax,%ax
+ stosw
+
+1:
+ cmpw -2(%bp),%si
+ jae 4f /* End of string */
+
+ stosw /* Chunk length */
+ movw %di,%bx /* Save pointer to chunk beginning */
+
+2:
+ fs lodsb
+ cmpb $0x5c,%al /* Backslash */
+ je 3f
+
+ call cptoutf
+ jmp 2b
+3:
+ /* Update chunk length */
+ movw %di,%ax
+ subw %bx,%ax
+ movw %ax,-2(%bx)
+
+ /* Update chunk count */
+ movw -4(%bp),%bx
+ incw (%bx)
+ jmp 1b
+4:
+ popw %ax
+ popw %di
+ popw %bx
+ popw %bp
+ retw
+ .size genpath,.-genpath
+ .type genpath,@function