Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ROM[16] = {0x00, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- word Address;
- int Prev;
- int Current;
- void setup() {
- DDRA = 0x00; //Pins 22-29 (lower 8b of Address Input) 22 = 0, > 29 = 7
- DDRC = 0x00; //Pins 30-37 (upper 8b of Address Input) 37 = 0, < 30 = 7
- DDRL = 0xFF; //Pins 42-49 (8b Data Output) 49 = 0, > 42 = 7
- Prev = 0xFF;
- Address = 0x0000;
- Serial.begin(500000);
- }
- void loop() {
- Address = word(PINC,PINA); //Combines PORTC and PORTA into a single 16b Value
- PORTL = ROM[Address]; //Reads from the ROM Array and puts it onto the Data Output
- Current = Address;
- if(Prev != Current){ //If the Address from one cycle beofre is the same as the Current one it will not print anything on the Serial Monitor. to keep it clean
- if (PORTL < 0x10 ) {
- Serial.print("$0");
- }
- else{
- Serial.print("$");
- };
- Serial.print(PORTL, HEX); //Prints the Data on the current Address as HEX with leading 0.
- Serial.print(" ");
- if (Address < 0x0010 ) {
- Serial.print("$000");
- goto EOSP;
- };
- if (Address < 0x0100 ) {
- Serial.print("$00");
- goto EOSP;
- };
- if (Address < 0x1000 ) {
- Serial.print("$0");
- goto EOSP;
- }
- else{
- Serial.print("$");
- };
- EOSP:
- Serial.print(Address, HEX); //Prints the Currently accessed Address as HEX with leading 0s.
- Serial.println();
- Prev = Current; //Sets the used Address as the "previous" one, so it can be compared next cycle.
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement