// This may look like C code, but it is really -*- Asm -*-
/*
 *  smoke16/src16/dump.s - Print the command line and environment.
 *  $Revision: 1.8 $
 *  Copyright 1997, Benjamin Sittler
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include <smoke16/asm.h>
	.rdata
LC0:	.zstring "=== Command line"
LC1:	.zstring "=== Environment"

	.text
	.align 1
	// int main(int argc, char * argv[], char * envp[])
	FUNCTION(_main)
	push %t0
	push %t1
	push %t2
	push %t3
	add %a0, %a0, %t0
	mov %a1, %t1
	mov %a2, %t2
	mov LC0, %a0
	call _puts
	mov %0, %t3
args0:	cmp %t0, %t3
	be args1
	mov '\t', %a0
	call _putchar
	add %t1, %t3, %a0
	mov [%a0], %a0
	call _puts
	add 2, %t3
	b args0
args1:	mov LC1, %a0
	call _puts
env0:	mov [%t2], %t0
	cmp %0, %t0
	be env1
	mov '\t', %a0
	call _putchar
	mov %t0, %a0
	call _puts
	add 2, %t2
	b env0
env1:	mov %0, %a0
	pop %t3
	pop %t2
	pop %t1
	pop %t0
	RET
