Parse the command-line arguments in uLoader too
This commit is contained in:
parent
4e6cef3810
commit
b5cc973c26
|
@ -95,6 +95,7 @@ _start:
|
||||||
mov %esp, %ebp
|
mov %esp, %ebp
|
||||||
push $0x0 /* argc */
|
push $0x0 /* argc */
|
||||||
|
|
||||||
|
/* FIXME mi->cmdline may be NULL */
|
||||||
mov %ebx, %ecx /* ecx = mi->cmdline; */
|
mov %ebx, %ecx /* ecx = mi->cmdline; */
|
||||||
add $0x10, %ecx
|
add $0x10, %ecx
|
||||||
mov (%ecx), %ecx /* ecx = *ecx; */
|
mov (%ecx), %ecx /* ecx = *ecx; */
|
||||||
|
|
|
@ -88,19 +88,52 @@ _start:
|
||||||
call multiboot
|
call multiboot
|
||||||
add $0x4, %esp
|
add $0x4, %esp
|
||||||
|
|
||||||
/* start the loader */
|
/* parse the command line */
|
||||||
push %ebp
|
push %ebp
|
||||||
mov %esp, %ebp
|
mov %esp, %ebp
|
||||||
|
push $0x0 /* argc */
|
||||||
|
|
||||||
|
/* FIXME mi->cmdline may be NULL */
|
||||||
|
mov %ebx, %ecx /* ecx = mi->cmdline; */
|
||||||
|
add $0x10, %ecx
|
||||||
|
mov (%ecx), %ecx /* ecx = *ecx; */
|
||||||
|
mov %ecx, %edx /* edx = ecx; */
|
||||||
|
3:
|
||||||
|
mov (%edx), %al /* al = *edx; */
|
||||||
|
cmp $0x0, %al /* if(al == '\0') */
|
||||||
|
je 4f /* goto 4f; */
|
||||||
|
inc %edx /* edx++; */
|
||||||
|
jmp 3b /* goto 3b; */
|
||||||
|
4:
|
||||||
|
push $0x0 /* argv[] = NULL; */
|
||||||
|
5:
|
||||||
|
cmp %ecx, %edx /* if(ecx == edx) */
|
||||||
|
je 7f /* goto 7f; */
|
||||||
|
mov (%edx), %al /* al = *edx; */
|
||||||
|
cmp $0x20, %al /* if(al != ' ') */
|
||||||
|
jne 6f /* goto 6f; */
|
||||||
|
movb $0x0, (%edx) /* *edx = '\0'; */
|
||||||
|
inc %edx
|
||||||
|
push %edx /* argv[] = edx; */
|
||||||
|
DEBUG_STRING(%edx)
|
||||||
|
dec %edx
|
||||||
|
incl -0x4(%ebp) /* argc++; */
|
||||||
|
6:
|
||||||
|
dec %edx /* edx--; */
|
||||||
|
jmp 5b /* goto 4b; */
|
||||||
|
7:
|
||||||
|
push %edx /* argv[] = edx; */
|
||||||
|
DEBUG_STRING(%edx)
|
||||||
|
incl -0x4(%ebp) /* argc++; */
|
||||||
|
|
||||||
|
/* prepare the arguments */
|
||||||
|
mov %esp, %eax /* eax = &argv; */
|
||||||
|
push %esp
|
||||||
|
push %ebx /* auxv */
|
||||||
|
push $0x0 /* envp */
|
||||||
|
push %eax /* argv */
|
||||||
|
push -0x4(%ebp) /* argc */
|
||||||
|
|
||||||
push $0x0
|
|
||||||
push $0x0
|
|
||||||
mov %ebx, %eax
|
|
||||||
add $0x10, %eax
|
|
||||||
push %eax
|
|
||||||
push $0x1
|
|
||||||
call main
|
|
||||||
mov %ebp, %esp
|
|
||||||
pop %ebp
|
|
||||||
jmp 2f
|
jmp 2f
|
||||||
|
|
||||||
1:
|
1:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user