File:  [HATARI the Atari ST Emulator] / hatari / tests / dbmsg / dbmsg.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 9 08:57:29 2019 UTC (7 years, 3 months ago) by root
Branches: hatari, MAIN
CVS tags: hatari02100, HEAD
hatari 2.1.0

/*
 * Tester for Hatari's implementation of Atari debugger
 * XBIOS Dbmsg() API
 * 
 * Test:
 *   hatari --bios-intercept --trace xbios dbmsg.tos
 * 
 * See:
 * - http://dev-docs.atariforge.org/files/Atari_Debugger_1-24-1990.pdf
 * - http://toshyp.atari.org/en/004012.html#Dbmsg
 */
#include "stdint.h"
#include "assert.h"
#include "tos.h"

#define DB_APP_CMD    0x0000
#define DB_COMMAND    0xF100
#define DB_NULLSTRING 0xF000
/* len should be: 1-255 */
#define DB_STRING(len) (DB_NULLSTRING + ((len) & 0xFF))

static void Dbmsg(int16_t reserved, uint16_t msg_num, uint32_t msg_arg)
{
	/* other 'reserved' values than 5 are undefined */
	xbios(11, reserved, msg_num, msg_arg);
}

int main()
{
	const char str[] = "Halting STRING";

	/* Print NULL-terminated string */
	Dbmsg(5, DB_NULLSTRING, (uint32_t)"Please print NULLSTRING");

	/* Print given string (which length is encoded to msg_num),
	 * and invoke debugger / halt
	 */
	Dbmsg(5, DB_STRING(sizeof(str)-1), (uint32_t)str);

	/* Print given value and invoke debugger */
	Dbmsg(5, DB_APP_CMD, (uint32_t)0xDEADBEEF);

	/* Give command for debugger to execute.
	 * In Hatari case this is currently same as DB_NULLSTRING.
	 */
	Dbmsg(5, DB_COMMAND, (uint32_t)"echo 'Debugging message';");

	return 0;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.