aboutsummaryrefslogtreecommitdiffstats
path: root/menu/startup.S16
blob: ccdc776b3537a5899f35e7348ac0cd75eb7ffa7f (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
	.code16gcc

	.globl _start
_start:
	/* Make sure stack pointer is normalized */
	movzwl %sp,%esp

	/* Zero .bss */
	movw $__bss_start,%di
	xorl %eax,%eax
	movw $(_end+3),%cx
	subw %di,%cx
	shrw $2,%cx
	cld
	rep ; stosl

	/* Normalize the command line.  At startup 0x80 = length and
	   the command line starts at 0x81, but with whitespace */
	movl $0x81,%esi
	movzbw (0x80),%bx
	movb $0,(%bx,%si)		/* Null-terminate the string */
1:
	lodsb
	dec %al				/* Stop on null */
	cmp $31,%al			/* Whitespace? */
	jbe 1b
	dec %si				/* Unskip first character */

	/* Invoke _cstart */
	pushl %esi			/* Pointer to command line */
	calll _cstart

	/* Terminate program (with error code in %al) */
	movb $0x4c,%ah
	int $0x21
	hlt