#include #include "pal_master.hch" #include "debug.hch" void print_hex_value(unsigned 32 value) { unsigned char character; unsigned 4 index; /* * We print 32 bits values max, so we only need 8 positions. */ for(index = 0; index != 8; index++) { /* * The 4 MSB equals one hex digit so we ignore the rest. */ character = 0 @ (value \\ 28); /* * To easly get our 4 MSB on the next run, we shift them here. */ value <<= 4; /* * We now have a value between 0 and f stored in our variable. * We simply add the appropiate value to our character because * only ascii characters make sense to be printed. */ character += (character > 9) ? 0x37 : 0x30; PalDataPortWrite(PalRS232PortCT(0), character); } } void print_string(unsigned char *string) { 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' != string[index]; index++) { PalDataPortWrite(PalRS232PortCT(0), string[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); }