summaryrefslogtreecommitdiffstats
path: root/pathname.S
blob: 9b6ec89eed2ea3cfe27f42a9a799d63329bdf5a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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