// This may look like C code, but it is really -*- Asm -*-
/*
 *  smoke16/src16/deadbeef.s - Demonstrates the C ("carry") flag.
 *  $Revision: 1.14 $
 *  Copyright 1997, 2000, 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>
#include <smoke16/syscall.h>

	.data
LCerror:.zstring "X: carry test failed.\n"

	.rdata
LCok:	.zstring "All tests succeeded.\n"

	.text
	.align 1
	FUNCTION(_main)
	mov %0, %a2
	movb 'A', %a2
	add 0, %0
	bc screwup
	movb 'B', %a2
	mov %0, %a0
	add 1, %a0
	bc screwup
	movb 'C', %a2
	sub 2, %a0
	bc fine
screwup:int SMOKE16__SYS_REGDUMP
	mov LCerror, %a0
	mov [_stderr], %a1
	movb %a2, [%a0]
	call _fputs
	add 1, %a0
done:	RET
fine:	mov LCok, %a0
	mov [_stdout], %a1
	call _fputs
	mov %0, %a0
	b done
