-
C Code Works
08/31/2020 at 01:19 • 0 commentsI have successfully gotten a simple program written in C to run. The program prints out a stanza from the poem To a Waterfowl. After each stanza, it waits for user input before printing the next stanza. Source code is shown below:
void kernel_main(void) { while (1) { mc6850_print("Whither, 'midst falling dew,\ While glow the heavens with the last steps of day,\ Far, through their rosy depths, dost thou pursue\ Thy solitary way?"); mc6850_read(); mc6850_print("Vainly the fowler’s eye\ Might mark thy distant flight, to do thee wrong,\ As, darkly seen against the crimson sky,\ Thy figure floats along."); mc6850_read(); mc6850_print("Seek’st thou the plashy brink\ Of weedy lake, or marge of river wide,\ Or where the rocking billows rise and sink\ On the chaféd ocean side?"); mc6850_read(); mc6850_print("There is a Power, whose care\ Teaches thy way along that pathless coast,—\ The desert and illimitable air\ Lone wandering, but not lost."); mc6850_read(); mc6850_print("All day thy wings have fanned,\ At that far height, the cold thin atmosphere;\ Yet stoop not, weary, to the welcome land,\ Though the dark night is near."); mc6850_read(); mc6850_print("And soon that toil shall end,\ Soon shalt thou find a summer home, and rest,\ And scream among thy fellows; reeds shall bend,\ Soon, o’er thy sheltered nest."); mc6850_read(); mc6850_print("Thou’rt gone, the abyss of heaven\ Hath swallowed up thy form, yet, on my heart\ Deeply hath sunk the lesson thou hast given,\ And shall not soon depart."); mc6850_read(); mc6850_print("He, who, from zone to zone,\ Guides through the boundless sky thy certain flight,\ In the long way that I must trace alone,\ Will lead my steps aright."); } }
This is what it outputs to the serial terminal:
I have also completed the MC6850 library. Source code is shown below:
#define MC6850_BASE 0xC0000 uint8_t* const mc6850_command = (uint8_t*)(MC6850_BASE); uint8_t* const mc6850_data = (uint8_t*)(MC6850_BASE+1); char mc6850_read(void) { // check if RDR full while (!(*mc6850_command & 1)); // read character from RDR return *mc6850_data; } void mc6850_write(char c) { // check if TDR empty while (!(*mc6850_command & 2)); // write character to TDR *mc6850_data = c; } void mc6850_print(const char* s) { while (*s) mc6850_write(*s++); }
-
Exception Handlers
08/30/2020 at 23:53 • 0 commentsI have implemented a very simple exception handler so that I can figure out what is causing the machine to fault.
The exception handler is telling me that the issue is an invalid instruction. It turns out, I forgot to add -march=68000 -mcpu=68000 to the C compiler flags. I added said flags and compared the binaries:
It turns out that EXTB is a 68020 instruction not present in the 68008. That was what was causing the fault.