summaryrefslogtreecommitdiffstats
path: root/Support_Libs/debug/debug.hcc
blob: 618ca466fc8bbc6bf26e41a4293530dd6b259502 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdlib.hch>

#include "pal_master.hch"

#include "debug.hch"

void print_hex_value(unsigned 32 value)
{
	unsigned 8 ch;
	unsigned 4 i; 
	
	for(i = 0;i < 8;i++)
	{
		ch = 0 @ (value\\28);		
		value <<= 4;
		ch += (ch > 9) ? 0x37 : 0x30;
		PalDataPortWrite(PalRS232PortCT(0), ch);
	}
}

void print_string(unsigned char *s) {
	unsigned 10 index;

	/*
	 * We print all elements from the provided array until we encounter the
	 * '\0' character. Since standard C and Handel-C both end a string
	 * with the '\0' character. Since Handel-C init's var's to 0 this
	 * normally will never go wrong.
	 */
	for(index = 0; '\0' != s[index]; index++) {
		PalDataPortWrite(PalRS232PortCT(0), s[index]);
    }
}



void print_eol(void) {
	/*
	 * To write a clean 'return' we have to both write the newline and
	 * carriage return symbol.
	 */
	PalDataPortWrite(PalRS232PortCT(0), 0x0a);
	PalDataPortWrite(PalRS232PortCT(0), 0x0d);
}



void print_cr(void) {
	/*
	 * Write the character that forces the cursor to go back to the
	 * beginning of the line.
	 */
	PalDataPortWrite(PalRS232PortCT(0), 0x0d);
}



void print_cls(void) {
	/*
	 * Write the clearscreen character to the RS232 port.
	 */
	PalDataPortWrite(PalRS232PortCT(0), 0x0c);
}