Advertisement
Guest User

68k Bootstrap

a guest
Aug 13th, 2014
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.65 KB | None | 0 0
  1. /*
  2. Source for 68k bin:
  3.  
  4. M68000
  5.     DL 0
  6.     DL 8
  7.  
  8.     MOVE.B  #$FF, D1
  9.  
  10. LOOP:
  11.     MOVE.L  #$FF, D0
  12.  
  13. LOOPW1:
  14.     SUBQ    #1, D0
  15.     BNE LOOPW1
  16.  
  17.     MOVE.B  D1, $010000
  18.     NOT D1
  19.     BRA LOOP
  20.  
  21. */
  22. #include <stdint.h>
  23.  
  24. uint8_t data[0x20] = {
  25. 0x00, 0x00, 0x00, 0x00,
  26. 0x00, 0x00, 0x00, 0x08,
  27. 0x12, 0x3c, 0x00, 0xff,
  28. 0x20, 0x3c, 0x00, 0x00,
  29. 0x00, 0xff, 0x53, 0x40,
  30. 0x66, 0xfc, 0x13, 0xc1,
  31. 0x00, 0x01, 0x00, 0x00,
  32. 0x46, 0x41, 0x60, 0xec
  33. };
  34.  
  35. void bus_highz()
  36. {
  37.     int _c;
  38.     for (_c = 2; _c <= 9; _c++)
  39.       pinMode(_c, INPUT);
  40. }
  41.  
  42. void bus_out(uint8_t data)
  43. {
  44.     int _c;
  45.     for (_c = 2; _c <= 9; _c++)
  46.       pinMode(_c, OUTPUT);
  47.     for (_c = 0; _c < 8; _c++)
  48.       digitalWrite(2 + _c, data & (1 << _c));
  49. }
  50.  
  51. uint8_t get_addr()
  52. {
  53.     uint8_t _c;
  54.     uint8_t _b = 0;
  55.     for (_c = 0; _c < 5; _c++)
  56.       _b |= (digitalRead(A0 + _c) ? 1 : 0) << _c;
  57.       _b |= (digitalRead(10) ? 1 : 0) ;
  58.   return _b;
  59. }
  60.  
  61. void do_read(){
  62.   uint8_t addr = get_addr();
  63.       Serial.println(addr);
  64.   bus_out(data[addr]);
  65.   digitalWrite(12, LOW);
  66. }
  67.  
  68. void setup() {
  69.     int _c;
  70.     Serial.begin(115200);
  71.     bus_highz();
  72.     for (_c = 0; _c < 5; _c++)
  73.       pinMode(A0 + _c, INPUT);
  74.     pinMode(A5, INPUT);
  75.     pinMode(10, INPUT);
  76.     pinMode(11, INPUT);
  77.     pinMode(12, OUTPUT);
  78.     pinMode(13, OUTPUT);
  79.     digitalWrite(13, LOW);
  80.     digitalWrite(12, LOW);
  81.     digitalWrite(13, LOW);
  82. }
  83. void loop() {
  84.   if (digitalRead(A5) || !digitalRead(11)) {//IF READ & NOT *RAMCS
  85.       bus_highz();
  86.       digitalWrite(12, LOW);
  87.      
  88.   } else {
  89.       digitalWrite(12, LOW);//Deassert SETARDUDTACK
  90.       do_read();
  91.       digitalWrite(12, HIGH);//Assert SETARDUDTACK
  92.   }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement