atmega8.pp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. {******************************************************************************
  2. Register definitions and startup code for ATMEL ATmega128
  3. ******************************************************************************}
  4. unit atmega8;
  5. {$goto on}
  6. {$macro on}
  7. interface
  8. const
  9. _SFR_OFFSET = $20; //indirect addressing
  10. var
  11. TWBR : byte absolute $00+_SFR_OFFSET;
  12. TWSR : byte absolute $01+_SFR_OFFSET;
  13. TWAR : byte absolute $02+_SFR_OFFSET;
  14. TWDR : byte absolute $03+_SFR_OFFSET;
  15. ADCW : word absolute $04+_SFR_OFFSET;
  16. ADC : word absolute $04+_SFR_OFFSET;
  17. ADCL : byte absolute $04+_SFR_OFFSET;
  18. ADCH : byte absolute $05+_SFR_OFFSET;
  19. ADCSRA : byte absolute $06+_SFR_OFFSET;
  20. ADMUX : byte absolute $07+_SFR_OFFSET;
  21. ACSR : byte absolute $08+_SFR_OFFSET;
  22. UBRRL : byte absolute $09+_SFR_OFFSET;
  23. UCSRB : byte absolute $0A+_SFR_OFFSET;
  24. UCSRA : byte absolute $0B+_SFR_OFFSET;
  25. UDR : byte absolute $0C+_SFR_OFFSET;
  26. SPCR : byte absolute $0D+_SFR_OFFSET;
  27. SPSR : byte absolute $0E+_SFR_OFFSET;
  28. SPDR : byte absolute $0F+_SFR_OFFSET;
  29. PIND : byte absolute $10+_SFR_OFFSET;
  30. DDRD : byte absolute $11+_SFR_OFFSET;
  31. PORTD : byte absolute $12+_SFR_OFFSET;
  32. PINC : byte absolute $13+_SFR_OFFSET;
  33. DDRC : byte absolute $14+_SFR_OFFSET;
  34. PORTC : byte absolute $15+_SFR_OFFSET;
  35. PINB : byte absolute $16+_SFR_OFFSET;
  36. DDRB : byte absolute $17+_SFR_OFFSET;
  37. PORTB : byte absolute $18+_SFR_OFFSET;
  38. EECR : byte absolute $1C+_SFR_OFFSET;
  39. EEDR : byte absolute $1D+_SFR_OFFSET;
  40. EEAR : word absolute $1E+_SFR_OFFSET;
  41. EEARL : byte absolute $1E+_SFR_OFFSET;
  42. EEARH : byte absolute $1F+_SFR_OFFSET;
  43. UCSRC : byte absolute $20+_SFR_OFFSET;
  44. UBRRH : byte absolute $20+_SFR_OFFSET;
  45. WDTCR : byte absolute $21+_SFR_OFFSET;
  46. ASSR : byte absolute $22+_SFR_OFFSET;
  47. OCR2 : byte absolute $23+_SFR_OFFSET;
  48. TCNT2 : byte absolute $24+_SFR_OFFSET;
  49. TCCR2 : byte absolute $25+_SFR_OFFSET;
  50. ICR1 : word absolute $26+_SFR_OFFSET;
  51. ICR1L : byte absolute $26+_SFR_OFFSET;
  52. ICR1H : byte absolute $27+_SFR_OFFSET;
  53. OCR1B : word absolute $28+_SFR_OFFSET;
  54. OCR1BL : byte absolute $28+_SFR_OFFSET;
  55. OCR1BH : byte absolute $29+_SFR_OFFSET;
  56. OCR1A : word absolute $2A+_SFR_OFFSET;
  57. OCR1AL : byte absolute $2A+_SFR_OFFSET;
  58. OCR1AH : byte absolute $2B+_SFR_OFFSET;
  59. TCNT1 : word absolute $2C+_SFR_OFFSET;
  60. TCNT1L : byte absolute $2C+_SFR_OFFSET;
  61. TCNT1H : byte absolute $2D+_SFR_OFFSET;
  62. TCCR1B : byte absolute $2E+_SFR_OFFSET;
  63. TCCR1A : byte absolute $2F+_SFR_OFFSET;
  64. SFIOR : byte absolute $30+_SFR_OFFSET;
  65. OSCCAL : byte absolute $31+_SFR_OFFSET;
  66. TCNT0 : byte absolute $32+_SFR_OFFSET;
  67. TCCR0 : byte absolute $33+_SFR_OFFSET;
  68. MCUSR : byte absolute $34+_SFR_OFFSET;
  69. MCUCSR : byte absolute $34+_SFR_OFFSET;
  70. MCUCR : byte absolute $35+_SFR_OFFSET;
  71. TWCR : byte absolute $36+_SFR_OFFSET;
  72. SPMCR : byte absolute $37+_SFR_OFFSET;
  73. TIFR : byte absolute $38+_SFR_OFFSET;
  74. TIMSK : byte absolute $39+_SFR_OFFSET;
  75. GIFR : byte absolute $3A+_SFR_OFFSET;
  76. GICR : byte absolute $3B+_SFR_OFFSET;
  77. SP : word absolute $3D+_SFR_OFFSET;
  78. SPL : byte absolute $3D+_SFR_OFFSET;
  79. SPH : byte absolute $3E+_SFR_OFFSET;
  80. SREG : byte absolute $3F+_SFR_OFFSET;
  81. const
  82. TWINT = 7;
  83. TWEA = 6;
  84. TWSTA = 5;
  85. TWSTO = 4;
  86. TWWC = 3;
  87. TWEN = 2;
  88. TWIE = 0;
  89. TWA6 = 7;
  90. TWA5 = 6;
  91. TWA4 = 5;
  92. TWA3 = 4;
  93. TWA2 = 3;
  94. TWA1 = 2;
  95. TWA0 = 1;
  96. TWGCE = 0;
  97. TWS7 = 7;
  98. TWS6 = 6;
  99. TWS5 = 5;
  100. TWS4 = 4;
  101. TWS3 = 3;
  102. TWPS1 = 1;
  103. TWPS0 = 0;
  104. XDIVEN = 7;
  105. XDIV6 = 6;
  106. XDIV5 = 5;
  107. XDIV4 = 4;
  108. XDIV3 = 3;
  109. XDIV2 = 2;
  110. XDIV1 = 1;
  111. XDIV0 = 0;
  112. ISC11 = 3;
  113. ISC10 = 2;
  114. ISC01 = 1;
  115. ISC00 = 0;
  116. INT1 = 7;
  117. INT0 = 6;
  118. INTF1 = 7;
  119. INTF0 = 6;
  120. OCIE2 = 7;
  121. TOIE2 = 6;
  122. TICIE1 = 5;
  123. OCIE1A = 4;
  124. OCIE1B = 3;
  125. TOIE1 = 2;
  126. TOIE0 = 0;
  127. OCF2 = 7;
  128. TOV2 = 6;
  129. ICF1 = 5;
  130. OCF1A = 4;
  131. OCF1B = 3;
  132. TOV1 = 2;
  133. TOV0 = 0;
  134. SPMIE = 7;
  135. RWWSB = 6;
  136. RWWSRE = 4;
  137. BLBSET = 3;
  138. PGWRT = 2;
  139. PGERS = 1;
  140. SPMEN = 0;
  141. COM1A1 = 7;
  142. COM1A0 = 6;
  143. COM1B1 = 5;
  144. COM1B0 = 4;
  145. COM1C1 = 3;
  146. COM1C0 = 2;
  147. WGM11 = 1;
  148. WGM10 = 0;
  149. ICNC = 7;
  150. ICES = 6;
  151. WGMB3 = 4;
  152. WGMB2 = 3;
  153. CSB2 = 2;
  154. CSB1 = 1;
  155. CSB0 = 0;
  156. ICNC1 = 7;
  157. ICES1 = 6;
  158. WGM13 = 4;
  159. WGM12 = 3;
  160. CS12 = 2;
  161. CS11 = 1;
  162. CS10 = 0;
  163. FOC2 = 7;
  164. WGM20 = 6;
  165. COM21 = 5;
  166. COM20 = 4;
  167. WGM21 = 3;
  168. CS22 = 2;
  169. CS21 = 1;
  170. CS20 = 0;
  171. SPIF = 7;
  172. WCOL = 6;
  173. SPI2X = 0;
  174. SPIE = 7;
  175. SPE = 6;
  176. DORD = 5;
  177. MSTR = 4;
  178. CPOL = 3;
  179. CPHA = 2;
  180. SPR1 = 1;
  181. SPR0 = 0;
  182. URSEL = 7;
  183. UMSEL = 6;
  184. UPM1 = 5;
  185. UPM0 = 4;
  186. USBS = 3;
  187. UCSZ1 = 2;
  188. UCSZ0 = 1;
  189. UCPOL = 0;
  190. RXC = 7;
  191. TXC = 6;
  192. UDRE = 5;
  193. FE = 4;
  194. DOR = 3;
  195. UPE = 2;
  196. U2X = 1;
  197. MPCM = 0;
  198. RXCIE = 7;
  199. TXCIE = 6;
  200. UDRIE = 5;
  201. RXEN = 4;
  202. TXEN = 3;
  203. UCSZ = 2;
  204. UCSZ2 = 2;
  205. RXB8 = 1;
  206. TXB8 = 0;
  207. ACD = 7;
  208. ACBG = 6;
  209. ACO = 5;
  210. ACI = 4;
  211. ACIE = 3;
  212. ACIC = 2;
  213. ACIS1 = 1;
  214. ACIS0 = 0;
  215. ADEN = 7;
  216. ADSC = 6;
  217. ADFR = 5;
  218. ADIF = 4;
  219. ADIE = 3;
  220. ADPS2 = 2;
  221. ADPS1 = 1;
  222. ADPS0 = 0;
  223. REFS1 = 7;
  224. REFS0 = 6;
  225. ADLAR = 5;
  226. MUX3 = 3;
  227. MUX2 = 2;
  228. MUX1 = 1;
  229. MUX0 = 0;
  230. {$define DOCALL:=call}
  231. {$define DOJMP:=jmp}
  232. implementation
  233. {$i avrcommon.inc}
  234. procedure Int00Handler; external name 'Int00Handler';
  235. procedure Int01Handler; external name 'Int01Handler';
  236. procedure Int02Handler; external name 'Int02Handler';
  237. procedure Int03Handler; external name 'Int03Handler';
  238. procedure Int04Handler; external name 'Int04Handler';
  239. procedure Int05Handler; external name 'Int05Handler';
  240. procedure Int06Handler; external name 'Int06Handler';
  241. procedure Int07Handler; external name 'Int07Handler';
  242. procedure Int08Handler; external name 'Int08Handler';
  243. procedure Int09Handler; external name 'Int09Handler';
  244. procedure Int10Handler; external name 'Int10Handler';
  245. procedure Int11Handler; external name 'Int11Handler';
  246. procedure Int12Handler; external name 'Int12Handler';
  247. procedure Int13Handler; external name 'Int13Handler';
  248. procedure Int14Handler; external name 'Int14Handler';
  249. procedure Int15Handler; external name 'Int15Handler';
  250. procedure Int16Handler; external name 'Int16Handler';
  251. procedure Int17Handler; external name 'Int17Handler';
  252. procedure Int18Handler; external name 'Int18Handler';
  253. procedure _FPC_start; assembler; nostackframe;
  254. label
  255. _start;
  256. asm
  257. .init
  258. .globl _start
  259. // .org 0x00
  260. jmp _start
  261. jmp Int00Handler
  262. jmp Int01Handler
  263. jmp Int02Handler
  264. jmp Int03Handler
  265. jmp Int04Handler
  266. jmp Int05Handler
  267. jmp Int06Handler
  268. jmp Int07Handler
  269. jmp Int08Handler
  270. jmp Int09Handler
  271. jmp Int10Handler
  272. jmp Int11Handler
  273. jmp Int12Handler
  274. jmp Int13Handler
  275. jmp Int14Handler
  276. jmp Int15Handler
  277. jmp Int16Handler
  278. jmp Int17Handler
  279. jmp Int18Handler
  280. {
  281. all ATMEL MCUs use the same startup code, the details are
  282. governed by defines
  283. }
  284. {$i start.inc}
  285. .weak Int00Handler
  286. .weak Int01Handler
  287. .weak Int02Handler
  288. .weak Int03Handler
  289. .weak Int04Handler
  290. .weak Int05Handler
  291. .weak Int06Handler
  292. .weak Int07Handler
  293. .weak Int08Handler
  294. .weak Int09Handler
  295. .weak Int10Handler
  296. .weak Int11Handler
  297. .weak Int12Handler
  298. .weak Int13Handler
  299. .weak Int14Handler
  300. .weak Int15Handler
  301. .weak Int16Handler
  302. .weak Int17Handler
  303. .weak Int18Handler
  304. .set Int00Handler, Default_IRQ_handler
  305. .set Int01Handler, Default_IRQ_handler
  306. .set Int02Handler, Default_IRQ_handler
  307. .set Int03Handler, Default_IRQ_handler
  308. .set Int04Handler, Default_IRQ_handler
  309. .set Int05Handler, Default_IRQ_handler
  310. .set Int06Handler, Default_IRQ_handler
  311. .set Int07Handler, Default_IRQ_handler
  312. .set Int08Handler, Default_IRQ_handler
  313. .set Int09Handler, Default_IRQ_handler
  314. .set Int10Handler, Default_IRQ_handler
  315. .set Int11Handler, Default_IRQ_handler
  316. .set Int12Handler, Default_IRQ_handler
  317. .set Int13Handler, Default_IRQ_handler
  318. .set Int14Handler, Default_IRQ_handler
  319. .set Int15Handler, Default_IRQ_handler
  320. .set Int16Handler, Default_IRQ_handler
  321. .set Int17Handler, Default_IRQ_handler
  322. .set Int18Handler, Default_IRQ_handler
  323. end;
  324. end.