├── .gitignore ├── asm ├── at90can.f ├── at90can128.f ├── at90can32.f ├── at90can64.f ├── at90usb1287.f ├── at90usb647.f ├── at90usbx7.f ├── atmega128.f ├── atmega16.f ├── atmega162.f ├── atmega168.f ├── atmega32.f ├── atmega328p.f ├── atmega48.f ├── atmega8.f ├── atmega88.f ├── atmegax8.f └── avr.f ├── avrforth.el ├── avrforth.f ├── avrforth.vim ├── blocks ├── assembler.avrforth ├── bit.avrforth ├── core.avrforth ├── debug.avrforth ├── eeprom.avrforth ├── extend.avrforth ├── flag.avrforth ├── font4x6.avrforth ├── lerp.avrforth ├── main.avrforth ├── miniboard.avrforth ├── morse.avrforth ├── oled.avrforth └── pin.avrforth ├── config.f ├── drivers ├── adc.f ├── can.f ├── gpio.f ├── pll.f ├── spi.f ├── tick.f ├── timer.f ├── timer16.f ├── timer8new.f ├── timer8old.f ├── twi.f ├── usart.f ├── usb-device.f ├── usb.f ├── wdt.f └── xmem.f ├── img └── board.jpg ├── makefile ├── readme.md ├── repl.scm ├── send.f └── uno.avrforth /.gitignore: -------------------------------------------------------------------------------- 1 | /eeprom 2 | /flash 3 | -------------------------------------------------------------------------------- /asm/at90can.f: -------------------------------------------------------------------------------- 1 | ( at90can ) 2 | 3 | $20 constant pina 4 | $21 constant ddra 5 | $22 constant porta 6 | $23 constant pinb 7 | $24 constant ddrb 8 | $25 constant portb 9 | $26 constant pinc 10 | $27 constant ddrc 11 | $28 constant portc 12 | $29 constant pind 13 | $2a constant ddrd 14 | $2b constant portd 15 | $2c constant pine 16 | $2d constant ddre 17 | $2e constant porte 18 | $2f constant pinf 19 | $30 constant ddrf 20 | $31 constant portf 21 | $32 constant ping 22 | $33 constant ddrg 23 | $34 constant portg 24 | $35 constant tifr0 25 | 1 constant ocf0a tifr0 ocf0a 2constant ocf0a-bit 26 | 0 constant tov0 tifr0 tov0 2constant tov0-bit 27 | $36 constant tifr1 28 | 5 constant icf1 tifr1 icf1 2constant icf1-bit 29 | 3 constant ocf1c tifr1 ocf1c 2constant ocf1c-bit 30 | 2 constant ocf1b tifr1 ocf1b 2constant ocf1b-bit 31 | 1 constant ocf1a tifr1 ocf1a 2constant ocf1a-bit 32 | 0 constant tov1 tifr1 tov1 2constant tov1-bit 33 | $37 constant tifr2 34 | 1 constant ocf2a tifr2 ocf2a 2constant ocf2a-bit 35 | 0 constant tov2 tifr2 tov2 2constant tov2-bit 36 | $38 constant tifr3 37 | 5 constant icf3 tifr3 icf3 2constant icf3-bit 38 | 3 constant ocf3a tifr3 ocf3a 2constant ocf3a-bit 39 | 2 constant ocf3b tifr3 ocf3b 2constant ocf3b-bit 40 | 1 constant ocf3c tifr3 ocf3c 2constant ocf3c-bit 41 | 0 constant tov3 tifr3 tov3 2constant tov3-bit 42 | $3c constant eifr 43 | $3d constant eimsk 44 | $3e constant gpior0 45 | $3f constant eecr 46 | 3 constant eerie 47 | 2 constant eemwe 48 | 1 constant eewe 49 | 0 constant eere 50 | $40 constant eedr 51 | $41 constant eearl 52 | $42 constant eearh 53 | $43 constant gtccr 54 | 7 constant tsm 55 | 1 constant psr2 56 | 0 constant psr310 57 | $44 constant tccr0a 58 | 7 constant foc0a 59 | 6 constant wgm00 60 | 5 constant com0a1 61 | 4 constant com0a0 62 | 3 constant wgm01 63 | 2 constant cs02 64 | 1 constant cs01 65 | 0 constant cs00 66 | $46 constant tcnt0 67 | $47 constant ocr0a 68 | $4a constant gpior1 69 | $4b constant gpior2 70 | $4c constant spcr 71 | 7 constant spie 72 | 6 constant spe 73 | 5 constant dord 74 | 4 constant mstr 75 | 3 constant cpol 76 | 2 constant cpha 77 | 1 constant spr1 78 | 0 constant spr0 79 | $4d constant spsr 80 | 7 constant spif 81 | 6 constant wcol 82 | 0 constant spi2x 83 | $4e constant spdr 84 | $50 constant acsr 85 | 7 constant acd 86 | 6 constant acbg 87 | 5 constant aco 88 | 4 constant aci 89 | 3 constant acie 90 | 2 constant acic 91 | 1 constant acis1 92 | 0 constant acis0 93 | $51 constant ocdr 94 | $53 constant smcr 95 | 3 constant sm2 96 | 2 constant sm1 97 | 1 constant sm0 98 | 0 constant se 99 | $54 constant mcusr 100 | 4 constant jtrf 101 | 3 constant wdrf 102 | 2 constant borf 103 | 1 constant extrf 104 | 0 constant porf 105 | $55 constant mcucr 106 | 7 constant jtd 107 | 4 constant pud 108 | 1 constant ivsel 109 | 0 constant ivce 110 | $57 constant spmcsr 111 | 7 constant spmie 112 | 6 constant rwwsb 113 | 4 constant rwwsre 114 | 3 constant blbset 115 | 2 constant pgwrt 116 | 1 constant pgers 117 | 0 constant spmen 118 | $5b constant rampz 119 | $5d constant spl 120 | $5e constant sph 121 | $5f constant sreg 122 | $60 constant wdtcr 123 | 4 constant wdce 124 | 3 constant wde 125 | 2 constant wdp2 126 | 1 constant wdp1 127 | 0 constant wdp0 128 | $61 constant clkpr 129 | 7 constant clkpce 130 | 3 constant clkps3 131 | 2 constant clkps2 132 | 1 constant clkps1 133 | 0 constant clkps0 134 | $66 constant osccal 135 | $69 constant eicra 136 | $6a constant eicrb 137 | $6e constant timsk0 138 | 1 constant ocie0a timsk0 ocie0a 2constant ocie0a-bit 139 | 0 constant toie0 timsk0 toie0 2constant toie0-bit 140 | $6f constant timsk1 141 | 5 constant icie1 timsk1 icie1 2constant icie1-bit 142 | 3 constant ocie1c timsk1 ocie1c 2constant ocie1c-bit 143 | 2 constant ocie1b timsk1 ocie1b 2constant ocie1b-bit 144 | 1 constant ocie1a timsk1 ocie1a 2constant ocie1a-bit 145 | 0 constant toie1 timsk1 toie1 2constant toie1-bit 146 | $70 constant timsk2 147 | 1 constant ocie2a timsk2 ocie2a 2constant ocie2a-bit 148 | 0 constant toie2 timsk2 toie2 2constant toie2-bit 149 | $71 constant timsk3 150 | 5 constant icie3 timsk3 icie3 2constant icie3-bit 151 | 3 constant ocie3c timsk3 ocie3c 2constant ocie3c-bit 152 | 2 constant ocie3b timsk3 ocie3b 2constant ocie3b-bit 153 | 1 constant ocie3a timsk3 ocie3a 2constant ocie3a-bit 154 | 0 constant toie3 timsk3 toie3 2constant toie3-bit 155 | $74 constant xmcra 156 | 7 constant sre 157 | 6 constant srl2 158 | 5 constant srl1 159 | 4 constant srl0 160 | 3 constant srw11 161 | 2 constant srw10 162 | 1 constant srw01 163 | 0 constant srw00 164 | $75 constant xmcrb 165 | 7 constant xmbk 166 | 2 constant xmm2 167 | 1 constant xmm1 168 | 0 constant xmm0 169 | $78 constant adcl 170 | $79 constant adch 171 | $7a constant adcsra 172 | 7 constant aden 173 | 6 constant adsc 174 | 5 constant adate 175 | 4 constant adif 176 | 3 constant adie 177 | 2 constant adps2 178 | 1 constant adps1 179 | 0 constant adps0 180 | $7b constant adcsrb 181 | 7 constant adhsm 182 | 6 constant acme 183 | 2 constant adts2 184 | 1 constant adts1 185 | 0 constant adts0 186 | $7c constant admux 187 | 7 constant refs1 188 | 6 constant refs0 189 | 5 constant adlar 190 | 4 constant mux4 191 | 3 constant mux3 192 | 2 constant mux2 193 | 1 constant mux1 194 | 0 constant mux0 195 | $7e constant didr0 196 | $7f constant didr1 197 | $80 constant tccr1a 198 | 7 constant com1a1 199 | 6 constant com1a0 200 | 5 constant com1b1 201 | 4 constant com1b0 202 | 3 constant com1c1 203 | 2 constant com1c0 204 | 1 constant wgm11 205 | 0 constant wgm10 206 | $81 constant tccr1b 207 | 7 constant icnc1 208 | 6 constant ices1 209 | 4 constant wgm13 210 | 3 constant wgm12 211 | 2 constant cs12 212 | 1 constant cs11 213 | 0 constant cs10 214 | $82 constant tccr1c 215 | 7 constant foc1a 216 | 6 constant foc1b 217 | 5 constant foc1c 218 | $84 constant tcnt1l 219 | $85 constant tcnt1h 220 | $86 constant icr1l 221 | $87 constant icr1h 222 | $88 constant ocr1al 223 | $89 constant ocr1ah 224 | $8a constant ocr1bl 225 | $8b constant ocr1bh 226 | $8c constant ocr1cl 227 | $8d constant ocr1ch 228 | $90 constant tccr3a 229 | 7 constant com3a1 230 | 6 constant com3a0 231 | 5 constant com3b1 232 | 4 constant com3b0 233 | 3 constant com3c1 234 | 2 constant com3c0 235 | 1 constant wgm31 236 | 0 constant wgm30 237 | $91 constant tccr3b 238 | 7 constant icnc3 239 | 6 constant ices3 240 | 4 constant wgm33 241 | 3 constant wgm32 242 | 2 constant cs32 243 | 1 constant cs31 244 | 0 constant cs30 245 | $92 constant tccr3c 246 | 7 constant foc3a 247 | 6 constant foc3b 248 | 5 constant foc3c 249 | $94 constant tcnt3l 250 | $95 constant tcnt3h 251 | $96 constant icr3l 252 | $97 constant icr3h 253 | $98 constant ocr3al 254 | $99 constant ocr3ah 255 | $9a constant ocr3bl 256 | $9b constant ocr3bh 257 | $9c constant ocr3cl 258 | $9d constant ocr3ch 259 | $b0 constant tccr2a 260 | 7 constant foc2a 261 | 6 constant wgm20 262 | 5 constant com2a1 263 | 4 constant com2a0 264 | 3 constant wgm21 265 | 2 constant cs22 266 | 1 constant cs21 267 | 0 constant cs20 268 | $b2 constant tcnt2 269 | $b3 constant ocr2a 270 | $b6 constant assr 271 | 4 constant exclk 272 | 3 constant as2 273 | 2 constant tcn2ub 274 | 1 constant ocr2ub 275 | 0 constant tcr2ub 276 | $b8 constant twbr 277 | $b9 constant twsr 278 | $ba constant twar 279 | $bb constant twdr 280 | $bc constant twcr 281 | 7 constant twint 282 | 6 constant twea 283 | 5 constant twsta 284 | 4 constant twsto 285 | 3 constant twwc 286 | 2 constant twen 287 | 0 constant twie 288 | 289 | ( usart ) 290 | 291 | ( ucsra ) 292 | 7 constant rxc 293 | 6 constant txc 294 | 5 constant udre 295 | 4 constant fe 296 | 3 constant dor 297 | 2 constant upe 298 | 1 constant u2x 299 | 0 constant mpcm 300 | 301 | ( ucsrb ) 302 | 7 constant rxcie 303 | 6 constant txcie 304 | 5 constant udrie 305 | 4 constant rxen 306 | 3 constant txen 307 | 2 constant ucsz2 308 | 1 constant rxb8 309 | 0 constant txb8 310 | 311 | ( ucsrc ) 312 | 6 constant umsel 313 | 5 constant upm1 314 | 4 constant upm0 315 | 3 constant usbs 316 | 2 constant ucsz1 317 | 1 constant ucsz0 318 | 0 constant ucpol 319 | 320 | $c0 constant ucsr0a 321 | $c1 constant ucsr0b 322 | $c2 constant ucsr0c 323 | $c4 constant ubrr0l 324 | $c5 constant ubrr0h 325 | $c6 constant udr0 326 | 327 | $c8 constant ucsr1a 328 | $c9 constant ucsr1b 329 | $ca constant ucsr1c 330 | $cc constant ubrr1l 331 | $cd constant ubrr1h 332 | $ce constant udr1 333 | 334 | $d8 constant cangcon 335 | 7 constant abrq 336 | 6 constant ovrq 337 | 5 constant ttc 338 | 4 constant synttc 339 | 3 constant listen 340 | 2 constant test 341 | 1 constant enastb 342 | 0 constant swres 343 | $d9 constant cangsta 344 | 6 constant ovrg 345 | 4 constant txbsy 346 | 3 constant rxbsy 347 | 2 constant enfg 348 | 1 constant boff 349 | 0 constant errp 350 | $da constant cangit 351 | 7 constant canit 352 | 6 constant boffit 353 | 5 constant ovrtim 354 | 4 constant bxok 355 | 3 constant serg 356 | 2 constant cerg 357 | 1 constant ferg 358 | 0 constant aerg 359 | $db constant cangie 360 | 7 constant enit 361 | 6 constant enboff 362 | 5 constant enrx 363 | 4 constant entx 364 | 3 constant enerr 365 | 2 constant enbx 366 | 1 constant energ 367 | 0 constant enovrt 368 | $dc constant canen2 369 | $dd constant canen1 370 | $de constant canie2 371 | $df constant canie1 372 | $e0 constant cansit2 373 | $e1 constant cansit1 374 | $e2 constant canbt1 375 | 6 constant brp5 376 | 5 constant brp4 377 | 4 constant brp3 378 | 3 constant brp2 379 | 2 constant brp1 380 | 1 constant brp0 381 | $e3 constant canbt2 382 | 6 constant sjw1 383 | 5 constant sjw0 384 | 3 constant prs2 385 | 2 constant prs1 386 | 1 constant prs0 387 | $e4 constant canbt3 388 | 6 constant phs22 389 | 5 constant phs21 390 | 4 constant phs20 391 | 3 constant phs12 392 | 2 constant phs11 393 | 1 constant phs10 394 | 0 constant smp 395 | $e5 constant cantcon 396 | $e6 constant cantiml 397 | $e7 constant cantimh 398 | $e8 constant canttcl 399 | $e9 constant canttch 400 | $ea constant cantec 401 | $eb constant canrec 402 | $ec constant canhpmob 403 | 7 constant hpmob3 404 | 6 constant hpmob2 405 | 5 constant hpmob1 406 | 4 constant hpmob0 407 | 3 constant cgp3 408 | 2 constant cgp2 409 | 1 constant cgp1 410 | 0 constant cgp0 411 | $ed constant canpage 412 | 7 constant mobnb3 413 | 6 constant mobnb2 414 | 5 constant mobnb1 415 | 4 constant mobnb0 416 | 3 constant ainc 417 | 2 constant indx2 418 | 1 constant indx1 419 | 0 constant indx0 420 | $ee constant canstmob 421 | 7 constant dlcw 422 | 6 constant txok 423 | 5 constant rxok 424 | 4 constant berr 425 | 3 constant serr 426 | 2 constant cerr 427 | 1 constant ferr 428 | 0 constant aerr 429 | $ef constant cancdmob 430 | 7 constant conmob1 431 | 6 constant conmob0 432 | 5 constant rplv 433 | 4 constant ide 434 | 3 constant dlc3 435 | 2 constant dlc2 436 | 1 constant dlc1 437 | 0 constant dlc0 438 | $f0 constant canidt4 439 | 2 constant rtrtag 440 | 1 constant rb1tag 441 | 0 constant rb0tag 442 | $f1 constant canidt3 443 | $f2 constant canidt2 444 | $f3 constant canidt1 445 | $f4 constant canidm4 446 | $f5 constant canidm3 447 | $f6 constant canidm2 448 | $f7 constant canidm1 449 | $f8 constant canstml 450 | $f9 constant canstmh 451 | $fa constant canmsg 452 | 453 | ( spi pins ) 454 | ddrb 0 2constant ss-ddr 455 | ddrb 1 2constant sck-ddr 456 | ddrb 2 2constant mosi-ddr 457 | ddrb 3 2constant miso-ddr 458 | 459 | ( interrupt vectors ) 460 | $00 constant reset 461 | $02 constant external_interrupt_0 462 | $04 constant external_interrupt_1 463 | $06 constant external_interrupt_2 464 | $08 constant external_interrupt_3 465 | $0a constant external_interrupt_4 466 | $0c constant external_interrupt_5 467 | $0e constant external_interrupt_6 468 | $10 constant external_interrupt_7 469 | $12 constant timer2_compare_a 470 | $14 constant timer2_overflow 471 | $16 constant timer1_capture 472 | $18 constant timer1_compare_a 473 | $1a constant timer1_compare_b 474 | $1c constant timer1_compare_c 475 | $1e constant timer1_overflow 476 | $20 constant timer0_compare_a 477 | $22 constant timer0_overflow 478 | $24 constant can 479 | $26 constant can_overflow 480 | $28 constant spi_stc 481 | $2a constant usart0_rxc 482 | $2c constant usart0_udre 483 | $2e constant usart0_txc 484 | $30 constant analog_comparator 485 | $32 constant adc 486 | $34 constant eeprom_ready 487 | $36 constant timer3_capture 488 | $38 constant timer3_compare_a 489 | $3a constant timer3_compare_b 490 | $3c constant timer3_compare_c 491 | $3e constant timer3_overflow 492 | $40 constant usart1_rxc 493 | $42 constant usart1_udre 494 | $44 constant usart1_txc 495 | $46 constant twi 496 | $48 constant spm_ready 497 | 498 | $4a constant start 499 | 500 | -------------------------------------------------------------------------------- /asm/at90can128.f: -------------------------------------------------------------------------------- 1 | ( at90can128 ) 2 | 3 | $e0 constant iosize 4 | $1000 constant ramsize 5 | $10000 constant flashsize 6 | $1000 constant eepromsize 7 | $80 constant pagesize 8 | 9 | include at90can.f 10 | 11 | -------------------------------------------------------------------------------- /asm/at90can32.f: -------------------------------------------------------------------------------- 1 | ( at90can32 ) 2 | 3 | $e0 constant iosize 4 | $800 constant ramsize 5 | $4000 constant flashsize 6 | $400 constant eepromsize 7 | $80 constant pagesize 8 | 9 | include at90can.f 10 | 11 | -------------------------------------------------------------------------------- /asm/at90can64.f: -------------------------------------------------------------------------------- 1 | ( at90can64 ) 2 | 3 | $e0 constant iosize 4 | $1000 constant ramsize 5 | $8000 constant flashsize 6 | $800 constant eepromsize 7 | $80 constant pagesize 8 | 9 | include at90can.f 10 | 11 | -------------------------------------------------------------------------------- /asm/at90usb1287.f: -------------------------------------------------------------------------------- 1 | ( at90usb1287 ) 2 | 3 | $e0 constant iosize 4 | $2000 constant ramsize 5 | $10000 constant flashsize 6 | $1000 constant eepromsize 7 | $80 constant pagesize 8 | 9 | include at90usbx7.f 10 | 11 | -------------------------------------------------------------------------------- /asm/at90usb647.f: -------------------------------------------------------------------------------- 1 | ( at90usb647 ) 2 | 3 | $e0 constant iosize 4 | $1000 constant ramsize 5 | $8000 constant flashsize 6 | $800 constant eepromsize 7 | $80 constant pagesize 8 | 9 | include at90usbx7.f 10 | 11 | -------------------------------------------------------------------------------- /asm/at90usbx7.f: -------------------------------------------------------------------------------- 1 | ( at90usbx7 ) 2 | 3 | $20 constant pina 4 | $21 constant ddra 5 | $22 constant porta 6 | $23 constant pinb 7 | $24 constant ddrb 8 | $25 constant portb 9 | $26 constant pinc 10 | $27 constant ddrc 11 | $28 constant portc 12 | $29 constant pind 13 | $2a constant ddrd 14 | $2b constant portd 15 | $2c constant pine 16 | $2d constant ddre 17 | $2e constant porte 18 | $2f constant pinf 19 | $30 constant ddrf 20 | $31 constant portf 21 | $35 constant tifr0 22 | 2 constant ocf0b tifr0 ocf0b 2constant ocf0b-bit 23 | 1 constant ocf0a tifr0 ocf0a 2constant ocf0a-bit 24 | 0 constant tov0 tifr0 tov0 2constant tov0-bit 25 | $36 constant tifr1 26 | 5 constant icf1 tifr1 icf1 2constant icf1-bit 27 | 3 constant ocf1c tifr1 ocf1c 2constant ocf1c-bit 28 | 2 constant ocf1b tifr1 ocf1b 2constant ocf1b-bit 29 | 1 constant ocf1a tifr1 ocf1a 2constant ocf1a-bit 30 | 0 constant tov1 tifr1 tov1 2constant tov1-bit 31 | $37 constant tifr2 32 | 2 constant ocf2b tifr2 ocf2b 2constant ocf2b-bit 33 | 1 constant ocf2a tifr2 ocf2a 2constant ocf2a-bit 34 | 0 constant tov2 tifr2 tov2 2constant tov2-bit 35 | $38 constant tifr3 36 | 5 constant icf3 tifr3 icf3 2constant icf3-bit 37 | 3 constant ocf3c tifr3 ocf3c 2constant ocf3c-bit 38 | 2 constant ocf3b tifr3 ocf3b 2constant ocf3b-bit 39 | 1 constant ocf3a tifr3 ocf3a 2constant ocf3a-bit 40 | 0 constant tov3 tifr3 tov3 2constant tov3-bit 41 | $3b constant pcifr 42 | 0 constant pcif0 43 | $3c constant eifr 44 | $3d constant eimsk 45 | $3e constant gpior0 46 | $3f constant eecr 47 | 5 constant eepm1 48 | 4 constant eepm0 49 | 3 constant eerie 50 | 2 constant eempe 2 constant eemwe 51 | 1 constant eepe 1 constant eewe 52 | 0 constant eere 53 | $40 constant eedr 54 | $41 constant eearl 55 | $42 constant eearh 56 | $43 constant gtccr 57 | 7 constant tsm 58 | 1 constant psrasy 59 | 0 constant psrsync 60 | $44 constant tccr0a 61 | 7 constant com0a1 62 | 6 constant com0a0 63 | 5 constant com0b1 64 | 4 constant com0b0 65 | 1 constant wgm01 66 | 0 constant wgm00 67 | $45 constant tccr0b 68 | 7 constant foc0a 69 | 6 constant foc0b 70 | 3 constant wgm02 71 | 2 constant cs02 72 | 1 constant cs01 73 | 0 constant cs00 74 | $46 constant tcnt0 75 | $47 constant ocr0a 76 | $48 constant ocr0b 77 | $49 constant pllcsr 78 | 4 constant pllp2 79 | 3 constant pllp1 80 | 2 constant pllp0 81 | 1 constant plle 82 | 0 constant plock 83 | $4a constant gpior1 84 | $4b constant gpior2 85 | $4c constant spcr 86 | 7 constant spie 87 | 6 constant spe 88 | 5 constant dord 89 | 4 constant mstr 90 | 3 constant cpol 91 | 2 constant cpha 92 | 1 constant spr1 93 | 0 constant spr0 94 | $4d constant spsr 95 | 7 constant spif 96 | 6 constant wcol 97 | 0 constant spi2x 98 | $4e constant spdr 99 | $50 constant acsr 100 | 7 constant acd 101 | 6 constant acbg 102 | 5 constant aco 103 | 4 constant aci 104 | 3 constant acie 105 | 2 constant acic 106 | 1 constant acis1 107 | 0 constant acis0 108 | $51 constant ocdr 109 | $51 constant mondr 110 | $53 constant smcr 111 | 3 constant sm2 112 | 2 constant sm1 113 | 1 constant sm0 114 | 0 constant se 115 | $54 constant mcusr 116 | 4 constant jtrf 117 | 3 constant wdrf 118 | 2 constant borf 119 | 1 constant extrf 120 | 0 constant porf 121 | $55 constant mcucr 122 | 7 constant jtd 123 | 4 constant pud 124 | 1 constant ivsel 125 | 0 constant ivce 126 | $57 constant spmcsr 127 | 7 constant spmie 128 | 6 constant rwwsb 129 | 5 constant sigrd 130 | 4 constant rwwsre 131 | 3 constant blbset 132 | 2 constant pgwrt 133 | 1 constant pgers 134 | 0 constant spmen 135 | $5b constant rampz 136 | $5d constant spl 137 | $5e constant sph 138 | $5f constant sreg 139 | $60 constant wdtcsr 140 | 7 constant wdif 141 | 6 constant wdie 142 | 5 constant wdp3 143 | 4 constant wdce 144 | 3 constant wde 145 | 2 constant wdp2 146 | 1 constant wdp1 147 | 0 constant wdp0 148 | $61 constant clkpr 149 | 7 constant clkpce 150 | 3 constant clkps3 151 | 2 constant clkps2 152 | 1 constant clkps1 153 | 0 constant clkps0 154 | $64 constant prr0 155 | 7 constant prtwi 156 | 6 constant prtim2 157 | 5 constant prtim0 158 | 3 constant prtim1 159 | 2 constant prspi 160 | 0 constant pradc 161 | $65 constant prr1 162 | 7 constant prusb 163 | 3 constant prtim3 164 | 0 constant prusart1 165 | $66 constant osccal 166 | $68 constant pcicr 167 | 0 constant pcie0 168 | $69 constant eicra 169 | 7 constant isc31 170 | 6 constant isc30 171 | 5 constant isc21 172 | 4 constant isc20 173 | 3 constant isc11 174 | 2 constant isc10 175 | 1 constant isc01 176 | 0 constant isc00 177 | $6a constant eicrb 178 | 7 constant isc71 179 | 6 constant isc70 180 | 5 constant isc61 181 | 4 constant isc60 182 | 3 constant isc51 183 | 2 constant isc50 184 | 1 constant isc41 185 | 0 constant isc40 186 | $6b constant pcmsk0 187 | $6e constant timsk0 188 | 2 constant ocie0b timsk0 ocie0b 2constant ocie0b-bit 189 | 1 constant ocie0a timsk0 ocie0a 2constant ocie0a-bit 190 | 0 constant toie0 timsk0 toie0 2constant toie0-bit 191 | $6f constant timsk1 192 | 5 constant icie1 timsk1 icie1 2constant icie1-bit 193 | 3 constant ocie1c timsk1 ocie1c 2constant ocie1c-bit 194 | 2 constant ocie1b timsk1 ocie1b 2constant ocie1b-bit 195 | 1 constant ocie1a timsk1 ocie1a 2constant ocie1a-bit 196 | 0 constant toie1 timsk1 toie1 2constant toie1-bit 197 | $70 constant timsk2 198 | 2 constant ocie2b timsk2 ocie2b 2constant ocie2b-bit 199 | 1 constant ocie2a timsk2 ocie2a 2constant ocie2a-bit 200 | 0 constant toie2 timsk2 toie2 2constant toie2-bit 201 | $71 constant timsk3 202 | 5 constant icie3 timsk3 icie3 2constant icie3-bit 203 | 3 constant ocie3c timsk3 ocie3c 2constant ocie3c-bit 204 | 2 constant ocie3b timsk3 ocie3b 2constant ocie3b-bit 205 | 1 constant ocie3a timsk3 ocie3a 2constant ocie3a-bit 206 | 0 constant toie3 timsk3 toie3 2constant toie3-bit 207 | $74 constant xmcra 208 | 7 constant sre 209 | 6 constant srl2 210 | 5 constant srl1 211 | 4 constant srl0 212 | 3 constant srw11 213 | 2 constant srw10 214 | 1 constant srw01 215 | 0 constant srw00 216 | $75 constant xmcrb 217 | 7 constant xmbk 218 | 2 constant xmm2 219 | 1 constant xmm1 220 | 0 constant xmm0 221 | $78 constant adcl 222 | $79 constant adch 223 | $7a constant adcsra 224 | 7 constant aden 225 | 6 constant adsc 226 | 5 constant adate 227 | 4 constant adif 228 | 3 constant adie 229 | 2 constant adps2 230 | 1 constant adps1 231 | 0 constant adps0 232 | $7b constant adcsrb 233 | 7 constant adhsm 234 | 6 constant acme 235 | 2 constant adts2 236 | 1 constant adts1 237 | 0 constant adts0 238 | $7c constant admux 239 | 7 constant refs1 240 | 6 constant refs0 241 | 5 constant adlar 242 | 4 constant mux4 243 | 3 constant mux3 244 | 2 constant mux2 245 | 1 constant mux1 246 | 0 constant mux0 247 | $7e constant didr0 248 | $7f constant didr1 249 | $80 constant tccr1a 250 | 7 constant com1a1 251 | 6 constant com1a0 252 | 5 constant com1b1 253 | 4 constant com1b0 254 | 3 constant com1c1 255 | 2 constant com1c0 256 | 1 constant wgm11 257 | 0 constant wgm10 258 | $81 constant tccr1b 259 | 7 constant icnc1 260 | 6 constant ices1 261 | 4 constant wgm13 262 | 3 constant wgm12 263 | 2 constant cs12 264 | 1 constant cs11 265 | 0 constant cs10 266 | $82 constant tccr1c 267 | 7 constant foc1a 268 | 6 constant foc1b 269 | 5 constant foc1c 270 | $84 constant tcnt1l 271 | $85 constant tcnt1h 272 | $86 constant icr1l 273 | $87 constant icr1h 274 | $88 constant ocr1al 275 | $89 constant ocr1ah 276 | $8a constant ocr1bl 277 | $8b constant ocr1bh 278 | $8c constant ocr1cl 279 | $8d constant ocr1ch 280 | $90 constant tccr3a 281 | 7 constant com3a1 282 | 6 constant com3a0 283 | 5 constant com3b1 284 | 4 constant com3b0 285 | 3 constant com3c1 286 | 2 constant com3c0 287 | 1 constant wgm31 288 | 0 constant wgm30 289 | $91 constant tccr3b 290 | 7 constant icnc3 291 | 6 constant ices3 292 | 4 constant wgm33 293 | 3 constant wgm32 294 | 2 constant cs32 295 | 1 constant cs31 296 | 0 constant cs30 297 | $92 constant tccr3c 298 | 7 constant foc3a 299 | 6 constant foc3b 300 | 5 constant foc3c 301 | $94 constant tcnt3l 302 | $95 constant tcnt3h 303 | $96 constant icr3l 304 | $97 constant icr3h 305 | $98 constant ocr3al 306 | $99 constant ocr3ah 307 | $9a constant ocr3bl 308 | $9b constant ocr3bh 309 | $9c constant ocr3cl 310 | $9d constant ocr3ch 311 | $9e constant uhcon 312 | 2 constant resume 313 | 1 constant reset 314 | 0 constant sofen 315 | $9f constant uhint 316 | 6 constant hwupi 317 | 5 constant hsofi 318 | 4 constant rxrsmi 319 | 3 constant rsmedi 320 | 2 constant rsti 321 | 1 constant ddisci 322 | 0 constant dconni 323 | $a0 constant uhien 324 | 6 constant hwupe 325 | 5 constant hsofe 326 | 4 constant rxrsme 327 | 3 constant rsmede 328 | 2 constant rste 329 | 1 constant ddisce 330 | 0 constant dconne 331 | $a1 constant uhaddr 332 | 6 constant hadd6 333 | 5 constant hadd5 334 | 4 constant hadd4 335 | 3 constant hadd3 336 | 2 constant hadd2 337 | 1 constant hadd1 338 | 0 constant hadd0 339 | $a2 constant uhfnuml 340 | 7 constant fnum7 341 | 6 constant fnum6 342 | 5 constant fnum5 343 | 4 constant fnum4 344 | 3 constant fnum3 345 | 2 constant fnum2 346 | 1 constant fnum1 347 | 0 constant fnum0 348 | $a3 constant uhfnumh 349 | 2 constant fnum10 350 | 1 constant fnum9 351 | 2 constant fnum8 352 | $a4 constant uhflen 353 | 7 constant flen7 354 | 6 constant flen6 355 | 5 constant flen5 356 | 4 constant flen4 357 | 3 constant flen3 358 | 2 constant flen2 359 | 1 constant flen1 360 | 0 constant flen0 361 | $a5 constant upinrqx 362 | 7 constant inrq7 363 | 6 constant inrq6 364 | 5 constant inrq5 365 | 4 constant inrq4 366 | 3 constant inrq3 367 | 2 constant inrq2 368 | 1 constant inrq1 369 | 0 constant inrq0 370 | $a6 constant upintx 371 | 7 constant fifocon 372 | 6 constant nakedi 373 | 5 constant rwal 374 | 4 constant perri 375 | 3 constant txstpi 376 | 2 constant txouti 377 | 1 constant rxstalli 378 | 0 constant rxini 379 | $a7 constant upnum 380 | 2 constant pnum2 381 | 1 constant pnum1 382 | 0 constant pnum0 383 | $a8 constant uprst 384 | 6 constant prst6 385 | 5 constant prst5 386 | 4 constant prst4 387 | 3 constant prst3 388 | 2 constant prst2 389 | 1 constant prst1 390 | 0 constant prst0 391 | $a9 constant upconx 392 | 6 constant pfreeze 393 | 5 constant inmode 394 | 3 constant rstdt 395 | 0 constant pen 396 | $aa constant upcfg0x 397 | 7 constant ptype1 398 | 6 constant ptype0 399 | 5 constant ptoken1 400 | 4 constant ptoken0 401 | 3 constant pepnum3 402 | 2 constant pepnum2 403 | 1 constant pepnum1 404 | 0 constant pepnum0 405 | $ab constant upcfg1x 406 | 6 constant psize2 407 | 5 constant psize1 408 | 4 constant psize0 409 | 3 constant pbk1 410 | 2 constant pbk0 411 | 1 constant alloc 412 | $ac constant upstax 413 | 7 constant cfgok 414 | 6 constant overfi 415 | 5 constant underfi 416 | 3 constant dtseq1 417 | 2 constant dtseq0 418 | 1 constant nbusybk1 419 | 0 constant nbusybk0 420 | $ad constant upcfg2x 421 | 7 constant intfrq7 422 | 6 constant intfrq6 423 | 5 constant intfrq5 424 | 4 constant intfrq4 425 | 3 constant intfrq3 426 | 2 constant intfrq2 427 | 1 constant intfrq1 428 | 0 constant intfrq0 429 | $ae constant upienx 430 | 7 constant flerre 431 | 6 constant nakede 432 | 4 constant perre 433 | 3 constant txstpe 434 | 2 constant txoute 435 | 1 constant rxstalle 436 | 0 constant rxine 437 | $af constant updatx 438 | 7 constant pdat7 439 | 6 constant pdat6 440 | 5 constant pdat5 441 | 4 constant pdat4 442 | 3 constant pdat3 443 | 2 constant pdat2 444 | 1 constant pdat1 445 | 0 constant pdat0 446 | $b0 constant tccr2a 447 | 7 constant com2a1 448 | 6 constant com2a0 449 | 5 constant com2b1 450 | 4 constant com2b0 451 | 1 constant wgm21 452 | 0 constant wgm20 453 | $b1 constant tccr2b 454 | 7 constant foc2a 455 | 6 constant foc2b 456 | 3 constant wgm22 457 | 2 constant cs22 458 | 1 constant cs21 459 | 0 constant cs20 460 | $b2 constant tcnt2 461 | $b3 constant ocr2a 462 | $b4 constant ocr2b 463 | $b6 constant assr 464 | 6 constant exclk 465 | 5 constant as2 466 | 4 constant tcn2ub 467 | 3 constant ocr2aub 468 | 2 constant ocr2bub 469 | 1 constant tcr2aub 470 | 0 constant tcr2bub 471 | $b8 constant twbr 472 | $b9 constant twsr 473 | $ba constant twar 474 | $bb constant twdr 475 | $bc constant twcr 476 | 7 constant twint 477 | 6 constant twea 478 | 5 constant twsta 479 | 4 constant twsto 480 | 3 constant twwc 481 | 2 constant twen 482 | 0 constant twie 483 | $bd constant twamr 484 | 7 constant twam6 485 | 6 constant twam5 486 | 5 constant twam4 487 | 4 constant twam3 488 | 3 constant twam2 489 | 2 constant twam1 490 | 1 constant twam0 491 | $c8 constant ucsr1a 492 | 7 constant rxc 493 | 6 constant txc 494 | 5 constant udre 495 | 4 constant fe 496 | 3 constant dor 497 | 2 constant pe 498 | 1 constant u2x 499 | 0 constant mpcm 500 | $c9 constant ucsr1b 501 | 7 constant rxcie 502 | 6 constant txcie 503 | 5 constant udrie 504 | 4 constant rxen 505 | 3 constant txen 506 | 2 constant ucsz2 507 | 1 constant rxb8 508 | 0 constant txb8 509 | $ca constant ucsr1c 510 | 7 constant umsel1 511 | 6 constant umsel0 512 | 5 constant upm1 513 | 4 constant upm0 514 | 3 constant usbs 515 | 2 constant ucsz1 516 | 1 constant ucsz0 517 | 0 constant ucpol 518 | $cc constant ubrr1l 519 | $cd constant ubrr1h 520 | $ce constant udr1 521 | $d7 constant uhwcon 522 | 7 constant uimod 523 | 6 constant uide 524 | 4 constant uvcone 525 | 0 constant uvrege 526 | $d8 constant usbcon 527 | 7 constant usbe 528 | 6 constant host 529 | 5 constant frzclk 530 | 4 constant otgpade 531 | 1 constant idte 532 | 0 constant vbuste 533 | $d9 constant usbsta 534 | 3 constant speed 535 | 1 constant id 536 | 0 constant vbus 537 | $da constant usbint 538 | 1 constant idti 539 | 0 constant vbusti 540 | $dd constant otgcon 541 | 5 constant hnpreq 542 | 4 constant srpreq 543 | 3 constant srpsel 544 | 2 constant vbushwc 545 | 1 constant vbusreq 546 | 0 constant vbusrqc 547 | $de constant otgien 548 | 5 constant stoe 549 | 4 constant hnperre 550 | 3 constant roleexe 551 | 2 constant bcerre 552 | 1 constant vberre 553 | 0 constant srpe 554 | $df constant otgint 555 | 5 constant stoi 556 | 4 constant hnperri 557 | 3 constant roleexi 558 | 2 constant bcerri 559 | 1 constant vberri 560 | 0 constant srpi 561 | $e0 constant udcon 562 | 2 constant lsm 563 | 1 constant rmwkup 564 | 0 constant detach 565 | $e1 constant udint 566 | 6 constant uprsmi 567 | 5 constant eorsmi 568 | 4 constant wakeupi 569 | 3 constant eorsti 570 | 2 constant sofi 571 | 0 constant suspi 572 | $e2 constant udien 573 | 6 constant uprsme 574 | 5 constant eorsme 575 | 4 constant wakeupe 576 | 3 constant eorste 577 | 2 constant sofe 578 | 0 constant suspe 579 | $e3 constant udaddr 580 | 7 constant adden 581 | 6 constant uadd6 582 | 5 constant uadd5 583 | 4 constant uadd4 584 | 3 constant uadd3 585 | 2 constant uadd2 586 | 1 constant uadd1 587 | 0 constant uadd0 588 | $e4 constant udfnuml 589 | 7 constant fnum7 590 | 6 constant fnum6 591 | 5 constant fnum5 592 | 4 constant fnum4 593 | 3 constant fnum3 594 | 2 constant fnum2 595 | 1 constant fnum1 596 | 0 constant fnum0 597 | $e5 constant udfnumh 598 | 2 constant fnum10 599 | 1 constant fnum9 600 | 0 constant fnum8 601 | $e6 constant udmfn 602 | 4 constant fncerr 603 | $e8 constant ueintx 604 | 7 constant fifocon 605 | 6 constant nakini 606 | 5 constant rwal 607 | 4 constant nakouti 608 | 3 constant rxstpi 609 | 2 constant rxouti 610 | 1 constant stalledi 611 | 0 constant txini 612 | $e9 constant uenum 613 | 2 constant epnum2 614 | 1 constant epnum1 615 | 0 constant epnum0 616 | $ea constant uerst 617 | 6 constant eprst6 618 | 5 constant eprst5 619 | 4 constant eprst4 620 | 3 constant eprst3 621 | 2 constant eprst2 622 | 1 constant eprst1 623 | 0 constant eprst0 624 | $eb constant ueconx 625 | 5 constant stallrq 626 | 4 constant stallrqc 627 | 3 constant rstdt 628 | 0 constant epen 629 | $ec constant uecfg0x 630 | 7 constant eptype1 631 | 6 constant eptype0 632 | 0 constant epdir 633 | $ed constant uecfg1x 634 | 6 constant epsize2 635 | 5 constant epsize1 636 | 4 constant epsize0 637 | 3 constant epbk1 638 | 2 constant epbk0 639 | 1 constant alloc 640 | $ee constant uesta0x 641 | 7 constant cfgok 642 | 6 constant overfi 643 | 5 constant underfi 644 | 3 constant dtseq1 645 | 2 constant dtseq0 646 | 1 constant nbusybk1 647 | 0 constant nbusybk0 648 | $ef constant uesta1x 649 | 2 constant ctrldir 650 | 1 constant currbk1 651 | 0 constant currbk0 652 | $f0 constant ueienx 653 | 7 constant flerre 654 | 6 constant nakine 655 | 4 constant nakoute 656 | 3 constant rxstpe 657 | 2 constant rxoute 658 | 1 constant stallede 659 | 0 constant txine 660 | $f1 constant uedatx 661 | 7 constant dat7 662 | 6 constant dat6 663 | 5 constant dat5 664 | 4 constant dat4 665 | 3 constant dat3 666 | 2 constant dat2 667 | 1 constant dat1 668 | 0 constant dat0 669 | $f2 constant uebclx 670 | 7 constant byct7 671 | 6 constant byct6 672 | 5 constant byct5 673 | 4 constant byct4 674 | 3 constant byct3 675 | 2 constant byct2 676 | 1 constant byct1 677 | 0 constant byct0 678 | $f3 constant uebchx 679 | 2 constant byct10 680 | 1 constant byct9 681 | 0 constant byct8 682 | $f4 constant ueint 683 | 6 constant epint6 684 | 5 constant epint5 685 | 4 constant epint4 686 | 3 constant epint3 687 | 2 constant epint2 688 | 1 constant epint1 689 | 0 constant epint0 690 | $f5 constant uperrx 691 | 6 constant counter1 692 | 5 constant counter0 693 | 4 constant crc16 694 | 3 constant timeout 695 | 2 constant pid 696 | 1 constant datapid 697 | 0 constant datatgl 698 | $f6 constant upbclx 699 | 7 constant pbyct7 700 | 6 constant pbyct6 701 | 5 constant pbyct5 702 | 4 constant pbyct4 703 | 3 constant pbyct3 704 | 2 constant pbyct2 705 | 1 constant pbyct1 706 | 0 constant pbyct0 707 | $f7 constant upbchx 708 | 2 constant pbyct10 709 | 1 constant pbyct9 710 | 0 constant pbyct8 711 | $f8 constant upint 712 | 7 constant pint7 713 | 6 constant pint6 714 | 5 constant pint5 715 | 4 constant pint4 716 | 3 constant pint3 717 | 2 constant pint2 718 | 1 constant pint1 719 | 0 constant pint0 720 | $f9 constant otgtcon 721 | 6 constant page1 722 | 5 constant page0 723 | 1 constant value1 724 | 0 constant value0 725 | 726 | ( spi pins ) 727 | ddrb 0 2constant ss-ddr 728 | ddrb 1 2constant sck-ddr 729 | ddrb 2 2constant mosi-ddr 730 | ddrb 3 2constant miso-ddr 731 | 732 | ( interrupt vectors ) 733 | $00 constant reset 734 | $02 constant external_interrupt_0 735 | $04 constant external_interrupt_1 736 | $06 constant external_interrupt_2 737 | $08 constant external_interrupt_3 738 | $0a constant external_interrupt_4 739 | $0c constant external_interrupt_5 740 | $0e constant external_interrupt_6 741 | $10 constant external_interrupt_7 742 | $12 constant pin_change_interrupt_0 743 | $14 constant usb_general 744 | $16 constant usb_endpoint 745 | $18 constant wdt 746 | $1a constant timer2_compare_a 747 | $1c constant timer2_compare_b 748 | $1e constant timer2_overflow 749 | $20 constant timer1_capture 750 | $22 constant timer1_compare_a 751 | $24 constant timer1_compare_b 752 | $26 constant timer1_compare_c 753 | $28 constant timer1_overflow 754 | $2a constant timer0_compare_a 755 | $2c constant timer0_compare_b 756 | $2e constant timer0_overflow 757 | $30 constant spi_stc 758 | $32 constant usart1_rxc 759 | $34 constant usart1_udre 760 | $36 constant usart1_txc 761 | $38 constant analog_comparator 762 | $3a constant adc 763 | $3c constant eeprom_ready 764 | $3e constant timer3_capture 765 | $40 constant timer3_compare_a 766 | $42 constant timer3_compare_b 767 | $44 constant timer3_compare_c 768 | $46 constant timer3_overflow 769 | $48 constant twi 770 | $4a constant spm_ready 771 | 772 | $4c constant start 773 | 774 | -------------------------------------------------------------------------------- /asm/atmega128.f: -------------------------------------------------------------------------------- 1 | ( atmega128 ) 2 | 3 | $e0 constant iosize 4 | $1000 constant ramsize 5 | $10000 constant flashsize 6 | $1000 constant eepromsize 7 | $80 constant pagesize 8 | 9 | $20 constant pinf 10 | $21 constant pine 11 | $22 constant ddre 12 | $23 constant porte 13 | $24 constant adcl 14 | $25 constant adch 15 | $26 constant adcsra 16 | 7 constant aden 17 | 6 constant adsc 18 | 5 constant adfr 19 | 4 constant adif 20 | 3 constant adie 21 | 2 constant adps2 22 | 1 constant adps1 23 | 0 constant adps0 24 | $27 constant admux 25 | 7 constant refs1 26 | 6 constant refs0 27 | 5 constant adlar 28 | 4 constant mux4 29 | 3 constant mux3 30 | 2 constant mux2 31 | 1 constant mux1 32 | 0 constant mux0 33 | $28 constant acsr 34 | 7 constant acd 35 | 6 constant acbg 36 | 5 constant aco 37 | 4 constant aci 38 | 3 constant acie 39 | 2 constant acic 40 | 1 constant acis1 41 | 0 constant acis0 42 | $29 constant ubrr0l 43 | $2a constant ucsr0b 44 | $2b constant ucsr0a 45 | $2c constant udr0 46 | $2d constant spcr 47 | 7 constant spie 48 | 6 constant spe 49 | 5 constant dord 50 | 4 constant mstr 51 | 3 constant cpol 52 | 2 constant cpha 53 | 1 constant spr1 54 | 0 constant spr0 55 | $2e constant spsr 56 | 7 constant spif 57 | 6 constant wcol 58 | 0 constant spi2x 59 | $2f constant spdr 60 | $30 constant pind 61 | $31 constant ddrd 62 | $32 constant portd 63 | $33 constant pinc 64 | $34 constant ddrc 65 | $35 constant portc 66 | $36 constant pinb 67 | $37 constant ddrb 68 | $38 constant portb 69 | $39 constant pina 70 | $3a constant ddra 71 | $3b constant porta 72 | $3c constant eecr 73 | 3 constant eerie 74 | 2 constant eemwe 75 | 1 constant eewe 76 | 0 constant eere 77 | $3d constant eedr 78 | $3e constant eearl 79 | $3f constant eearh 80 | $40 constant sfior 81 | 7 constant tsm 82 | 3 constant acme 83 | 2 constant pud 84 | 1 constant psr0 85 | 0 constant psr321 86 | $41 constant wdtcr 87 | 4 constant wdce 88 | 3 constant wde 89 | 2 constant wdp2 90 | 1 constant wdp1 91 | 0 constant wdp0 92 | $42 constant ocdr 93 | $43 constant ocr2a 94 | $44 constant tcnt2 95 | $45 constant tccr2a 96 | 7 constant foc2 97 | 6 constant wgm20 98 | 5 constant com21 99 | 4 constant com20 100 | 3 constant wgm21 101 | 2 constant cs22 102 | 1 constant cs21 103 | 0 constant cs20 104 | $46 constant icr1l 105 | $47 constant icr1h 106 | $48 constant ocr1bl 107 | $49 constant ocr1bh 108 | $4a constant ocr1al 109 | $4b constant ocr1ah 110 | $4c constant tcnt1l 111 | $4d constant tcnt1h 112 | $4e constant tccr1b 113 | 7 constant icnc1 114 | 6 constant ices1 115 | 4 constant wgm13 116 | 3 constant wgm12 117 | 2 constant cs12 118 | 1 constant cs11 119 | 0 constant cs10 120 | $4f constant tccr1a 121 | 7 constant com1a1 122 | 6 constant com1a0 123 | 5 constant com1b1 124 | 4 constant com1b0 125 | 3 constant com1c1 126 | 2 constant com1c0 127 | 1 constant wgm11 128 | 0 constant wgm10 129 | $50 constant assr 130 | 3 constant as0 131 | 2 constant tcn0ub 132 | 1 constant ocr0ub 133 | 0 constant tcr0ub 134 | $51 constant ocr0a 135 | $52 constant tcnt0 136 | $53 constant tccr0a 137 | 7 constant foc0 138 | 6 constant wgm00 139 | 5 constant com01 140 | 4 constant com00 141 | 3 constant wgm01 142 | 2 constant cs02 143 | 1 constant cs01 144 | 0 constant cs00 145 | $54 constant mcucsr 146 | 7 constant jtd 147 | 4 constant jtrf 148 | 3 constant wdrf 149 | 2 constant borf 150 | 1 constant extrf 151 | 0 constant porf 152 | $55 constant mcucr 153 | 7 constant sre 154 | 6 constant srw10 155 | 5 constant se 156 | 4 constant sm1 157 | 3 constant sm0 158 | 2 constant sm2 159 | 1 constant ivsel 160 | 0 constant ivce 161 | $56 constant tifr 162 | 7 constant ocf2a tifr ocf2a 2constant ocf2a-bit 163 | 6 constant tov2 tifr tov2 2constant tov2-bit 164 | 5 constant icf1 tifr icf1 2constant icf1-bit 165 | 4 constant ocf1a tifr ocf1a 2constant ocf1a-bit 166 | 3 constant ocf1b tifr ocf1b 2constant ocf1b-bit 167 | 2 constant tov1 tifr tov1 2constant tov1-bit 168 | 1 constant ocf0a tifr ocf0a 2constant ocf0a-bit 169 | 0 constant tov0 tifr tov0 2constant tov0-bit 170 | $57 constant timsk 171 | 7 constant ocie2a timsk ocie2a 2constant ocie2a-bit 172 | 6 constant toie2 timsk toie2 2constant toie2-bit 173 | 5 constant icie1 timsk icie1 2constant icie1-bit 174 | 4 constant ocie1a timsk ocie1a 2constant ocie1a-bit 175 | 3 constant ocie1b timsk ocie1b 2constant ocie1b-bit 176 | 2 constant toie1 timsk toie1 2constant toie1-bit 177 | 1 constant ocie0a timsk ocie0a 2constant ocie0a-bit 178 | 0 constant toie0 timsk toie0 2constant toie0-bit 179 | $58 constant eifr 180 | $59 constant eimsk 181 | $5a constant eicrb 182 | 7 constant isc71 183 | 6 constant isc70 184 | 5 constant isc61 185 | 4 constant isc60 186 | 3 constant isc51 187 | 2 constant isc50 188 | 1 constant isc41 189 | 0 constant isc40 190 | $5b constant rampz 191 | $5c constant xdiv 192 | 7 constant xdiven 193 | 6 constant xdiv6 194 | 5 constant xdiv5 195 | 4 constant xdiv4 196 | 3 constant xdiv3 197 | 2 constant xdiv2 198 | 1 constant xdiv1 199 | 0 constant xdiv0 200 | $5d constant spl 201 | $5e constant sph 202 | $5f constant sreg 203 | $61 constant ddrf 204 | $62 constant portf 205 | $63 constant ping 206 | $64 constant ddrg 207 | $65 constant portg 208 | $68 constant spmcsr 209 | 7 constant spmie 210 | 6 constant rwwsb 211 | 4 constant rwwsre 212 | 3 constant blbset 213 | 2 constant pgwrt 214 | 1 constant pgers 215 | 0 constant spmen 216 | $6a constant eicra 217 | 7 constant isc31 218 | 6 constant isc30 219 | 5 constant isc21 220 | 4 constant isc20 221 | 3 constant isc11 222 | 2 constant isc10 223 | 1 constant isc01 224 | 0 constant isc00 225 | $6c constant xmcrb 226 | 7 constant xmbk 227 | 2 constant xmm2 228 | 1 constant xmm1 229 | 0 constant xmm0 230 | $6d constant xmcra 231 | 6 constant srl2 232 | 5 constant srl1 233 | 4 constant srl0 234 | 3 constant srw01 235 | 2 constant srw00 236 | 1 constant srw11 237 | $6f constant osccal 238 | $70 constant twbr 239 | $71 constant twsr 240 | $72 constant twar 241 | $73 constant twdr 242 | $74 constant twcr 243 | 7 constant twint 244 | 6 constant twea 245 | 5 constant twsta 246 | 4 constant twsto 247 | 3 constant twwc 248 | 2 constant twen 249 | 0 constant twie 250 | $78 constant ocr1cl 251 | $79 constant ocr1ch 252 | $7a constant tccr1c 253 | 7 constant foc1a 254 | 6 constant foc1b 255 | 5 constant foc1c 256 | $7c constant etifr 257 | 5 constant icf3 etifr icf3 2constant icf3-bit 258 | 4 constant ocf3a etifr ocf3a 2constant ocf3a-bit 259 | 3 constant ocf3b etifr ocf3b 2constant ocf3b-bit 260 | 2 constant tov3 etifr tov3 2constant tov3-bit 261 | 1 constant ocf3c etifr ocf3c 2constant ocf3c-bit 262 | 0 constant ocf1c etifr ocf1c 2constant ocf1c-bit 263 | $7d constant etimsk 264 | 5 constant icie3 etimsk icie3 2constant icie3-bit 265 | 4 constant ocie3a etimsk ocie3a 2constant ocie3a-bit 266 | 3 constant ocie3b etimsk ocie3b 2constant ocie3b-bit 267 | 2 constant toie3 etimsk toie3 2constant toie3-bit 268 | 1 constant ocie3c etimsk ocie3c 2constant ocie3c-bit 269 | 0 constant ocie1c etimsk ocie1c 2constant ocie1c-bit 270 | $80 constant icr3l 271 | $81 constant icr3h 272 | $82 constant ocr3cl 273 | $83 constant ocr3ch 274 | $84 constant ocr3bl 275 | $85 constant ocr3bh 276 | $86 constant ocr3al 277 | $87 constant ocr3ah 278 | $88 constant tcnt3l 279 | $89 constant tcnt3h 280 | $8a constant tccr3b 281 | 7 constant icnc3 282 | 6 constant ices3 283 | 4 constant wgm33 284 | 3 constant wgm32 285 | 2 constant cs32 286 | 1 constant cs31 287 | 0 constant cs30 288 | $8b constant tccr3a 289 | 7 constant com3a1 290 | 6 constant com3a0 291 | 5 constant com3b1 292 | 4 constant com3b0 293 | 3 constant com3c1 294 | 2 constant com3c0 295 | 1 constant wgm31 296 | 0 constant wgm30 297 | $8c constant tccr3c 298 | 7 constant foc3a 299 | 6 constant foc3b 300 | 5 constant foc3c 301 | 302 | ( usart ) 303 | 304 | ( ucsrc ) 305 | 6 constant umsel 306 | 5 constant upm1 307 | 4 constant upm0 308 | 3 constant usbs 309 | 2 constant ucsz1 310 | 1 constant ucsz0 311 | 0 constant ucpol 312 | 313 | ( ucsrb ) 314 | 7 constant rxcie 315 | 6 constant txcie 316 | 5 constant udrie 317 | 4 constant rxen 318 | 3 constant txen 319 | 2 constant ucsz2 320 | 1 constant rxb8 321 | 0 constant txb8 322 | 323 | ( ucsra ) 324 | 7 constant rxc 325 | 6 constant txc 326 | 5 constant udre 327 | 4 constant fe 328 | 3 constant dor 329 | 2 constant upe 330 | 1 constant u2x 331 | 0 constant mpcm 332 | 333 | $90 constant ubrr0h 334 | $95 constant ucsr0c 335 | $98 constant ubrr1h 336 | $99 constant ubrr1l 337 | $9a constant ucsr1b 338 | $9b constant ucsr1a 339 | $9c constant udr1 340 | $9d constant ucsr1c 341 | 342 | ( spi pins ) 343 | ddrb 0 2constant ss-ddr 344 | ddrb 1 2constant sck-ddr 345 | ddrb 2 2constant mosi-ddr 346 | ddrb 3 2constant miso-ddr 347 | 348 | ( interrupt vectors ) 349 | $00 constant reset 350 | $02 constant external_interrupt_0 351 | $04 constant external_interrupt_1 352 | $06 constant external_interrupt_2 353 | $08 constant external_interrupt_3 354 | $0a constant external_interrupt_4 355 | $0c constant external_interrupt_5 356 | $0e constant external_interrupt_6 357 | $10 constant external_interrupt_7 358 | $12 constant timer2_compare_a 359 | $14 constant timer2_overflow 360 | $16 constant timer1_capture 361 | $18 constant timer1_compare_a 362 | $1a constant timer1_compare_b 363 | $1c constant timer1_overflow 364 | $1e constant timer0_compare_a 365 | $20 constant timer0_overflow 366 | $22 constant spi_stc 367 | $24 constant usart0_rxc 368 | $26 constant usart0_udre 369 | $28 constant usart0_txc 370 | $2a constant adc 371 | $2c constant eeprom_ready 372 | $2e constant analog_comparator 373 | $30 constant timer1_compare_c 374 | $32 constant timer3_capture 375 | $34 constant timer3_compare_a 376 | $36 constant timer3_compare_b 377 | $38 constant timer3_compare_c 378 | $3a constant timer3_overflow 379 | $3c constant usart1_rxc 380 | $3e constant usart1_udre 381 | $40 constant usart1_txc 382 | $42 constant twi 383 | $44 constant spm_ready 384 | 385 | $46 constant start 386 | 387 | -------------------------------------------------------------------------------- /asm/atmega16.f: -------------------------------------------------------------------------------- 1 | ( atmega16 ) 2 | 3 | $40 constant iosize 4 | $400 constant ramsize 5 | $2000 constant flashsize 6 | $200 constant eepromsize 7 | $40 constant pagesize 8 | 9 | $20 constant twbr 10 | $21 constant twsr 11 | $22 constant twar 12 | $23 constant twdr 13 | $24 constant adcl 14 | $25 constant adch 15 | $26 constant adcsra 16 | 7 constant aden 17 | 6 constant adsc 18 | 5 constant adate 19 | 4 constant adif 20 | 3 constant adie 21 | 2 constant adps2 22 | 1 constant adps1 23 | 0 constant adps0 24 | $27 constant admux 25 | 7 constant refs1 26 | 6 constant refs0 27 | 5 constant adlar 28 | 4 constant mux4 29 | 3 constant mux3 30 | 2 constant mux2 31 | 1 constant mux1 32 | 0 constant mux0 33 | $28 constant acsr 34 | 7 constant acd 35 | 6 constant acbg 36 | 5 constant aco 37 | 4 constant aci 38 | 3 constant acie 39 | 2 constant acic 40 | 1 constant acis1 41 | 0 constant acis0 42 | $29 constant ubrr0l 43 | $2a constant ucsr0b 44 | 7 constant rxcie 45 | 6 constant txcie 46 | 5 constant udrie 47 | 4 constant rxen 48 | 3 constant txen 49 | 2 constant ucsz2 50 | 1 constant rxb8 51 | 0 constant txb8 52 | $2b constant ucsr0a 53 | 7 constant rxc 54 | 6 constant txc 55 | 5 constant udre 56 | 4 constant fe 57 | 3 constant dor 58 | 2 constant pe 59 | 1 constant u2x 60 | 0 constant mpcm 61 | $2c constant udr0 62 | $2d constant spcr 63 | 7 constant spie 64 | 6 constant spe 65 | 5 constant dord 66 | 4 constant mstr 67 | 3 constant cpol 68 | 2 constant cpha 69 | 1 constant spr1 70 | 0 constant spr0 71 | $2e constant spsr 72 | 7 constant spif 73 | 6 constant wcol 74 | 0 constant spi2x 75 | $2f constant spdr 76 | $30 constant pind 77 | $31 constant ddrd 78 | $32 constant portd 79 | $33 constant pinc 80 | $34 constant ddrc 81 | $35 constant portc 82 | $36 constant pinb 83 | $37 constant ddrb 84 | $38 constant portb 85 | $39 constant pina 86 | $3a constant ddra 87 | $3b constant porta 88 | $3c constant eecr 89 | 3 constant eerie 90 | 2 constant eemwe 91 | 1 constant eewe 92 | 0 constant eere 93 | $3d constant eedr 94 | $3e constant eearl 95 | $3f constant eearh 96 | $40 constant ucsr0c 97 | 7 constant ursel 98 | 6 constant umsel 99 | 5 constant upm1 100 | 4 constant upm0 101 | 3 constant usbs 102 | 2 constant ucsz1 103 | 1 constant ucsz0 104 | 0 constant ucpol 105 | $40 constant ubrr0h 106 | $41 constant wdtcr 107 | 4 constant wdtoe 108 | 3 constant wde 109 | 2 constant wdp2 110 | 1 constant wdp1 111 | 0 constant wdp0 112 | $42 constant assr 113 | 3 constant as2 114 | 2 constant tcn2ub 115 | 1 constant ocr2ub 116 | 0 constant tcr2ub 117 | $43 constant ocr2a 118 | $44 constant tcnt2 119 | $45 constant tccr2a 120 | 7 constant foc2 121 | 6 constant wgm20 122 | 5 constant com21 123 | 4 constant com20 124 | 3 constant wgm21 125 | 2 constant cs22 126 | 1 constant cs21 127 | 0 constant cs20 128 | $46 constant icr1l 129 | $47 constant icr1h 130 | $48 constant ocr1bl 131 | $49 constant ocr1bh 132 | $4a constant ocr1al 133 | $4b constant ocr1ah 134 | $4c constant tcnt1l 135 | $4d constant tcnt1h 136 | $4e constant tccr1b 137 | 7 constant icnc1 138 | 6 constant ices1 139 | 4 constant wgm13 140 | 3 constant wgm12 141 | 2 constant cs12 142 | 1 constant cs11 143 | 0 constant cs10 144 | $4f constant tccr1a 145 | 7 constant com1a1 146 | 6 constant com1a0 147 | 5 constant com1b1 148 | 4 constant com1b0 149 | 3 constant foc1a 150 | 2 constant foc1b 151 | 1 constant wgm11 152 | 0 constant wgm10 153 | $50 constant sfior 154 | 7 constant adts2 155 | 6 constant adts1 156 | 5 constant adts0 157 | 3 constant acme 158 | 2 constant pud 159 | 1 constant psr2 160 | 0 constant psr10 161 | $51 constant ocdr 162 | $51 constant osccal 163 | $52 constant tcnt0 164 | $53 constant tccr0a 165 | 7 constant foc0 166 | 6 constant wgm00 167 | 5 constant com01 168 | 4 constant com00 169 | 3 constant wgm01 170 | 2 constant cs02 171 | 1 constant cs01 172 | 0 constant cs00 173 | $54 constant mcucsr 174 | 7 constant jtd 175 | 6 constant isc2 176 | 4 constant jtrf 177 | 3 constant wdrf 178 | 2 constant borf 179 | 1 constant extrf 180 | 0 constant porf 181 | $55 constant mcucr 182 | 7 constant sm2 183 | 6 constant se 184 | 5 constant sm1 185 | 4 constant sm0 186 | 3 constant isc11 187 | 2 constant isc10 188 | 1 constant isc01 189 | 0 constant isc00 190 | $56 constant twcr 191 | 7 constant twint 192 | 6 constant twea 193 | 5 constant twsta 194 | 4 constant twsto 195 | 3 constant twwc 196 | 2 constant twen 197 | 0 constant twie 198 | $57 constant spmcsr 199 | 7 constant spmie 200 | 6 constant rwwsb 201 | 4 constant rwwsre 202 | 3 constant blbset 203 | 2 constant pgwrt 204 | 1 constant pgers 205 | 0 constant spmen 206 | $58 constant tifr 207 | 7 constant ocf2a tifr ocf2a 2constant ocf2a-bit 208 | 6 constant tov2 tifr tov2 2constant tov2-bit 209 | 5 constant icf1 tifr icf1 2constant icf1-bit 210 | 4 constant ocf1a tifr ocf1a 2constant ocf1a-bit 211 | 3 constant ocf1b tifr ocf1b 2constant ocf1b-bit 212 | 2 constant tov1 tifr tov1 2constant tov1-bit 213 | 1 constant ocf0a tifr ocf0a 2constant ocf0a-bit 214 | 0 constant tov0 tifr tov0 2constant tov0-bit 215 | $59 constant timsk 216 | 7 constant ocie2a timsk ocie2a 2constant ocie2a-bit 217 | 6 constant toie2 timsk toie2 2constant toie2-bit 218 | 5 constant icie1 timsk icie1 2constant icie1-bit 219 | 4 constant ocie1a timsk ocie1a 2constant ocie1a-bit 220 | 3 constant ocie1b timsk ocie1b 2constant ocie1b-bit 221 | 2 constant toie1 timsk toie1 2constant toie1-bit 222 | 1 constant ocie0a timsk ocie0a 2constant ocie0a-bit 223 | 0 constant toie0 timsk toie0 2constant toie0-bit 224 | $5a constant gifr 225 | 7 constant intf1 226 | 6 constant intf0 227 | 5 constant intf2 228 | $5b constant gicr 229 | 7 constant int1 230 | 6 constant int0 231 | 5 constant int2 232 | 1 constant ivsel 233 | 0 constant ivce 234 | $5c constant ocr0a 235 | $5d constant spl 236 | $5e constant sph 237 | $5f constant sreg 238 | 239 | ( spi pins ) 240 | ddrb 4 2constant ss-ddr 241 | ddrb 7 2constant sck-ddr 242 | ddrb 5 2constant mosi-ddr 243 | ddrb 6 2constant miso-ddr 244 | 245 | ( interrupt vectors ) 246 | $00 constant reset 247 | $02 constant external_interrupt_0 248 | $04 constant external_interrupt_1 249 | $06 constant timer2_compare_a 250 | $08 constant timer2_overflow 251 | $0a constant timer1_capture 252 | $0c constant timer1_compare_a 253 | $0e constant timer1_compare_b 254 | $10 constant timer1_overflow 255 | $12 constant timer0_overflow 256 | $14 constant spi_stc 257 | $16 constant usart0_rxc 258 | $18 constant usart0_udre 259 | $1a constant usart0_txc 260 | $1c constant adc 261 | $1e constant eeprom_ready 262 | $20 constant analog_comparator 263 | $22 constant twi 264 | $24 constant external_interrupt_2 265 | $26 constant timer0_compare_a 266 | $28 constant spm_ready 267 | 268 | $2a constant start 269 | 270 | -------------------------------------------------------------------------------- /asm/atmega162.f: -------------------------------------------------------------------------------- 1 | ( atmega162 ) 2 | 3 | $e0 constant iosize 4 | $400 constant ramsize 5 | $2000 constant flashsize 6 | $200 constant eepromsize 7 | $40 constant pagesize 8 | 9 | ( usart ) 10 | 11 | ( ucsrc ) 12 | 7 constant ursel 13 | 6 constant umsel 14 | 5 constant upm1 15 | 4 constant upm0 16 | 3 constant usbs 17 | 2 constant ucsz1 18 | 1 constant ucsz0 19 | 0 constant ucpol 20 | 21 | ( ucsrb ) 22 | 7 constant rxcie 23 | 6 constant txcie 24 | 5 constant udrie 25 | 4 constant rxen 26 | 3 constant txen 27 | 2 constant ucsz2 28 | 1 constant rxb8 29 | 0 constant txb8 30 | 31 | ( ucsra ) 32 | 7 constant rxc 33 | 6 constant txc 34 | 5 constant udre 35 | 4 constant fe 36 | 3 constant dor 37 | 2 constant upe 38 | 1 constant u2x 39 | 0 constant mpcm 40 | 41 | $20 constant ubrr1l 42 | $21 constant ucsr1b 43 | $22 constant ucsr1a 44 | $23 constant udr1 45 | $24 constant ocdr 46 | $24 constant osccal 47 | $25 constant pine 48 | $26 constant ddre 49 | $27 constant porte 50 | $28 constant acsr 51 | 7 constant acd 52 | 6 constant acbg 53 | 5 constant aco 54 | 4 constant aci 55 | 3 constant acie 56 | 2 constant acic 57 | 1 constant acis1 58 | 0 constant acis0 59 | $29 constant ubrr0l 60 | $2a constant ucsr0b 61 | $2b constant ucsr0a 62 | $2c constant udr0 63 | $2d constant spcr 64 | 7 constant spie 65 | 6 constant spe 66 | 5 constant dord 67 | 4 constant mstr 68 | 3 constant cpol 69 | 2 constant cpha 70 | 1 constant spr1 71 | 0 constant spr0 72 | $2e constant spsr 73 | 7 constant spif 74 | 6 constant wcol 75 | 0 constant spi2x 76 | $2f constant spdr 77 | $30 constant pind 78 | $31 constant ddrd 79 | $32 constant portd 80 | $33 constant pinc 81 | $34 constant ddrc 82 | $35 constant portc 83 | $36 constant pinb 84 | $37 constant ddrb 85 | $38 constant portb 86 | $39 constant pina 87 | $3a constant ddra 88 | $3b constant porta 89 | $3c constant eecr 90 | 3 constant eerie 91 | 2 constant eemwe 92 | 1 constant eewe 93 | 0 constant eere 94 | $3d constant eedr 95 | $3e constant eearl 96 | $3f constant eearh 97 | $40 constant ucsr0c 98 | $40 constant ubrr0h 99 | $41 constant wdtcr 100 | 4 constant wdce 101 | 3 constant wde 102 | 2 constant wdp2 103 | 1 constant wdp1 104 | 0 constant wdp0 105 | $42 constant ocr2a 106 | $43 constant tcnt2 107 | $44 constant icr1l 108 | $45 constant icr1h 109 | $46 constant assr 110 | 3 constant as2 111 | 2 constant tcn2ub 112 | 1 constant ocr2ub 113 | 0 constant tcr2ub 114 | $47 constant tccr2a 115 | 7 constant foc2 116 | 6 constant wgm20 117 | 5 constant com21 118 | 4 constant com20 119 | 3 constant wgm21 120 | 2 constant cs22 121 | 1 constant cs21 122 | 0 constant cs20 123 | $48 constant ocr1bl 124 | $49 constant ocr1bh 125 | $4a constant ocr1al 126 | $4b constant ocr1ah 127 | $4c constant tcnt1l 128 | $4d constant tcnt1h 129 | $4e constant tccr1b 130 | 7 constant icnc1 131 | 6 constant ices1 132 | 4 constant wgm13 133 | 3 constant wgm12 134 | 2 constant cs12 135 | 1 constant cs11 136 | 0 constant cs10 137 | $4f constant tccr1a 138 | 7 constant com1a1 139 | 6 constant com1a0 140 | 5 constant com1b1 141 | 4 constant com1b0 142 | 3 constant foc1a 143 | 2 constant foc1b 144 | 1 constant wgm11 145 | 0 constant wgm10 146 | $50 constant sfior 147 | 7 constant tsm 148 | 6 constant xmbk 149 | 5 constant xmm2 150 | 4 constant xmm1 151 | 3 constant xmm0 152 | 2 constant pud 153 | 1 constant psr2 154 | 0 constant psr310 155 | $51 constant ocr0a 156 | $52 constant tcnt0 157 | $53 constant tccr0a 158 | 7 constant foc0 159 | 6 constant wgm00 160 | 5 constant com01 161 | 4 constant com00 162 | 3 constant wgm01 163 | 2 constant cs02 164 | 1 constant cs01 165 | 0 constant cs00 166 | $54 constant mcucsr 167 | 7 constant jtd 168 | 5 constant sm2 169 | 4 constant jtrf 170 | 3 constant wdrf 171 | 2 constant borf 172 | 1 constant extrf 173 | 0 constant porf 174 | $55 constant mcucr 175 | 7 constant sre 176 | 6 constant srw10 177 | 5 constant se 178 | 4 constant sm1 179 | 3 constant isc11 180 | 2 constant isc10 181 | 1 constant isc01 182 | 0 constant isc00 183 | $56 constant emcucr 184 | 7 constant sm0 185 | 6 constant srl2 186 | 5 constant srl1 187 | 4 constant srl0 188 | 3 constant srw01 189 | 2 constant srw00 190 | 1 constant srw11 191 | 0 constant isc2 192 | $57 constant spmcsr 193 | 7 constant spmie 194 | 6 constant rwwsb 195 | 4 constant rwwsre 196 | 3 constant blbset 197 | 2 constant pgwrt 198 | 1 constant pgers 199 | 0 constant spmen 200 | $58 constant tifr 201 | 7 constant tov1 tifr tov1 2constant tov1-bit 202 | 6 constant ocf1a tifr ocf1a 2constant ocf1a-bit 203 | 5 constant ocf1b tifr ocf1b 2constant ocf1b-bit 204 | 4 constant ocf2a tifr ocf2a 2constant ocf2a-bit 205 | 3 constant icf1 tifr icf1 2constant icf1-bit 206 | 2 constant tov2 tifr tov2 2constant tov2-bit 207 | 1 constant tov0 tifr tov0 2constant tov0-bit 208 | 0 constant ocf0a tifr ocf0a 2constant ocf0a-bit 209 | $59 constant timsk 210 | 7 constant toie1 timsk toie1 2constant toie1-bit 211 | 6 constant ocie1a timsk ocie1a 2constant ocie1a-bit 212 | 5 constant ocie1b timsk ocie1b 2constant ocie1b-bit 213 | 4 constant ocie2a timsk ocie2a 2constant ocie2a-bit 214 | 3 constant icie1 timsk icie1 2constant icie1-bit 215 | 2 constant toie2 timsk toie2 2constant toie2-bit 216 | 1 constant toie0 timsk toie0 2constant toie0-bit 217 | 0 constant ocie0a timsk ocie0a 2constant ocie0a-bit 218 | $5a constant gifr 219 | 7 constant intf1 220 | 6 constant intf0 221 | 5 constant intf2 222 | 4 constant pcif1 223 | 3 constant pcif0 224 | $5b constant gicr 225 | 7 constant int1 226 | 6 constant int0 227 | 5 constant int2 228 | 4 constant pcie1 229 | 3 constant pcie0 230 | 1 constant ivsel 231 | 0 constant ivce 232 | $5c constant ucsrc 233 | $5c constant ubrr1h 234 | $5d constant spl 235 | $5e constant sph 236 | $5f constant sreg 237 | $61 constant clkpr 238 | 7 constant clkpce 239 | 3 constant clkps3 240 | 2 constant clkps2 241 | 1 constant clkps1 242 | 0 constant clkps0 243 | $6b constant pcmsk0 244 | $6c constant pcmsk1 245 | $7c constant etifr 246 | 5 constant icf3 etifr icf3 2constant icf3-bit 247 | 4 constant ocf3a etifr ocf3a 2constant ocf3a-bit 248 | 3 constant ocf3b etifr ocf3b 2constant ocf3b-bit 249 | 2 constant tov3 etifr tov3 2constant tov3-bit 250 | $7d constant etimsk 251 | 5 constant icie3 etimsk icie3 2constant icie3-bit 252 | 4 constant ocie3a etimsk ocie3a 2constant ocie3a-bit 253 | 3 constant ocie3b etimsk ocie3b 2constant ocie3b-bit 254 | 2 constant toie3 etimsk toie3 2constant toie3-bit 255 | $80 constant icr3l 256 | $81 constant icr3h 257 | $84 constant ocr3bl 258 | $85 constant ocr3bh 259 | $86 constant ocr3al 260 | $87 constant ocr3ah 261 | $88 constant tcnt3l 262 | $89 constant tcnt3h 263 | $8a constant tccr3b 264 | 7 constant icnc3 265 | 6 constant ices3 266 | 4 constant wgm33 267 | 3 constant wgm32 268 | 2 constant cs32 269 | 1 constant cs31 270 | 0 constant cs30 271 | $8b constant tccr3a 272 | 7 constant com3a1 273 | 6 constant com3a0 274 | 5 constant com3b1 275 | 4 constant com3b0 276 | 3 constant foc3a 277 | 2 constant foc3b 278 | 1 constant wgm31 279 | 0 constant wgm30 280 | 281 | ( spi pins ) 282 | ddrb 4 2constant ss-ddr 283 | ddrb 7 2constant sck-ddr 284 | ddrb 5 2constant mosi-ddr 285 | ddrb 6 2constant miso-ddr 286 | 287 | ( interrupt vectors ) 288 | $00 constant reset 289 | $02 constant external_interrupt_0 290 | $04 constant external_interrupt_1 291 | $06 constant external_interrupt_2 292 | $08 constant pcint0 293 | $0a constant pcint1 294 | $0c constant timer3_capture 295 | $0e constant timer3_compare_a 296 | $10 constant timer3_compare_b 297 | $12 constant timer3_overflow 298 | $14 constant timer2_compare_a 299 | $16 constant timer2_overflow 300 | $18 constant timer1_capture 301 | $1a constant timer1_compare_a 302 | $1c constant timer1_compare_b 303 | $1e constant timer1_overflow 304 | $20 constant timer0_compare_a 305 | $22 constant timer0_overflow 306 | $24 constant spi_stc 307 | $26 constant usart0_rxc 308 | $28 constant usart1_rxc 309 | $2a constant usart0_udre 310 | $2c constant usart1_udre 311 | $2e constant usart0_txc 312 | $30 constant usart1_txc 313 | $32 constant eeprom_ready 314 | $34 constant analog_comparator 315 | $36 constant spm_ready 316 | 317 | $38 constant start 318 | 319 | -------------------------------------------------------------------------------- /asm/atmega168.f: -------------------------------------------------------------------------------- 1 | ( atmega168 ) 2 | 3 | $e0 constant iosize 4 | $400 constant ramsize 5 | $2000 constant flashsize 6 | $200 constant eepromsize 7 | $40 constant pagesize 8 | $2 constant vectorsize 9 | 10 | include atmegax8.f 11 | 12 | -------------------------------------------------------------------------------- /asm/atmega32.f: -------------------------------------------------------------------------------- 1 | ( atmega32 ) 2 | 3 | $40 constant iosize 4 | $800 constant ramsize 5 | $4000 constant flashsize 6 | $400 constant eepromsize 7 | $40 constant pagesize 8 | 9 | $20 constant twbr 10 | $21 constant twsr 11 | 7 constant tws7 12 | 6 constant tws6 13 | 5 constant tws5 14 | 4 constant tws4 15 | 3 constant tws3 16 | 1 constant twps1 17 | 0 constant twps0 18 | $22 constant twar 19 | 7 constant twa6 20 | 6 constant twa5 21 | 5 constant twa4 22 | 4 constant twa3 23 | 3 constant twa2 24 | 2 constant twa1 25 | 1 constant twa0 26 | 0 constant twgce 27 | $23 constant twdr 28 | $24 constant adcl 29 | $25 constant adch 30 | $26 constant adcsra 31 | 7 constant aden 32 | 6 constant adsc 33 | 5 constant adate 34 | 4 constant adif 35 | 3 constant adie 36 | 2 constant adps2 37 | 1 constant adps1 38 | 0 constant adps0 39 | $27 constant admux 40 | 7 constant refs1 41 | 6 constant refs0 42 | 5 constant adlar 43 | 4 constant mux4 44 | 3 constant mux3 45 | 2 constant mux2 46 | 1 constant mux1 47 | 0 constant mux0 48 | $28 constant acsr 49 | 7 constant acd 50 | 6 constant acbg 51 | 5 constant aco 52 | 4 constant aci 53 | 3 constant acie 54 | 2 constant acic 55 | 1 constant acis1 56 | 0 constant acis0 57 | $29 constant ubrr0l 58 | $2a constant ucsr0b 59 | 7 constant rxcie 60 | 6 constant txcie 61 | 5 constant udrie 62 | 4 constant rxen 63 | 3 constant txen 64 | 2 constant ucsz2 65 | 1 constant rxb8 66 | 0 constant txb8 67 | $2b constant ucsr0a 68 | 7 constant rxc 69 | 6 constant txc 70 | 5 constant udre 71 | 4 constant fe 72 | 3 constant dor 73 | 2 constant pe 74 | 1 constant u2x 75 | 0 constant mpcm 76 | $2c constant udr0 77 | $2d constant spcr 78 | 7 constant spie 79 | 6 constant spe 80 | 5 constant dord 81 | 4 constant mstr 82 | 3 constant cpol 83 | 2 constant cpha 84 | 1 constant spr1 85 | 0 constant spr0 86 | $2e constant spsr 87 | 7 constant spif 88 | 6 constant wcol 89 | 0 constant spi2x 90 | $2f constant spdr 91 | $30 constant pind 92 | $31 constant ddrd 93 | $32 constant portd 94 | $33 constant pinc 95 | $34 constant ddrc 96 | $35 constant portc 97 | $36 constant pinb 98 | $37 constant ddrb 99 | $38 constant portb 100 | $39 constant pina 101 | $3a constant ddra 102 | $3b constant porta 103 | $3c constant eecr 104 | 3 constant eerie 105 | 2 constant eemwe 106 | 1 constant eewe 107 | 0 constant eere 108 | $3d constant eedr 109 | $3e constant eearl 110 | $3f constant eearh 111 | $40 constant ucsr0c 112 | 7 constant ursel 113 | 6 constant umsel 114 | 5 constant upm1 115 | 4 constant upm0 116 | 3 constant usbs 117 | 2 constant ucsz1 118 | 1 constant ucsz0 119 | 0 constant ucpol 120 | $40 constant ubrr0h 121 | 7 constant ursel 122 | 3 constant ubrr11 123 | 2 constant ubrr10 124 | 1 constant ubrr9 125 | 0 constant ubrr8 126 | $41 constant wdtcr 127 | 4 constant wdtoe 128 | 3 constant wde 129 | 2 constant wdp2 130 | 1 constant wdp1 131 | 0 constant wdp0 132 | $42 constant assr 133 | 3 constant as2 134 | 2 constant tcn2ub 135 | 1 constant ocr2ub 136 | 0 constant tcr2ub 137 | $43 constant ocr2a 138 | $44 constant tcnt2 139 | $45 constant tccr2a 140 | 7 constant foc2 141 | 6 constant wgm20 142 | 5 constant com21 143 | 4 constant com20 144 | 3 constant wgm21 145 | 2 constant cs22 146 | 1 constant cs21 147 | 0 constant cs20 148 | $46 constant icr1l 149 | $47 constant icr1h 150 | $48 constant ocr1bl 151 | $49 constant ocr1bh 152 | $4a constant ocr1al 153 | $4b constant ocr1ah 154 | $4c constant tcnt1l 155 | $4d constant tcnt1h 156 | $4e constant tccr1b 157 | 7 constant icnc1 158 | 6 constant ices1 159 | 4 constant wgm13 160 | 3 constant wgm12 161 | 2 constant cs12 162 | 1 constant cs11 163 | 0 constant cs10 164 | $4f constant tccr1a 165 | 7 constant com1a1 166 | 6 constant com1a0 167 | 5 constant com1b1 168 | 4 constant com1b0 169 | 3 constant foc1a 170 | 2 constant foc1b 171 | 1 constant wgm11 172 | 0 constant wgm10 173 | $50 constant sfior 174 | 7 constant adts2 175 | 6 constant adts1 176 | 5 constant adts0 177 | 3 constant acme 178 | 2 constant pud 179 | 1 constant psr2 180 | 0 constant psr10 181 | $51 constant ocdr 182 | $51 constant osccal 183 | $52 constant tcnt0 184 | $53 constant tccr0a 185 | 7 constant foc0 186 | 6 constant wgm00 187 | 5 constant com01 188 | 4 constant com00 189 | 3 constant wgm01 190 | 2 constant cs02 191 | 1 constant cs01 192 | 0 constant cs00 193 | $54 constant mcucsr 194 | 7 constant jtd 195 | 6 constant isc2 196 | 4 constant jtrf 197 | 3 constant wdrf 198 | 2 constant borf 199 | 1 constant extrf 200 | 0 constant porf 201 | $55 constant mcucr 202 | 7 constant se 203 | 6 constant sm2 204 | 5 constant sm1 205 | 4 constant sm0 206 | 3 constant isc11 207 | 2 constant isc10 208 | 1 constant isc01 209 | 0 constant isc00 210 | $56 constant twcr 211 | 7 constant twint 212 | 6 constant twea 213 | 5 constant twsta 214 | 4 constant twsto 215 | 3 constant twwc 216 | 2 constant twen 217 | 0 constant twie 218 | $57 constant spmcsr 219 | 7 constant spmie 220 | 6 constant rwwsb 221 | 4 constant rwwsre 222 | 3 constant blbset 223 | 2 constant pgwrt 224 | 1 constant pgers 225 | 0 constant spmen 226 | $58 constant tifr 227 | 7 constant ocf2a tifr ocf2a 2constant ocf2a-bit 228 | 6 constant tov2 tifr tov2 2constant tov2-bit 229 | 5 constant icf1 tifr icf1 2constant icf1-bit 230 | 4 constant ocf1a tifr ocf1a 2constant ocf1a-bit 231 | 3 constant ocf1b tifr ocf1b 2constant ocf1b-bit 232 | 2 constant tov1 tifr tov1 2constant tov1-bit 233 | 1 constant ocf0a tifr ocf0a 2constant ocf0a-bit 234 | 0 constant tov0 tifr tov0 2constant tov0-bit 235 | $59 constant timsk 236 | 7 constant ocie2a timsk ocie2a 2constant ocie2a-bit 237 | 6 constant toie2 timsk toie2 2constant toie2-bit 238 | 5 constant icie1 timsk icie1 2constant icie1-bit 239 | 4 constant ocie1a timsk ocie1a 2constant ocie1a-bit 240 | 3 constant ocie1b timsk ocie1b 2constant ocie1b-bit 241 | 2 constant toie1 timsk toie1 2constant toie1-bit 242 | 1 constant ocie0a timsk ocie0a 2constant ocie0a-bit 243 | 0 constant toie0 timsk toie0 2constant toie0-bit 244 | $5a constant gifr 245 | 7 constant intf1 246 | 6 constant intf0 247 | 5 constant intf2 248 | $5b constant gicr 249 | 7 constant int1 250 | 6 constant int0 251 | 5 constant int2 252 | 1 constant ivsel 253 | 0 constant ivce 254 | $5c constant ocr0a 255 | $5d constant spl 256 | $5e constant sph 257 | $5f constant sreg 258 | 259 | ( spi pins ) 260 | ddrb 4 2constant ss-ddr 261 | ddrb 7 2constant sck-ddr 262 | ddrb 5 2constant mosi-ddr 263 | ddrb 6 2constant miso-ddr 264 | 265 | ( interrupt vectors ) 266 | $00 constant reset 267 | $02 constant external_interrupt_0 268 | $04 constant external_interrupt_1 269 | $06 constant external_interrupt_2 270 | $08 constant timer2_compare_a 271 | $0a constant timer2_overflow 272 | $0c constant timer1_capture 273 | $0e constant timer1_compare_a 274 | $10 constant timer1_compare_b 275 | $12 constant timer1_overflow 276 | $14 constant timer0_compare_a 277 | $16 constant timer0_overflow 278 | $18 constant spi_stc 279 | $1a constant usart0_rxc 280 | $1c constant usart0_udre 281 | $1e constant usart0_txc 282 | $20 constant adc 283 | $22 constant eeprom_ready 284 | $24 constant analog_comparator 285 | $26 constant twi 286 | $28 constant spm_ready 287 | 288 | $2a constant start 289 | 290 | -------------------------------------------------------------------------------- /asm/atmega328p.f: -------------------------------------------------------------------------------- 1 | ( atmega328p ) 2 | 3 | $e0 constant iosize 4 | $800 constant ramsize 5 | $4000 constant flashsize 6 | $400 constant eepromsize 7 | $40 constant pagesize 8 | $2 constant vectorsize 9 | 10 | include atmegax8.f 11 | -------------------------------------------------------------------------------- /asm/atmega48.f: -------------------------------------------------------------------------------- 1 | ( atmega48 ) 2 | 3 | $e0 constant iosize 4 | $200 constant ramsize 5 | $800 constant flashsize 6 | $100 constant eepromsize 7 | $20 constant pagesize 8 | $1 constant vectorsize 9 | 10 | include atmegax8.f 11 | 12 | -------------------------------------------------------------------------------- /asm/atmega8.f: -------------------------------------------------------------------------------- 1 | ( atmega8 ) 2 | 3 | $40 constant iosize 4 | $400 constant ramsize 5 | $1000 constant flashsize 6 | $200 constant eepromsize 7 | $20 constant pagesize 8 | 9 | $20 constant twbr 10 | $21 constant twsr 11 | 7 constant tws7 12 | 6 constant tws6 13 | 5 constant tws5 14 | 4 constant tws4 15 | 3 constant tws3 16 | 1 constant twps1 17 | 0 constant twps0 18 | $22 constant twar 19 | 7 constant twa6 20 | 6 constant twa5 21 | 5 constant twa4 22 | 4 constant twa3 23 | 3 constant twa2 24 | 2 constant twa1 25 | 1 constant twa0 26 | 0 constant twgce 27 | $23 constant twdr 28 | $24 constant adcl 29 | $25 constant adch 30 | $26 constant adcsra 31 | 7 constant aden 32 | 6 constant adsc 33 | 5 constant adfr 34 | 4 constant adif 35 | 3 constant adie 36 | 2 constant adps2 37 | 1 constant adps1 38 | 0 constant adps0 39 | $27 constant admux 40 | 7 constant refs1 41 | 6 constant refs0 42 | 5 constant adlar 43 | 3 constant mux3 44 | 2 constant mux2 45 | 1 constant mux1 46 | 0 constant mux0 47 | $28 constant acsr 48 | 7 constant acd 49 | 6 constant acbg 50 | 5 constant aco 51 | 4 constant aci 52 | 3 constant acie 53 | 2 constant acic 54 | 1 constant acis1 55 | 0 constant acis0 56 | $29 constant ubrr0l 57 | $2a constant ucsr0b 58 | 7 constant rxcie 59 | 6 constant txcie 60 | 5 constant udrie 61 | 4 constant rxen 62 | 3 constant txen 63 | 2 constant ucsz2 64 | 1 constant rxb8 65 | 0 constant txb8 66 | $2b constant ucsr0a 67 | 7 constant rxc 68 | 6 constant txc 69 | 5 constant udre 70 | 4 constant fe 71 | 3 constant dor 72 | 2 constant pe 73 | 1 constant u2x 74 | 0 constant mpcm 75 | $2c constant udr0 76 | $2d constant spcr 77 | 7 constant spie 78 | 6 constant spe 79 | 5 constant dord 80 | 4 constant mstr 81 | 3 constant cpol 82 | 2 constant cpha 83 | 1 constant spr1 84 | 0 constant spr0 85 | $2e constant spsr 86 | 7 constant spif 87 | 6 constant wcol 88 | 0 constant spi2x 89 | $2f constant spdr 90 | $30 constant pind 91 | $31 constant ddrd 92 | $32 constant portd 93 | $33 constant pinc 94 | $34 constant ddrc 95 | $35 constant portc 96 | $36 constant pinb 97 | $37 constant ddrb 98 | $38 constant portb 99 | $3c constant eecr 100 | 3 constant eerie 101 | 2 constant eemwe 102 | 1 constant eewe 103 | 0 constant eere 104 | $3d constant eedr 105 | $3e constant eearl 106 | $3f constant eearh 107 | $40 constant ubrr0h 108 | $40 constant ucsr0c 109 | 7 constant ursel 110 | 6 constant umsel 111 | 5 constant upm1 112 | 4 constant upm0 113 | 3 constant usbs 114 | 2 constant ucsz1 115 | 1 constant ucsz0 116 | 0 constant ucpol 117 | $41 constant wdtcr 118 | 4 constant wdce 119 | 3 constant wde 120 | 2 constant wdp2 121 | 1 constant wdp1 122 | 0 constant wdp0 123 | $42 constant assr 124 | 3 constant as2 125 | 2 constant tcn2ub 126 | 1 constant ocr2ub 127 | 0 constant tcr2ub 128 | $43 constant ocr2a 129 | $44 constant tcnt2 130 | $45 constant tccr2a 131 | 7 constant foc2 132 | 6 constant wgm20 133 | 5 constant com21 134 | 4 constant com20 135 | 3 constant wgm21 136 | 2 constant cs22 137 | 1 constant cs21 138 | 0 constant cs20 139 | $46 constant icr1l 140 | $47 constant icr1h 141 | $48 constant ocr1bl 142 | $49 constant ocr1bh 143 | $4a constant ocr1al 144 | $4b constant ocr1ah 145 | $4c constant tcnt1l 146 | $4d constant tcnt1h 147 | $4e constant tccr1b 148 | 7 constant icnc1 149 | 6 constant ices1 150 | 4 constant wgm13 151 | 3 constant wgm12 152 | 2 constant cs12 153 | 1 constant cs11 154 | 0 constant cs10 155 | $4f constant tccr1a 156 | 7 constant com1a1 157 | 6 constant com1a0 158 | 5 constant com1b1 159 | 4 constant com1b0 160 | 3 constant foc1a 161 | 2 constant foc1b 162 | 1 constant wgm11 163 | 0 constant wgm10 164 | $50 constant sfior 165 | 3 constant acme 166 | 2 constant pud 167 | 1 constant psr2 168 | 0 constant psr10 169 | $51 constant osccal 170 | $52 constant tcnt0 171 | $53 constant tccr0a 172 | 2 constant cs02 173 | 1 constant cs01 174 | 0 constant cs00 175 | $54 constant mcucsr 176 | 3 constant wdrf 177 | 2 constant borf 178 | 1 constant extrf 179 | 0 constant porf 180 | $55 constant mcucr 181 | 7 constant se 182 | 6 constant sm2 183 | 5 constant sm1 184 | 4 constant sm0 185 | 3 constant isc11 186 | 2 constant isc10 187 | 1 constant isc01 188 | 0 constant isc00 189 | $56 constant twcr 190 | 7 constant twint 191 | 6 constant twea 192 | 5 constant twsta 193 | 4 constant twsto 194 | 3 constant twwc 195 | 2 constant twen 196 | 0 constant twie 197 | $57 constant spmcsr 198 | 7 constant spmie 199 | 6 constant rwwsb 200 | 4 constant rwwsre 201 | 3 constant blbset 202 | 2 constant pgwrt 203 | 1 constant pgers 204 | 0 constant spmen 205 | $58 constant tifr 206 | 7 constant ocf2a tifr ocf2a 2constant ocf2a-bit 207 | 6 constant tov2 tifr tov2 2constant tov2-bit 208 | 5 constant icf1 tifr icf1 2constant icf1-bit 209 | 4 constant ocf1a tifr ocf1a 2constant ocf1a-bit 210 | 3 constant ocf1b tifr ocf1b 2constant ocf1b-bit 211 | 2 constant tov1 tifr tov1 2constant tov1-bit 212 | 0 constant tov0 tifr tov0 2constant tov0-bit 213 | $59 constant timsk 214 | 7 constant ocie2a timsk ocie2a 2constant ocie2a-bit 215 | 6 constant toie2 timsk toie2 2constant toie2-bit 216 | 5 constant icie1 timsk icie1 2constant icie1-bit 217 | 4 constant ocie1a timsk ocie1a 2constant ocie1a-bit 218 | 3 constant ocie1b timsk ocie1b 2constant ocie1b-bit 219 | 2 constant toie1 timsk toie1 2constant toie1-bit 220 | 0 constant toie0 timsk toie0 2constant toie0-bit 221 | $5a constant gifr 222 | 7 constant intf1 223 | 6 constant inf0 224 | $5b constant gicr 225 | 7 constant int1 226 | 6 constant int0 227 | 1 constant ivsel 228 | 0 constant ivce 229 | $5d constant spl 230 | $5e constant sph 231 | $5f constant sreg 232 | 7 constant i 233 | 6 constant t 234 | 5 constant h 235 | 4 constant s 236 | 3 constant v 237 | 2 constant n 238 | 1 constant z 239 | 0 constant c 240 | 241 | ( spi pins ) 242 | ddrb 2 2constant ss-ddr 243 | ddrb 5 2constant sck-ddr 244 | ddrb 3 2constant mosi-ddr 245 | ddrb 4 2constant miso-ddr 246 | 247 | ( interrupt vectors ) 248 | $00 constant reset 249 | $01 constant external_interrupt_0 250 | $02 constant external_interrupt_1 251 | $03 constant timer2_compare_a 252 | $04 constant timer2_overflow 253 | $05 constant timer1_capture 254 | $06 constant timer1_compare_a 255 | $07 constant timer1_compare_b 256 | $08 constant timer1_overflow 257 | $09 constant timer0_overflow 258 | $0a constant spi_stc 259 | $0b constant usart0_rxc 260 | $0c constant usart0_udre 261 | $0d constant usart0_txc 262 | $0e constant adc 263 | $0f constant eeprom_ready 264 | $10 constant analog_comparator 265 | $11 constant twi 266 | $12 constant spm_ready 267 | 268 | $13 constant start 269 | 270 | -------------------------------------------------------------------------------- /asm/atmega88.f: -------------------------------------------------------------------------------- 1 | ( atmega88 ) 2 | 3 | $e0 constant iosize 4 | $400 constant ramsize 5 | $1000 constant flashsize 6 | $200 constant eepromsize 7 | $20 constant pagesize 8 | $1 constant vectorsize 9 | 10 | include atmegax8.f 11 | 12 | -------------------------------------------------------------------------------- /asm/atmegax8.f: -------------------------------------------------------------------------------- 1 | ( atmegax8 ) 2 | 3 | $23 constant pinb 4 | $24 constant ddrb 5 | $25 constant portb 6 | $26 constant pinc 7 | $27 constant ddrc 8 | $28 constant portc 9 | $29 constant pind 10 | $2a constant ddrd 11 | $2b constant portd 12 | $35 constant tifr0 13 | 2 constant ocf0b tifr0 ocf0b 2constant ocf0b-bit 14 | 1 constant ocf0a tifr0 ocf0a 2constant ocf0a-bit 15 | 0 constant tov0 tifr0 tov0 2constant tov0-bit 16 | $36 constant tifr1 17 | 5 constant icf1 tifr1 icf1 2constant icf1-bit 18 | 2 constant ocf1b tifr1 ocf1b 2constant ocf1b-bit 19 | 1 constant ocf1a tifr1 ocf1a 2constant ocf1a-bit 20 | 0 constant tov1 tifr1 tov1 2constant tov1-bit 21 | $37 constant tifr2 22 | 2 constant ocf2b tifr2 ocf2b 2constant ocf2b-bit 23 | 1 constant ocf2a tifr2 ocf2a 2constant ocf2a-bit 24 | 0 constant tov2 tifr2 tov2 2constant tov2-bit 25 | $3b constant pcifr 26 | 2 constant pcif2 27 | 1 constant pcif1 28 | 0 constant pcif0 29 | $3c constant eifr 30 | 1 constant intf1 31 | 0 constant intf0 32 | $3d constant eimsk 33 | 1 constant int1 34 | 0 constant int0 35 | $3e constant gpior0 36 | $3f constant eecr 37 | 5 constant eepm1 38 | 4 constant eepm0 39 | 3 constant eerie 40 | 2 constant eempe 2 constant eemwe 41 | 1 constant eepe 1 constant eewe 42 | 0 constant eere 43 | $40 constant eedr 44 | $41 constant eearl 45 | $42 constant eearh 46 | $43 constant gtccr 47 | 7 constant tsm 48 | 1 constant psrasy 49 | 0 constant psrsync 50 | $44 constant tccr0a 51 | 7 constant com0a1 52 | 6 constant com0a0 53 | 5 constant com0b1 54 | 4 constant com0b0 55 | 1 constant wgm01 56 | 0 constant wgm00 57 | $45 constant tccr0b 58 | 7 constant foc0a 59 | 6 constant foc0b 60 | 3 constant wgm02 61 | 2 constant cs02 62 | 1 constant cs01 63 | 0 constant cs00 64 | $46 constant tcnt0 65 | $47 constant ocr0a 66 | $48 constant ocr0b 67 | $4a constant gpior1 68 | $4b constant gpior2 69 | $4c constant spcr 70 | 7 constant spie 71 | 6 constant spe 72 | 5 constant dord 73 | 4 constant mstr 74 | 3 constant cpol 75 | 2 constant cpha 76 | 1 constant spr1 77 | 0 constant spr0 78 | $4d constant spsr 79 | 7 constant spif 80 | 6 constant wcol 81 | 0 constant spi2x 82 | $4e constant spdr 83 | $50 constant acsr 84 | 7 constant acd 85 | 6 constant acbg 86 | 5 constant aco 87 | 4 constant aci 88 | 3 constant acie 89 | 2 constant acic 90 | 1 constant acis1 91 | 0 constant acis0 92 | $53 constant smcr 93 | 3 constant sm2 94 | 2 constant sm1 95 | 1 constant sm0 96 | 0 constant se 97 | $54 constant mcusr 98 | 3 constant wdrf 99 | 2 constant borf 100 | 1 constant extrf 101 | 0 constant porf 102 | $55 constant mcucr 103 | 4 constant pud 104 | 1 constant ivsel 105 | 0 constant ivce 106 | $57 constant spmcsr 107 | 7 constant spmie 108 | 6 constant rwwsb 109 | 4 constant rwwsre 110 | 3 constant blbset 111 | 2 constant pgwrt 112 | 1 constant pgers 113 | 0 constant selfprgen 0 constant spmen 114 | $5d constant spl 115 | $5e constant sph 116 | $5f constant sreg 117 | $60 constant wdtcsr 118 | 7 constant wdif 119 | 6 constant wdie 120 | 5 constant wdp3 121 | 4 constant wdce 122 | 3 constant wde 123 | 2 constant wdp2 124 | 1 constant wdp1 125 | 0 constant wdp0 126 | $61 constant clkpr 127 | 7 constant clkpce 128 | 3 constant clkps3 129 | 2 constant clkps2 130 | 1 constant clkps1 131 | 0 constant clkps0 132 | $64 constant prr 133 | 7 constant prtwi 134 | 6 constant prtim2 135 | 5 constant prtim0 136 | 3 constant prtim1 137 | 2 constant prspi 138 | 1 constant prusart0 139 | 0 constant pradc 140 | $66 constant osccal 141 | $68 constant pcicr 142 | 2 constant pcie2 143 | 1 constant pcie1 144 | 0 constant pcie0 145 | $69 constant eicra 146 | 3 constant isc11 147 | 2 constant isc10 148 | 1 constant isc01 149 | 0 constant isc00 150 | $6b constant pcmsk0 151 | 7 constant pcint7 152 | 6 constant pcint6 153 | 5 constant pcint5 154 | 4 constant pcint4 155 | 3 constant pcint3 156 | 2 constant pcint2 157 | 1 constant pcint1 158 | 0 constant pcint0 159 | $6c constant pcmsk1 160 | 6 constant pcint14 161 | 5 constant pcint13 162 | 4 constant pcint12 163 | 3 constant pcint11 164 | 2 constant pcint10 165 | 1 constant pcint9 166 | 0 constant pcint8 167 | $6d constant pcmsk2 168 | 7 constant pcint23 169 | 6 constant pcint22 170 | 5 constant pcint21 171 | 4 constant pcint20 172 | 3 constant pcint19 173 | 2 constant pcint18 174 | 1 constant pcint17 175 | 0 constant pcint16 176 | $6e constant timsk0 177 | 2 constant ocie0b timsk0 ocie0b 2constant ocie0b-bit 178 | 1 constant ocie0a timsk0 ocie0a 2constant ocie0a-bit 179 | 0 constant toie0 timsk0 toie0 2constant toie0-bit 180 | $6f constant timsk1 181 | 5 constant icie1 timsk1 icie1 2constant icie1-bit 182 | 2 constant ocie1b timsk1 ocie1b 2constant ocie1b-bit 183 | 1 constant ocie1a timsk1 ocie1a 2constant ocie1a-bit 184 | 0 constant toie1 timsk1 toie1 2constant toie1-bit 185 | $70 constant timsk2 186 | 2 constant ocie2b timsk2 ocie2b 2constant ocie2b-bit 187 | 1 constant ocie2a timsk2 ocie2a 2constant ocie2a-bit 188 | 0 constant toie2 timsk2 toie2 2constant toie2-bit 189 | $78 constant adcl 190 | $79 constant adch 191 | $7a constant adcsra 192 | 7 constant aden 193 | 6 constant adsc 194 | 5 constant adate 195 | 4 constant adif 196 | 3 constant adie 197 | 2 constant adps2 198 | 1 constant adps1 199 | 0 constant adps0 200 | $7b constant adcsrb 201 | 6 constant acme 202 | 2 constant adts2 203 | 1 constant adts1 204 | 0 constant adts0 205 | $7c constant admux 206 | 7 constant refs1 207 | 6 constant refs0 208 | 5 constant adlar 209 | 3 constant mux3 210 | 2 constant mux2 211 | 1 constant mux1 212 | 0 constant mux0 213 | $7e constant didr0 214 | 5 constant adc5d 215 | 4 constant adc4d 216 | 3 constant adc3d 217 | 2 constant adc2d 218 | 1 constant adc1d 219 | 0 constant adc0d 220 | $7f constant didr1 221 | 1 constant ain1d 222 | 0 constant ain0d 223 | $80 constant tccr1a 224 | 7 constant com1a1 225 | 6 constant com1a0 226 | 5 constant com1b1 227 | 4 constant com1b0 228 | 1 constant wgm11 229 | 0 constant wgm10 230 | $81 constant tccr1b 231 | 7 constant icnc1 232 | 6 constant ices1 233 | 4 constant wgm13 234 | 3 constant wgm12 235 | 2 constant cs12 236 | 1 constant cs11 237 | 0 constant cs10 238 | $82 constant tccr1c 239 | 7 constant foc1a 240 | 6 constant foc1b 241 | $84 constant tcnt1l 242 | $85 constant tcnt1h 243 | $86 constant icr1l 244 | $87 constant icr1h 245 | $88 constant ocr1al 246 | $89 constant ocr1ah 247 | $8a constant ocr1bl 248 | $8b constant ocr1bh 249 | $b0 constant tccr2a 250 | 7 constant com2a1 251 | 6 constant com2a0 252 | 5 constant com2b1 253 | 4 constant com2b0 254 | 1 constant wgm21 255 | 0 constant wgm20 256 | $b1 constant tccr2b 257 | 7 constant foc2a 258 | 6 constant foc2b 259 | 3 constant wgm22 260 | 2 constant cs22 261 | 1 constant cs21 262 | 0 constant cs20 263 | $b2 constant tcnt2 264 | $b3 constant ocr2a 265 | $b4 constant ocr2b 266 | $b6 constant assr 267 | 6 constant exclk 268 | 5 constant as2 269 | 4 constant tcn2ub 270 | 3 constant ocr2aub 271 | 2 constant ocr2bub 272 | 1 constant tcr2aub 273 | 0 constant tcr2bub 274 | $b8 constant twbr 275 | $b9 constant twsr 276 | 7 constant tws7 277 | 6 constant tws6 278 | 5 constant tws5 279 | 4 constant tws4 280 | 3 constant tws3 281 | 1 constant twps1 282 | 0 constant twps0 283 | $ba constant twar 284 | 7 constant twa6 285 | 6 constant twa5 286 | 5 constant twa4 287 | 4 constant twa3 288 | 3 constant twa2 289 | 2 constant twa1 290 | 1 constant twa0 291 | 0 constant twgce 292 | $bb constant twdr 293 | $bc constant twcr 294 | 7 constant twint 295 | 6 constant twea 296 | 5 constant twsta 297 | 4 constant twsto 298 | 3 constant twwc 299 | 2 constant twen 300 | 0 constant twie 301 | $bd constant twamr 302 | 7 constant twam6 303 | 6 constant twam5 304 | 5 constant twam4 305 | 4 constant twam3 306 | 3 constant twam2 307 | 2 constant twam1 308 | 1 constant twam0 309 | $c0 constant ucsr0a 310 | 7 constant rxc 311 | 6 constant txc 312 | 5 constant udre 313 | 4 constant fe 314 | 3 constant dor 315 | 2 constant upe 316 | 1 constant u2x 317 | 0 constant mpcm 318 | $c1 constant ucsr0b 319 | 7 constant rxcie 320 | 6 constant txcie 321 | 5 constant udrie 322 | 4 constant rxen 323 | 3 constant txen 324 | 2 constant ucsz2 325 | 1 constant rxb8 326 | 0 constant txb8 327 | $c2 constant ucsr0c 328 | 7 constant umsel1 329 | 6 constant umsel0 330 | 5 constant upm1 331 | 4 constant upm0 332 | 3 constant usbs 333 | 2 constant ucsz1 2 constant udord0 334 | 1 constant ucsz0 1 constant ucpha0 335 | 0 constant ucpol 336 | $c4 constant ubrr0l 337 | $c5 constant ubrr0h 338 | $c6 constant udr0 339 | 340 | ( spi pins ) 341 | ddrb 2 2constant ss-ddr 342 | ddrb 5 2constant sck-ddr 343 | ddrb 3 2constant mosi-ddr 344 | ddrb 4 2constant miso-ddr 345 | 346 | ( interrupt vectors ) 347 | $00 vectorsize * constant reset 348 | $01 vectorsize * constant external_interrupt_0 349 | $02 vectorsize * constant external_interrupt_1 350 | $03 vectorsize * constant pin_change_interrupt_0 351 | $04 vectorsize * constant pin_change_interrupt_1 352 | $05 vectorsize * constant pin_change_interrupt_2 353 | $06 vectorsize * constant wdt 354 | $07 vectorsize * constant timer2_compare_a 355 | $08 vectorsize * constant timer2_compare_b 356 | $09 vectorsize * constant timer2_overflow 357 | $0a vectorsize * constant timer1_capture 358 | $0b vectorsize * constant timer1_compare_a 359 | $0c vectorsize * constant timer1_compare_b 360 | $0d vectorsize * constant timer1_overflow 361 | $0e vectorsize * constant timer0_compare_a 362 | $0f vectorsize * constant timer0_compare_b 363 | $10 vectorsize * constant timer0_overflow 364 | $11 vectorsize * constant spi_stc 365 | $12 vectorsize * constant usart0_rxc 366 | $13 vectorsize * constant usart0_udre 367 | $14 vectorsize * constant usart0_txc 368 | $15 vectorsize * constant adc 369 | $16 vectorsize * constant eeprom_ready 370 | $17 vectorsize * constant analog_comparator 371 | $18 vectorsize * constant twi 372 | $19 vectorsize * constant spm_ready 373 | 374 | $1a vectorsize * constant start 375 | 376 | -------------------------------------------------------------------------------- /asm/avr.f: -------------------------------------------------------------------------------- 1 | ( avr assembler ) 2 | 3 | hex 4 | : << lshift ; 5 | : >> rshift ; 6 | : lo ff and ; 7 | : hi 8 >> lo ; 8 | : 2^ 1 swap << ; 9 | 10 | ( target memory ) 11 | 20 constant regsize 12 | 0 constant regstart 13 | 1f constant regend 14 | 20 constant iostart 15 | iostart iosize + 1- constant ioend 16 | ioend 1+ constant ramstart 17 | ioend ramsize + constant ramend 18 | 0 constant flashstart 19 | flashsize 1- constant flashend 20 | 0 constant eepromstart 21 | eepromsize 1- constant eepromend 22 | 23 | create tflash flashsize 2* allot 24 | tflash flashsize 2* ff fill 25 | 26 | create tram ramsize allot 27 | tram ramsize 00 fill 28 | 29 | create teeprom eepromsize allot 30 | teeprom eepromsize ff fill 31 | 32 | variable idp 33 | variable tdp 34 | variable edp 35 | 36 | : ihere idp @ ; 37 | : there tdp @ ; 38 | : ehere edp @ ; 39 | 40 | : itarget 2* tflash + ; 41 | : target tram + regsize - iosize - ; 42 | : etarget teeprom + ; 43 | 44 | 1 constant icell 45 | : icells icell * ; 46 | : icell+ icell + ; 47 | : i@ ( ta -- x ) itarget dup c@ swap 1 + c@ 8 << or ; 48 | : i! ( x ta -- ) itarget over lo over c! swap hi swap 1 + c! ; 49 | : iallot idp +! ; 50 | : i, ihere i! 1 icells iallot ; 51 | 52 | 2 constant tcell 53 | : tcells tcell * ; 54 | : tcell+ tcell + ; 55 | : tc@ ( ta -- c ) target c@ ; 56 | : tc! ( c ta -- ) target c! ; 57 | : t@ ( ta -- x ) target dup c@ swap 1 + c@ 8 << or ; 58 | : t! ( x ta -- ) target over ff and over c! swap 8 >> ff and swap 1 + c! ; 59 | : tallot tdp +! ; 60 | : tc, there tc! 1 tallot ; 61 | : t, there t! 1 tcells tallot ; 62 | 63 | 2 constant ecell 64 | : ecells ecell * ; 65 | : ecell+ ecell + ; 66 | : ec@ ( ta -- c ) etarget c@ ; 67 | : ec! ( c ta -- ) etarget c! ; 68 | : e@ ( ta -- x ) etarget dup c@ swap 1 + c@ 8 << or ; 69 | : e! ( x ta -- ) etarget over ff and over c! swap 8 >> ff and swap 1 + c! ; 70 | : eallot edp +! ; 71 | : ec, ehere ec! 1 eallot ; 72 | : e, ehere e! 1 ecells eallot ; 73 | 74 | 75 | ( opcodes ) 76 | 77 | ( sreg bits ) 78 | 79 | 0 constant c 80 | 1 constant z 81 | 2 constant n 82 | 3 constant v 83 | 4 constant s 84 | 5 constant h 85 | 6 constant t 86 | 7 constant i 87 | 88 | ( inherent ) 89 | ( op ) 90 | ( oooo oooo oooo oooo ) 91 | 92 | : inherent i, ; 93 | 94 | : break, 9598 inherent ; 95 | : eicall, 9519 inherent ; 96 | : eijmp, 9419 inherent ; 97 | : elpm, 95d8 inherent ; 98 | : espm, 95f8 inherent ; 99 | : icall, 9509 inherent ; 100 | : ijmp, 9409 inherent ; 101 | : lpm, 95c8 inherent ; 102 | : nop, 0000 inherent ; 103 | : ret, 9508 inherent ; 104 | : reti, 9518 inherent ; 105 | : sleep, 9588 inherent ; 106 | : spm, 95e8 inherent ; 107 | : wdr, 95a8 inherent ; 108 | 109 | ( two 5-bit registers ) 110 | ( d r op ) 111 | ( oooo oord dddd rrrr ) 112 | 113 | : 2reg5bit ( d r op -- ) 114 | >r 115 | dup 0010 and 5 << r> or >r 116 | 000f and r> or >r 117 | 001f and 4 << r> or i, ; 118 | 119 | : adc, 1c00 2reg5bit ; 120 | : add, 0c00 2reg5bit ; 121 | : and, 2000 2reg5bit ; 122 | : cp, 1400 2reg5bit ; 123 | : cpc, 0400 2reg5bit ; 124 | : cpse, 1000 2reg5bit ; 125 | : eor, 2400 2reg5bit ; 126 | : mov, 2c00 2reg5bit ; 127 | : mul, 9c00 2reg5bit ; 128 | : or, 2800 2reg5bit ; 129 | : sbc, 0800 2reg5bit ; 130 | : sub, 1800 2reg5bit ; 131 | 132 | : clr, dup eor, ; 133 | : lsl, dup add, ; 134 | : rol, dup adc, ; 135 | : tst, dup and, ; 136 | 137 | ( one 5-bit register ) 138 | ( d op ) 139 | ( oooo oood dddd oooo ) 140 | 141 | : 1reg5bit ( d op -- ) 142 | >r 143 | 001f and 4 << r> or i, ; 144 | 145 | : asr, 9405 1reg5bit ; 146 | : com, 9400 1reg5bit ; 147 | : dec, 940a 1reg5bit ; 148 | : elpmz, 9006 1reg5bit ; 149 | : elpmz+, 9007 1reg5bit ; 150 | : inc, 9403 1reg5bit ; 151 | : ldx, 900c 1reg5bit ; 152 | : ldx+, 900d 1reg5bit ; 153 | : ld-x, 900e 1reg5bit ; 154 | : ldy, 8008 1reg5bit ; 155 | : ldy+, 9009 1reg5bit ; 156 | : ld-y, 900a 1reg5bit ; 157 | : ldz, 8000 1reg5bit ; 158 | : ldz+, 9001 1reg5bit ; 159 | : ld-z, 9002 1reg5bit ; 160 | : lpmz, 9004 1reg5bit ; 161 | : lpmz+, 9005 1reg5bit ; 162 | : lsr, 9406 1reg5bit ; 163 | : neg, 9401 1reg5bit ; 164 | : pop, 900f 1reg5bit ; 165 | : push, 920f 1reg5bit ; 166 | : ror, 9407 1reg5bit ; 167 | : stx, 920c 1reg5bit ; 168 | : stx+, 920d 1reg5bit ; 169 | : st-x, 920e 1reg5bit ; 170 | : sty, 8208 1reg5bit ; 171 | : sty+, 9209 1reg5bit ; 172 | : st-y, 920a 1reg5bit ; 173 | : stz, 8200 1reg5bit ; 174 | : stz+, 9201 1reg5bit ; 175 | : st-z, 9202 1reg5bit ; 176 | : swap, 9402 1reg5bit ; 177 | 178 | ( one 4-bit register with immediate data ) 179 | ( d k op ) 180 | ( oooo kkkk dddd kkkk ) 181 | 182 | : 1reg4bitimm ( d k op -- ) 183 | >r 184 | dup 00f0 and 4 << r> or >r 185 | 000f and r> or >r 186 | 000f and 4 << r> or i, ; 187 | 188 | : andi, 7000 1reg4bitimm ; 189 | : cpi, 3000 1reg4bitimm ; 190 | : ldi, e000 1reg4bitimm ; 191 | : ori, 6000 1reg4bitimm ; 192 | : sbci, 4000 1reg4bitimm ; 193 | : subi, 5000 1reg4bitimm ; 194 | 195 | : cbr, invert andi, ; 196 | : sbr, ori, ; 197 | : ser, ff ldi, ; 198 | 199 | ( one 2-bit word with immediate data ) 200 | ( d k op ) 201 | ( oooo oooo kkdd kkkk ) 202 | 203 | : 1word2bitimm ( d k op -- ) 204 | >r 205 | dup 0030 and 2 << r> or >r 206 | 000f and r> or >r 207 | 0006 and 3 << r> or i, ; 208 | 209 | : adiw, 9600 1word2bitimm ; 210 | : sbiw, 9700 1word2bitimm ; 211 | 212 | ( branch ) 213 | ( s k op ) 214 | ( k op ) 215 | ( oooo ookk kkkk ksss ) 216 | 217 | : branch ( s k op -- ) 218 | >r 219 | ihere - 1- 007f and 3 << r> or >r 220 | 0007 and r> or i, ; 221 | 222 | : brbc, f400 branch ; 223 | : brcc, c swap brbc, ; 224 | : brsh, brcc, ; 225 | : brne, z swap brbc, ; 226 | : brpl, n swap brbc, ; 227 | : brvc, v swap brbc, ; 228 | : brge, s swap brbc, ; 229 | : brhc, h swap brbc, ; 230 | : brtc, t swap brbc, ; 231 | : brid, i swap brbc, ; 232 | 233 | : brbs, f000 branch ; 234 | : brcs, c swap brbs, ; 235 | : brlo, brcs, ; 236 | : breq, z swap brbs, ; 237 | : brmi, n swap brbs, ; 238 | : brvs, v swap brbs, ; 239 | : brli, s swap brbs, ; 240 | : brhs, h swap brbs, ; 241 | : brts, t swap brbs, ; 242 | : brie, i swap brbs, ; 243 | 244 | ( sreg ) 245 | ( s op ) 246 | ( oooo oooo osss oooo ) 247 | 248 | : sregbit ( s op -- ) 249 | >r 250 | 0007 and 4 << r> or i, ; 251 | 252 | : bclr, 9488 sregbit ; 253 | 254 | : clc, c bclr, ; 255 | : clz, z bclr, ; 256 | : cln, n bclr, ; 257 | : clv, v bclr, ; 258 | : cls, s bclr, ; 259 | : clh, h bclr, ; 260 | : clt, t bclr, ; 261 | : cli, i bclr, ; 262 | 263 | : bsei, 9408 sregbit ; 264 | 265 | : sec, c bsei, ; 266 | : sez, z bsei, ; 267 | : sen, n bsei, ; 268 | : sev, v bsei, ; 269 | : ses, s bsei, ; 270 | : seh, h bsei, ; 271 | : set, t bsei, ; 272 | : sei, i bsei, ; 273 | 274 | ( one 5-bit register with i/o location ) 275 | ( d a op ) 276 | ( oooo oaad dddd aaaa ) 277 | 278 | : 1reg5bitio ( d a op -- ) 279 | >r 280 | dup 0030 and 5 << r> or >r 281 | 000f and r> or >r 282 | 001f and 4 << r> or i, ; 283 | 284 | : in, b000 1reg5bitio ; 285 | : out, swap b800 1reg5bitio ; 286 | 287 | ( two 4-bit registers ) 288 | ( d r op ) 289 | ( oooo oooo dddd rrrr ) 290 | 291 | : 2reg4bit ( d r op -- ) 292 | >r 293 | 000f and r> or >r 294 | 000f and 4 << r> or i, ; 295 | 296 | : muls, 0200 2reg4bit ; 297 | 298 | ( two 3-bit registers ) 299 | ( d r op ) 300 | ( oooo oooo oddd orrr ) 301 | 302 | : 2reg3bit ( d r op -- ) 303 | >r 304 | 0007 and r> or >r 305 | 0007 and 4 << r> or i, ; 306 | 307 | : mulsu, 0300 2reg3bit ; 308 | : fmul, 0308 2reg3bit ; 309 | : fmuls, 0380 2reg3bit ; 310 | : fmulsu, 0388 2reg3bit ; 311 | 312 | ( relative ) 313 | ( k op ) 314 | ( oooo kkkk kkkk kkkk ) 315 | 316 | : relative ( k op -- ) 317 | >r 318 | ihere - 1- 0fff and r> or i, ; 319 | 320 | : rcall, d000 relative ; 321 | : rjmp, c000 relative ; 322 | 323 | ( one 5-bit register bit operation ) 324 | ( d b op ) 325 | ( oooo oood dddd obbb ) 326 | 327 | : 1reg5bitbit ( d b op -- ) 328 | >r 329 | 0007 and r> or >r 330 | 001f and 4 << r> or i, ; 331 | 332 | : bld, f800 1reg5bitbit ; 333 | : bst, fa00 1reg5bitbit ; 334 | : sbrc, fc00 1reg5bitbit ; 335 | : sbrs, fe00 1reg5bitbit ; 336 | 337 | ( absolute ) 338 | ( doesn't handle 22-bit addresses yet ) 339 | ( k op ) 340 | ( oooo oook kkkk oook ) 341 | ( kkkk kkkk kkkk kkkk ) 342 | 343 | : absolute ( k op -- ) 344 | i, i, ; 345 | 346 | : call, 940e absolute ; 347 | : jmp, 940c absolute ; 348 | 349 | ( one i/o register bit operation ) 350 | ( a b op ) 351 | ( oooo oooo aaaa abbb ) 352 | 353 | : 1iobit ( a b op -- ) 354 | >r 355 | 0007 and r> or >r 356 | 001f and 3 << r> or i, ; 357 | 358 | : cbi, 9800 1iobit ; 359 | : sbi, 9a00 1iobit ; 360 | : sbic, 9900 1iobit ; 361 | : sbis, 9b00 1iobit ; 362 | 363 | ( direct ) 364 | ( k r op ) 365 | ( oooo oood dddd oooo ) 366 | ( kkkk kkkk kkkk kkkk ) 367 | 368 | : direct ( k r op -- ) 369 | >r 370 | 001f and 4 << r> or i, i, ; 371 | 372 | : sts, 9200 direct ; 373 | : lds, swap 9000 direct ; 374 | 375 | ( two words ) 376 | ( d r op ) 377 | ( oooo oooo dddd rrrr ) 378 | 379 | : 2words ( d r op -- ) 380 | >r 381 | 001e and 1 >> r> or >r 382 | 001e and 3 << r> or i, ; 383 | 384 | : movw, 0100 2words ; 385 | 386 | ( indirect with displacement ) 387 | ( d q op ) 388 | ( ooqo qqod dddd oqqq ) 389 | 390 | : displacement ( d q op -- ) 391 | >r 392 | dup 0020 and 8 << r> or >r 393 | dup 0018 and 7 << r> or >r 394 | 0007 and r> or >r 395 | 001f and 4 << r> or i, ; 396 | 397 | : lddy, 8008 displacement ; 398 | : lddz, 8000 displacement ; 399 | : stdy, swap 8208 displacement ; 400 | : stdz, swap 8200 displacement ; 401 | 402 | start idp ! 403 | ramstart tdp ! 404 | eepromstart edp ! 405 | 406 | ( binary file output ) 407 | 408 | 0 Value flash-file 409 | : write-flash ( ca n -- ) 410 | w/o bin create-file throw to flash-file 411 | tflash flashsize 2* flash-file write-file throw 412 | flash-file close-file throw ; 413 | 414 | 0 Value eeprom-file 415 | : write-eeprom ( ca n -- ) 416 | w/o bin create-file throw to eeprom-file 417 | teeprom eepromsize eeprom-file write-file throw 418 | eeprom-file close-file throw ; 419 | 420 | ( structured assembler constructs ) 421 | 422 | ( fetch and store ) 423 | : fetch dup 20 60 within if 20 - in, else lds, then ; 424 | : store over 20 60 within if swap 20 - swap out, else sts, then ; 425 | : load over 0 20 within if 426 | over 10 20 within if 427 | ldi, 428 | else as swap ldi, as mov, then 429 | else as swap ldi, as store then ; 430 | 431 | ( bit operations ) 432 | : skip-bit-clear over 20 40 within if swap 20 - swap sbic, 433 | else as rot fetch as swap sbrc, then ; 434 | : skip-bit-set over 20 40 within if swap 20 - swap sbis, 435 | else as rot fetch as swap sbrs, then ; 436 | : set-bit over 20 40 within if swap 20 - swap sbi, 437 | else over as swap fetch as swap 2^ ori, as store then ; 438 | : clear-bit over 20 40 within if swap 20 - swap cbi, 439 | else over as swap fetch as swap 2^ invert andi, as store then ; 440 | 441 | ( address labels ) 442 | : label create ihere , does> @ ; 443 | 444 | ( subroutines ) 445 | : rel? ( dest src -- f ) - 1- -800 800 within ; 446 | : call dup ihere rel? if rcall, else call, then ; 447 | : jump dup ihere rel? if rjmp, else jmp, then ; 448 | 449 | ( variables ) 450 | : var create there , tallot does> @ ; 451 | : evar create ehere , eallot does> @ ; 452 | 453 | ( conditionals ) 454 | : if, ( cc -- a ) 0007 and f400 or i, ihere 1- ; 455 | : ~if, ( cc -- a ) 0007 and f000 or i, ihere 1- ; 456 | : then, ( a -- ) ihere over - 1- 007f and 3 << over i@ or swap i! ; 457 | : then, ( a -- ) dup i@ 458 | dup f800 and f000 = if drop ihere over - 1- 007f and 3 << over i@ or swap i! 459 | else c000 = if ihere over - 1- 0fff and over i@ or swap i! 460 | then then ; 461 | : else, ( a -- a' ) c000 i, ihere 1- swap then, ; 462 | 463 | ( loops ) 464 | : begin, ( -- a ) ihere ; 465 | : again, ( a -- ) rjmp, ; 466 | : until, ( a cc -- ) swap brbc, ; 467 | : ~until, ( a cc -- ) swap brbs, ; 468 | : do, ( -- a ) ihere ; 469 | : loop, ( a r -- ) dec, brne, ; 470 | : while, ( a cc -- a a ) if, swap ; 471 | : ~while, ( a cc -- a a ) ~if, swap ; 472 | : repeat, ( a a -- ) again, then, ; 473 | 474 | \ ( jump table ) 475 | \ : jump, ( r -- ) 476 | \ ihere 5 + 477 | \ zl over lo ldi, 478 | \ zh swap hi ldi, 479 | \ zl swap add, 480 | \ zh zero adc, 481 | \ ijmp, ; 482 | 483 | ( interrupts ) 484 | : vector idp @ swap idp ! dup jump idp ! ; 485 | : inton sei, ; 486 | : intoff cli, ; 487 | 488 | ( save/restore sreg in isrs ) 489 | : pushsreg 490 | as push, 491 | as sreg fetch 492 | as push, ; 493 | : popsreg 494 | as pop, 495 | sreg as store 496 | as pop, ; 497 | 498 | \ ( copy initial ram contents ) 499 | \ : mirror ramstart target flashsize itarget ramsize - ramsize move ; 500 | \ : mirror, 501 | \ zh flashend 2* ramsize - hi ldi, 502 | \ zl flashend 2* ramsize - lo ldi, 503 | \ yh ramstart hi ldi, 504 | \ yl ramstart lo ldi, 505 | \ xh flashend 2* hi ldi, 506 | \ xl flashend 2* lo ldi, 507 | \ 508 | \ begin, 509 | \ zl xl cp, 510 | \ zh xh cpc, 511 | \ z ~while, 512 | \ wh lpmz+, 513 | \ wh sty+, 514 | \ repeat, ; 515 | 516 | -------------------------------------------------------------------------------- /avrforth.el: -------------------------------------------------------------------------------- 1 | ;(defvar my-mode-map nil "keymap for `my-mode-mode'") 2 | ;(setq my-mode-map (make-sparse-keymap)) 3 | ;(define-key my-mode-map (kbd "C-c C-a") 'my-mode-cmd1) 4 | 5 | (defface avrforth-face-compiled-word 6 | '((t :foreground "green")) 7 | "Face for words that get compiled, not run (including ] prefix)" 8 | :group 'avrforth) 9 | 10 | (defvar avrforth-mode-syntax-table nil "Syntax table for `avrforth-mode'.") 11 | 12 | (setq avrforth-mode-syntax-table 13 | (let ( (st (make-syntax-table text-mode-syntax-table))) 14 | ;;(modify-syntax-entry ?\\ "<" st) 15 | ;;(modify-syntax-entry ?\n ">" st) 16 | (modify-syntax-entry ?. "_" st) 17 | (modify-syntax-entry ?, "_" st) 18 | (modify-syntax-entry ?: "_" st) 19 | (modify-syntax-entry ?\; "_" st) 20 | (modify-syntax-entry ?! "_" st) 21 | (modify-syntax-entry ?@ "_" st) 22 | (modify-syntax-entry ?# "_" st) 23 | (modify-syntax-entry ?? "_" st) 24 | (modify-syntax-entry ?~ "_" st) 25 | (modify-syntax-entry ?\( "_" st) 26 | (modify-syntax-entry ?\) "_" st) 27 | (modify-syntax-entry ?\[ "_" st) 28 | (modify-syntax-entry ?\] "_" st) 29 | (modify-syntax-entry ?' "_" st) 30 | (modify-syntax-entry ?` "_" st) 31 | st)) 32 | 33 | (setq avrforth-highlights 34 | '( ;; comment 35 | ("\\_<\([[:space:]][^)]\\{1,63\\}\)" . font-lock-comment-face) 36 | ;; we have a 64 byte buffer, longer comments cause crashes: 37 | ("\\_<\([[:space:]][^)]+\)" . font-lock-warning-face) 38 | ;; string 39 | ("\\_<[^[:space:]]*\"[[:space:]]\\([^\"]*\\)\"" 1 font-lock-string-face ) 40 | ;; ] prefix 41 | ("\\_<\][[:space:]]+\]\\_>" . font-lock-warning-face) 42 | ("\\_<\][[:space:]]+[^[:space:]]+\\_>" . 'avrforth-face-compiled-word) 43 | 44 | ;; colon definition 45 | ;;("\\_<[^[:space:]]*:[[:space:]]+[^[:space:]]+\\>_" . font-lock-function-name-face) 46 | ("\\_<[^[:space:]]*:[[:space:]]+[^[:space:]]+\\_>" . font-lock-function-name-face) 47 | ;; l 48 | ("\\_" . font-lock-keyword-face) 49 | ;; [ 50 | ("\\_<\\[\\_>" . font-lock-keyword-face) 51 | ;; only 16-bit lowercase hexadecimal! 52 | ("\\_<$[[:space:]]+[0-9a-f]\\{1,4\\}\\_>" . font-lock-constant-face) 53 | ;; any other literals are no good: 54 | ("\\_<$[[:space:]]+[^[:space:]]+" . font-lock-warning-face) 55 | 56 | t)) 57 | 58 | ;;(require 'forth-mode) 59 | 60 | ;; get your forth-mode from gforth.el, distributed in the official 61 | ;; gforth releases. 62 | (define-derived-mode avrforth-mode forth-mode "avrforth" 63 | "major mode for editing avrforth language code. 64 | 65 | gforth's syntax highlighting makes it really to read. this mode 66 | will turn your ]-prefixed words into a different font, and it 67 | will color [ and l pairs (not [ and ]) so they match." 68 | 69 | (setq font-lock-defaults '(avrforth-highlights)) 70 | 71 | (remove-hook 'after-change-functions 'forth-change-function t) 72 | (set-syntax-table avrforth-mode-syntax-table) 73 | (setq font-lock-multiline t) 74 | (setq-local comment-start "\\ ") 75 | (setq-local comment-end "")) 76 | 77 | 78 | ;;(setq auto-mode-alist (cons '("\\.avrforth\\'" . avrforth-mode) auto-mode-alist)) 79 | 80 | -------------------------------------------------------------------------------- /avrforth.vim: -------------------------------------------------------------------------------- 1 | :syntax match red /\:\s\+\S\+\_s\+/ 2 | :syntax match green /]\s\+\S\+\_s\+/ 3 | :syntax match yellow /[[$]\s\+\S\+\_s\+/ 4 | :syntax match white /(\s\+[^)\n]*)/ 5 | :syntax match cyan /c\s\+\S\+\_s\+/ 6 | :syntax match magenta /var\s\+\S\+\_s\+/ 7 | :syntax match darkyellow /l\{1,2}\_s\+/ 8 | :highlight red ctermfg=red 9 | :highlight green ctermfg=green 10 | :highlight yellow ctermfg=yellow 11 | :highlight white ctermfg=white 12 | :highlight cyan ctermfg=cyan 13 | :highlight magenta ctermfg=magenta 14 | :highlight darkyellow ctermfg=darkyellow 15 | :NoMatchParen 16 | 17 | -------------------------------------------------------------------------------- /blocks/assembler.avrforth: -------------------------------------------------------------------------------- 1 | ( avrforth assembler ) 2 | ( daniel kruszyna ) 3 | ( public domain ) 4 | 5 | ( register defines ) 6 | 7 | ( z ) 8 | : zh [ $ 1f l ] ; 9 | : zl [ $ 1e l ] ; 10 | : zz [ $ 1e l ] ; 11 | 12 | ( y : parameter stack pointer ) 13 | : yh [ $ 1d l ] ; 14 | : yl [ $ 1c l ] ; 15 | : yy [ $ 1c l ] ; 16 | 17 | ( x ) 18 | : xh [ $ 1b l ] ; 19 | : xl [ $ 1a l ] ; 20 | : xx [ $ 1a l ] ; 21 | 22 | ( top of stack register ) 23 | : tosh [ $ 19 l ] ; 24 | : tosl [ $ 18 l ] ; 25 | : tos [ $ 18 l ] ; 26 | 27 | ( temp registers ) 28 | : temp3 [ $ 13 l ] ; 29 | : temp2 [ $ 12 l ] ; 30 | : temp1 [ $ 11 l ] ; 31 | : temp0 [ $ 10 l ] ; 32 | 33 | ( sreg bits ) 34 | 35 | : cbit [ $ 0 l ] ; 36 | : zbit [ $ 1 l ] ; 37 | : nbit [ $ 2 l ] ; 38 | : vbit [ $ 3 l ] ; 39 | : sbit [ $ 4 l ] ; 40 | : hbit [ $ 5 l ] ; 41 | : tbit [ $ 6 l ] ; 42 | : ibit [ $ 7 l ] ; 43 | 44 | ( inherent ) 45 | ( op ) 46 | ( oooo oooo oooo oooo ) 47 | 48 | : break, [ $ 9598 l ] i, ] ; 49 | : eicall, [ $ 9519 l ] i, ] ; 50 | : eijmp, [ $ 9419 l ] i, ] ; 51 | : elpm, [ $ 95d8 l ] i, ] ; 52 | : espm, [ $ 95f8 l ] i, ] ; 53 | : icall, [ $ 9509 l ] i, ] ; 54 | : ijmp, [ $ 9409 l ] i, ] ; 55 | : lpm, [ $ 95c8 l ] i, ] ; 56 | : nop, [ $ 0000 l ] i, ] ; 57 | : ret, [ $ 9508 l ] i, ] ; 58 | : reti, [ $ 9518 l ] i, ] ; 59 | : sleep, [ $ 9588 l ] i, ] ; 60 | : spm, [ $ 95e8 l ] i, ] ; 61 | : wdr, [ $ 95a8 l ] i, ] ; 62 | 63 | ( two 5-bit registers ) 64 | ( d r op ) 65 | ( oooo oord dddd rrrr ) 66 | 67 | : 2reg5bit ( d r op -- ) 68 | ] >r 69 | ] dup [ $ 0010 l ] and [ $ 5 l ] lshift ] r> ] or ] >r 70 | [ $ 000f l ] and ] r> ] or ] >r 71 | [ $ 001f l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 72 | 73 | : adc, [ $ 1c00 l ] 2reg5bit ] ; 74 | : add, [ $ 0c00 l ] 2reg5bit ] ; 75 | : and, [ $ 2000 l ] 2reg5bit ] ; 76 | : cp, [ $ 1400 l ] 2reg5bit ] ; 77 | : cpc, [ $ 0400 l ] 2reg5bit ] ; 78 | : cpse, [ $ 1000 l ] 2reg5bit ] ; 79 | : eor, [ $ 2400 l ] 2reg5bit ] ; 80 | : mov, [ $ 2c00 l ] 2reg5bit ] ; 81 | : mul, [ $ 9c00 l ] 2reg5bit ] ; 82 | : or, [ $ 2800 l ] 2reg5bit ] ; 83 | : sbc, [ $ 0800 l ] 2reg5bit ] ; 84 | : sub, [ $ 1800 l ] 2reg5bit ] ; 85 | 86 | : clr, ] dup ] eor, ] ; 87 | : lsl, ] dup ] add, ] ; 88 | : rol, ] dup ] adc, ] ; 89 | : tsi, ] dup ] and, ] ; 90 | 91 | ( one 5-bit register ) 92 | ( d op ) 93 | ( oooo oood dddd oooo ) 94 | 95 | : 1reg5bit ( d op -- ) 96 | ] >r 97 | [ $ 001f l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 98 | 99 | : asr, [ $ 9405 l ] 1reg5bit ] ; 100 | : com, [ $ 9400 l ] 1reg5bit ] ; 101 | : dec, [ $ 940a l ] 1reg5bit ] ; 102 | : elpmz, [ $ 9006 l ] 1reg5bit ] ; 103 | : elpmz+, [ $ 9007 l ] 1reg5bit ] ; 104 | : inc, [ $ 9403 l ] 1reg5bit ] ; 105 | : ldx, [ $ 900c l ] 1reg5bit ] ; 106 | : ldx+, [ $ 900d l ] 1reg5bit ] ; 107 | : ld-x, [ $ 900e l ] 1reg5bit ] ; 108 | : ldy, [ $ 8008 l ] 1reg5bit ] ; 109 | : ldy+, [ $ 9009 l ] 1reg5bit ] ; 110 | : ld-y, [ $ 900a l ] 1reg5bit ] ; 111 | : ldz, [ $ 8000 l ] 1reg5bit ] ; 112 | : ldz+, [ $ 9001 l ] 1reg5bit ] ; 113 | : ld-z, [ $ 9002 l ] 1reg5bit ] ; 114 | : lpmz, [ $ 9004 l ] 1reg5bit ] ; 115 | : lpmz+, [ $ 9005 l ] 1reg5bit ] ; 116 | : lsr, [ $ 9406 l ] 1reg5bit ] ; 117 | : neg, [ $ 9401 l ] 1reg5bit ] ; 118 | : pop, [ $ 900f l ] 1reg5bit ] ; 119 | : push, [ $ 920f l ] 1reg5bit ] ; 120 | : ror, [ $ 9407 l ] 1reg5bit ] ; 121 | : stx, [ $ 920c l ] 1reg5bit ] ; 122 | : stx+, [ $ 920d l ] 1reg5bit ] ; 123 | : st-x, [ $ 920e l ] 1reg5bit ] ; 124 | : sty, [ $ 8208 l ] 1reg5bit ] ; 125 | : sty+, [ $ 9209 l ] 1reg5bit ] ; 126 | : st-y, [ $ 920a l ] 1reg5bit ] ; 127 | : stz, [ $ 8200 l ] 1reg5bit ] ; 128 | : stz+, [ $ 9201 l ] 1reg5bit ] ; 129 | : st-z, [ $ 9202 l ] 1reg5bit ] ; 130 | : swap, [ $ 9402 l ] 1reg5bit ] ; 131 | 132 | ( one 4-bit register with immediate data ) 133 | ( d k op ) 134 | ( oooo kkkk dddd kkkk ) 135 | 136 | : 1reg4bitimm ( d k op -- ) 137 | ] >r 138 | ] dup [ $ 00f0 l ] and [ $ 4 l ] lshift ] r> ] or ] >r 139 | [ $ 000f l ] and ] r> ] or ] >r 140 | [ $ 000f l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 141 | 142 | : andi, [ $ 7000 l ] 1reg4bitimm ] ; 143 | : cpi, [ $ 3000 l ] 1reg4bitimm ] ; 144 | : ldi, [ $ e000 l ] 1reg4bitimm ] ; 145 | : ori, [ $ 6000 l ] 1reg4bitimm ] ; 146 | : sbci, [ $ 4000 l ] 1reg4bitimm ] ; 147 | : subi, [ $ 5000 l ] 1reg4bitimm ] ; 148 | 149 | : cbr, ] invert ] andi, ] ; 150 | : sbr, ] ori, ] ; 151 | : ser, [ $ ff l ] ldi, ] ; 152 | 153 | ( one 2-bit word with immediate data ) 154 | ( d k op ) 155 | ( oooo oooo kkdd kkkk ) 156 | 157 | : 1word2bitimm ( d k op -- ) 158 | ] >r 159 | ] dup [ $ 0030 l ] and [ $ 2 l ] lshift ] r> ] or ] >r 160 | [ $ 000f l ] and ] r> ] or ] >r 161 | [ $ 0006 l ] and [ $ 3 l ] lshift ] r> ] or ] i, ] ; 162 | 163 | : adiw, [ $ 9600 l ] 1word2bitimm ] ; 164 | : sbiw, [ $ 9700 l ] 1word2bitimm ] ; 165 | 166 | ( branch ) 167 | ( s k op ) 168 | ( k op ) 169 | ( oooo ookk kkkk ksss ) 170 | 171 | : branch ( s k op -- ) 172 | ] >r 173 | ] ihere ] - ] 1- [ $ 007f l ] and [ $ 3 l ] lshift ] r> ] or ] >r 174 | [ $ 0007 l ] and ] r> ] or ] i, ] ; 175 | 176 | : brbc, [ $ f400 l ] branch ] ; 177 | : brcc, ] cbit ] swap ] brbc, ] ; 178 | : brsh, ] brcc, ] ; 179 | : brne, ] zbit ] swap ] brbc, ] ; 180 | : brpl, ] nbit ] swap ] brbc, ] ; 181 | : brvc, ] vbit ] swap ] brbc, ] ; 182 | : brge, ] sbit ] swap ] brbc, ] ; 183 | : brhc, ] hbit ] swap ] brbc, ] ; 184 | : brtc, ] tbit ] swap ] brbc, ] ; 185 | : brid, ] ibit ] swap ] brbc, ] ; 186 | 187 | : brbs, [ $ f000 l ] branch ] ; 188 | : brcs, ] cbit ] swap ] brbs, ] ; 189 | : brlo, ] brcs, ] ; 190 | : breq, ] zbit ] swap ] brbs, ] ; 191 | : brmi, ] nbit ] swap ] brbs, ] ; 192 | : brvs, ] vbit ] swap ] brbs, ] ; 193 | : brli, ] sbit ] swap ] brbs, ] ; 194 | : brhs, ] hbit ] swap ] brbs, ] ; 195 | : brts, ] tbit ] swap ] brbs, ] ; 196 | : brie, ] ibit ] swap ] brbs, ] ; 197 | 198 | ( sreg ) 199 | ( s op ) 200 | ( oooo oooo osss oooo ) 201 | 202 | : sregbit ( s op -- ) 203 | ] >r 204 | [ $ 0007 l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 205 | 206 | : bclr, [ $ 9488 l ] sregbit ] ; 207 | 208 | : clc, [ cbit l ] bclr, ] ; 209 | : clz, [ zbit l ] bclr, ] ; 210 | : cln, [ nbit l ] bclr, ] ; 211 | : clv, [ vbit l ] bclr, ] ; 212 | : cls, [ sbit l ] bclr, ] ; 213 | : clh, [ hbit l ] bclr, ] ; 214 | : clt, [ tbit l ] bclr, ] ; 215 | : cli, [ ibit l ] bclr, ] ; 216 | 217 | : bsei, [ $ 9408 l ] sregbit ] ; 218 | 219 | : sec, [ cbit l ] bsei, ] ; 220 | : sez, [ zbit l ] bsei, ] ; 221 | : sen, [ nbit l ] bsei, ] ; 222 | : sev, [ vbit l ] bsei, ] ; 223 | : ses, [ sbit l ] bsei, ] ; 224 | : seh, [ hbit l ] bsei, ] ; 225 | : set, [ tbit l ] bsei, ] ; 226 | : sei, [ ibit l ] bsei, ] ; 227 | 228 | ( one 5-bit register with i/o location ) 229 | ( d a op ) 230 | ( oooo oaad dddd aaaa ) 231 | 232 | : 1reg5bitio ( d a op -- ) 233 | ] >r 234 | ] dup [ $ 0030 l ] and [ $ 5 l ] lshift ] r> ] or ] >r 235 | [ $ 000f l ] and ] r> ] or ] >r 236 | [ $ 001f l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 237 | 238 | : in, [ $ b000 l ] 1reg5bitio ] ; 239 | : out, ] swap [ $ b800 l ] 1reg5bitio ] ; 240 | 241 | ( two 4-bit registers ) 242 | ( d r op ) 243 | ( oooo oooo dddd rrrr ) 244 | 245 | : 2reg4bit ( d r op -- ) 246 | ] >r 247 | [ $ 000f l ] and ] r> ] or ] >r 248 | [ $ 000f l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 249 | 250 | : muls, [ $ 0200 l ] 2reg4bit ] ; 251 | 252 | ( two 3-bit registers ) 253 | ( d r op ) 254 | ( oooo oooo oddd orrr ) 255 | 256 | : 2reg3bit ( d r op -- ) 257 | ] >r 258 | [ $ 0007 l ] and ] r> ] or ] >r 259 | [ $ 0007 l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 260 | 261 | : mulsu, [ $ 0300 l ] 2reg3bit ] ; 262 | : fmul, [ $ 0308 l ] 2reg3bit ] ; 263 | : fmuls, [ $ 0380 l ] 2reg3bit ] ; 264 | : fmulsu, [ $ 0388 l ] 2reg3bit ] ; 265 | 266 | ( relative ) 267 | ( k op ) 268 | ( oooo kkkk kkkk kkkk ) 269 | 270 | : relative ( k op -- ) 271 | ] >r 272 | ] ihere ] - ] 1- [ $ 0fff l ] and ] r> ] or ] i, ] ; 273 | 274 | : rcall, [ $ d000 l ] relative ] ; 275 | : rjmp, [ $ c000 l ] relative ] ; 276 | 277 | ( one 5-bit register bit operation ) 278 | ( d b op ) 279 | ( oooo oood dddd obbb ) 280 | 281 | : 1reg5bitbit ( d b op -- ) 282 | ] >r 283 | [ $ 0007 l ] and ] r> ] or ] >r 284 | [ $ 001f l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 285 | 286 | : bld, [ $ f800 l ] 1reg5bitbit ] ; 287 | : bst, [ $ fa00 l ] 1reg5bitbit ] ; 288 | : sbrc, [ $ fc00 l ] 1reg5bitbit ] ; 289 | : sbrs, [ $ fe00 l ] 1reg5bitbit ] ; 290 | 291 | ( absolute ) 292 | ( doesn't handle 22-bit addresses yet ) 293 | ( k op ) 294 | ( oooo oook kkkk oook ) 295 | ( kkkk kkkk kkkk kkkk ) 296 | 297 | : absolute ( k op -- ) 298 | ] i, ] i, ] ; 299 | 300 | : call, [ $ 940e l ] absolute ] ; 301 | : jmp, [ $ 940c l ] absolute ] ; 302 | 303 | ( one i/o register bit operation ) 304 | ( a b op ) 305 | ( oooo oooo aaaa abbb ) 306 | 307 | : 1iobit ( a b op -- ) 308 | ] >r 309 | [ $ 0007 l ] and ] r> ] or ] >r 310 | [ $ 001f l ] and [ $ 3 l ] lshift ] r> ] or ] i, ] ; 311 | 312 | : cbi, [ $ 9800 l ] 1iobit ] ; 313 | : sbi, [ $ 9a00 l ] 1iobit ] ; 314 | : sbic, [ $ 9900 l ] 1iobit ] ; 315 | : sbis, [ $ 9b00 l ] 1iobit ] ; 316 | 317 | ( direct ) 318 | ( k r op ) 319 | ( oooo oood dddd oooo ) 320 | ( kkkk kkkk kkkk kkkk ) 321 | 322 | : direct ( k r op -- ) 323 | ] >r 324 | [ $ 001f l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] i, ] ; 325 | 326 | : sts, [ $ 9200 l ] direct ] ; 327 | : lds, ] swap [ $ 9000 l ] direct ] ; 328 | 329 | ( two words ) 330 | ( d r op ) 331 | ( oooo oooo dddd rrrr ) 332 | 333 | : 2words ( d r op -- ) 334 | ] >r 335 | [ $ 001e l ] and [ $ 1 l ] rshift ] r> ] or ] >r 336 | [ $ 001e l ] and [ $ 3 l ] lshift ] r> ] or ] i, ] ; 337 | 338 | : movw, [ $ 0100 l ] 2words ] ; 339 | 340 | ( indirect with displacement ) 341 | ( d q op ) 342 | ( ooqo qqod dddd oqqq ) 343 | 344 | : displacement ( d q op -- ) 345 | ] >r 346 | ] dup [ $ 0020 l ] and [ $ 8 l ] lshift ] r> ] or ] >r 347 | ] dup [ $ 0018 l ] and [ $ 7 l ] lshift ] r> ] or ] >r 348 | [ $ 0007 l ] and ] r> ] or ] >r 349 | [ $ 001f l ] and [ $ 4 l ] lshift ] r> ] or ] i, ] ; 350 | 351 | : lddy, [ $ 8008 l ] displacement ] ; 352 | : lddz, [ $ 8000 l ] displacement ] ; 353 | : stdy, ] swap [ $ 8208 l ] displacement ] ; 354 | : stdz, ] swap [ $ 8200 l ] displacement ] ; 355 | 356 | -------------------------------------------------------------------------------- /blocks/bit.avrforth: -------------------------------------------------------------------------------- 1 | ( bit operations ) 2 | 3 | : ll ] swap ] l ] l ] ; 4 | 5 | : get ( a b -- x) ] 2^ ] swap ] c@ ] and ] ones ] ; 6 | : set ( a b -- ) ] 2^ ] over ] c@ ] or ] swap ] c! ] ; 7 | : clear ( a b -- ) ] 2^ ] invert ] over ] c@ ] and ] swap ] c! ] ; 8 | : toggle ( a b --) ] 2dup ] get ] 0? ] if ] drop ] clear ] ; ] then ] drop ] set ] ; 9 | 10 | macro : set 11 | ] ?lit ] if 12 | ] ?lit ] if 13 | ] dup [ $ 20 l $ 40 l ] within ] if 14 | [ $ 20 l ] - ] swap ] sbi, ] ; 15 | ] then ] l 16 | ] then ] l 17 | ] then [ ' set l ] ,xt ] ; 18 | 19 | macro : clear 20 | ] ?lit ] if 21 | ] ?lit ] if 22 | ] dup [ $ 20 l $ 40 l ] within ] if 23 | [ $ 20 l ] - ] swap ] cbi, ] ; 24 | ] then ] l 25 | ] then ] l 26 | ] then [ ' clear l ] ,xt ] ; 27 | 28 | -------------------------------------------------------------------------------- /blocks/core.avrforth: -------------------------------------------------------------------------------- 1 | : drop ] drop ] ; 2 | : dup ] dup ] ; 3 | 4 | : [ ] ; 5 | : ( [ $ 0029 l ] word ] drop ] ; 6 | 7 | : low [ $ 00ff l ] and ] ; 8 | : high ] >< ] low ] ; 9 | 10 | ( constants ) 11 | : 0 [ $ 0000 l ] ; 12 | : 1 [ $ 0001 l ] ; 13 | : 2 [ $ 0002 l ] ; 14 | : 4 [ $ 0004 l ] ; 15 | : -1 [ $ ffff l ] ; 16 | 17 | ( variables ) 18 | : var c : ] here ] l c ; ] allot ] ; 19 | : evar c : ] ehere ] l c ; ] eallot ] ; 20 | : con c : [ ' const l ] ,xt ] i, ] ; 21 | 22 | ( math ) 23 | macro : 1+ [ $ 9601 l ] i, ] ; : 1+ ] 1+ ] ; 24 | macro : 1- [ $ 9701 l ] i, ] ; : 1- ] 1- ] ; 25 | macro : 2* [ $ 0f88 l ] i, [ $ 1f99 l ] i, ] ; : 2* ] 2* ] ; 26 | macro : 2/ [ $ 9595 l ] i, [ $ 9587 l ] i, ] ; : 2/ ] 2/ ] ; 27 | macro : invert [ $ 9580 l ] i, [ $ 9590 l ] i, ] ; 28 | : negate ] invert ] 1+ ] ; 29 | 30 | : 2^ ] 1 ] swap ] lshift ] ; 31 | 32 | : ntz ] dup ] 1- ] swap ] invert ] and ] ones ] ; 33 | 34 | ( conditionals ) 35 | macro : 0? [ $ 9600 l ] i, ] ; 36 | macro : ? ] ?lit ( literal only ) 37 | ] dup ] low ] imm [ $ e000 l ] or ] i, 38 | ] high ] imm [ $ e010 l ] or ] i, 39 | [ $ 1780 l ] i, [ $ 0791 l ] i, ] ; 40 | 41 | macro : if ] ihere [ $ f001 l ] i, ] ; 42 | macro : =if ] ihere [ $ f401 l ] i, ] ; 43 | macro : -if ] ihere [ $ f402 l ] i, ] ; 44 | macro : uint l ] ,xt ] ; 97 | macro : int; [ ' int> l ] ,xt c ;; ] ; 98 | 99 | macro : inton [ $ 9478 l ] i, ] ; : inton ] inton ] ; 100 | macro : intoff [ $ 94f8 l ] i, ] ; : intoff ] intoff ] ; 101 | 102 | ( postincrement ) 103 | : c@+ ] dup $ 1 l ] + ] swap ] c@ ] ; 104 | : @+ ] dup $ 2 l ] + ] swap ] @ ] ; 105 | : c!+ ] dup ] -rot ] c! $ 1 l ] + ] ; 106 | : !+ ] dup ] -rot ] ! $ 2 l ] + ] ; 107 | 108 | ( predecrement ) 109 | : c@- $ 1 l ] - ] dup ] c@ ] ; 110 | : @- $ 2 l ] - ] dup ] @ ] ; 111 | : c!- $ 1 l ] - ] dup ] -rot ] c! ] ; 112 | : !- $ 2 l ] - ] dup ] -rot ] ! ] ; 113 | 114 | ( double cell ) 115 | : 2@ ] dup [ $ 2 l ] + ] @ ] swap ] @ ] ; 116 | : 2! ] swap ] over ] ! [ $ 2 l ] + ] ! ] ; 117 | : 2drop ] drop ] drop ] ; 118 | : 2dup ] over ] over ] ; 119 | : 2swap ] rot ] >r ] rot ] r> ] ;; 120 | : 2over ] >r ] >r ] 2dup ] r> ] r> ] 2swap ] ; 121 | 122 | : d+ ] >r ] rot ] + ] swap ] u ] + ] ; 123 | : d- ] >r ] rot ] swap ] - ] swap ] u ] - ] ; 124 | 125 | : dinvert ] >r ] invert ] r> ] invert ] ; 126 | : d1+ ] swap ] 1+ ] if ] swap ] ; ] then ] swap ] 1+ ] ; 127 | : dnegate ] dinvert ] d1+ ] ; 128 | : extend ] 0? ] -if [ $ ffff l ] ; ] then [ $ 0000 l ] ; 129 | 130 | ( multiplication ) 131 | : * ] m* ] drop ] ; 132 | : u* ] um* ] drop ] ; 133 | 134 | ( division ) 135 | : m/mod 136 | ] 0? ] f@ ] >r ] r ] dnegate ] r> ] then 137 | ] >r ] 0? ] ] um/mod 138 | ] r> ] f! ] r ] extend ] r> ] m/mod ] ; 141 | : / ] /mod ] nip ] ; 142 | : mod ] /mod ] drop ] ; 143 | 144 | : */mod ] >r ] m* ] r> ] m/mod ] ; 145 | : */ ] */mod ] nip ] ; 146 | 147 | : u/mod [ $ 0000 l ] swap ] um/mod ] ; 148 | : u/ ] u/mod ] nip ] ; 149 | : umod ] u/mod ] drop ] ; 150 | 151 | : u*/mod ] >r ] um* ] r> ] um/mod ] ; 152 | : u*/ ] u*/mod ] nip ] ; 153 | 154 | ( counted loops ) 155 | macro : for ] ihere [ ' >r l ] ,xt ] ; 156 | : next' [ ' r> l ] ,xt c 1- ] >r 157 | ] ihere ] - ] 1- [ $ 007f l ] and ] 2* ] 2* ] 2* ] r> ] or ] i, 158 | c drop ] ; 159 | macro : next [ $ f401 l ] next' ] ; 160 | macro : -next [ $ f402 l ] next' ] ; 161 | 162 | ( hex output ) 163 | : h. ] # ] # ] # ] # ] drop ] space ] ; 164 | : b. ] >< ] # ] # ] drop ] space ] ; 165 | 166 | ( display wordlists ) 167 | : words' ] 0? ] if ] space ] dup ] 1+ ] itype ] i@ ] words' ] ; 168 | ] then ] drop ] ; 169 | : words ] link ] @ ] words' ] ; 170 | : macros ] mlink ] @ ] words' ] ; 171 | 172 | ( multitasking ) 173 | : task-init ( xt rs ds task -- ) 174 | ] dup ] >r ] + 175 | ] dup ] >r ] + 176 | ] swap ] >< ] swap ] !- 177 | ] r> $ 2 l ] - ] >< ] swap ] !- 178 | $ 1 l ] - ] r> ] ! ] ; 179 | : task-queue ( task -- ) 180 | ] me $ 2 l ] + ] @ 181 | ] over $ 2 l ] + ] ! 182 | ] me $ 2 l ] + ] ! ] ; 183 | : task-next ( task1 -- task2 ) 184 | $ 2 l ] + ] @ ] ; 185 | : task-prev' ( task1 task2 -- task3 ) 186 | ] dup ] task-next ] rot ] ?? ] =if ] drop ] drop ] ; 187 | ] then ] -rot ] nip ] task-prev' ] ; 188 | : task-prev ( task1 -- task2 ) 189 | ] dup ] task-prev' ] ; 190 | : task-dequeue ( task -- ) 191 | ] dup ] task-next ] swap ] task-prev $ 2 l ] + ] ! ] ; 192 | 193 | : wait ( reg mask -- ) 194 | ] over ] c@ ] over ] and ] 0? ] drop ] if 195 | ] drop ] drop ] ; 196 | ] then ] pause ] wait ] ; 197 | 198 | : within ] over ] - ] >r ] - ] r> ] - ] drop ] uc1 ( ca ea -- ca' ea' ) 9 | ] ec@+ ( ca ea' d ) 10 | ] rot ( ea' d ca ) 11 | ] c!+ ( ea' ca' ) 12 | ] swap ( ca' ea' ) 13 | ] ; 14 | 15 | : e>c ( ca ea n -- ) 16 | ] 0? ] if ] for ] e>c1 ] next ] drop ] drop ] ; ] then 17 | ] drop ] drop ] drop ] ; 18 | 19 | : c>e1 ( ca ea -- ea' ca' ) ] swap ] c@+ ] rot ] ec!+ ] ; 20 | 21 | : c>e ( ca ea n -- ) 22 | ] 0? ] if ] for ] c>e1 ] next ] drop ] drop ] ; ] then 23 | ] drop ] drop ] drop ] ; 24 | 25 | -------------------------------------------------------------------------------- /blocks/extend.avrforth: -------------------------------------------------------------------------------- 1 | ( extended precision arithmetic ) 2 | 3 | : +. 4 | temp0 ldy+, 5 | temp1 ldy+, 6 | tosl temp0 adc, 7 | tosh temp1 adc, 8 | ret, 9 | 10 | : t+ ] >r ] >r ] >r ] rot ] r> ] + ] rot ] r> ] +. ] rot ] r> ] +. ] ; 11 | 12 | : ut* ] dup ] >r ] rot ] um* ] rot [ $ 0 l ] swap 13 | ] r> ] um* [ $ 0 l ] -rot ] t+ ] ; 14 | 15 | : 2*. 16 | tosl rol, 17 | tosh rol, 18 | ret, 19 | 20 | : d2* ] swap ] 2* ] swap ] 2*. ] ; 21 | : t2* ] rot ] 2* ] rot ] 2*. ] rot ] 2*. ] ; 22 | 23 | : dlshift ] 0? ] if ] for ] d2* ] next ] ; ] then ] drop ] ; 24 | 25 | : 2/. 26 | tosh ror, 27 | tosl ror, 28 | ret, 29 | 30 | : d2/ ] 2/ ] swap ] 2/. ] swap ] ; 31 | : t2/ ] 2/ ] -rot ] 2/. ] -rot ] 2/. ] -rot ] ; 32 | 33 | : 1rshift 34 | tosh lsr, 35 | tosl ror, 36 | ret, 37 | 38 | : 1drshift ] 1rshift ] swap ] 2/. ] swap ] ; 39 | : drshift ] 0? ] if ] for ] 1drshift ] next ] ; ] then ] drop ] ; 40 | 41 | -------------------------------------------------------------------------------- /blocks/flag.avrforth: -------------------------------------------------------------------------------- 1 | ( byte flags ) 2 | 3 | : on [ $ ff l ] swap ] c! ] ; 4 | : off [ $ 00 l ] swap ] c! ] ; 5 | 6 | -------------------------------------------------------------------------------- /blocks/font4x6.avrforth: -------------------------------------------------------------------------------- 1 | ( # counting starts at 0x20) 2 | 3 | \ $ 0 >oled 0 >oled $ 7b >oled $ 00 >oled 4 | \ $ 1010 1 lshift $ 3400 high imm or h. 5 | 6 | \ push start of iallot on stack, and then keep it in fontstart 7 | \ is this usually done with create? how should this be done with avrforth? 8 | 9 | ihere $ 60 2* iallot : fontstart l ] ; 10 | : glyphr1 ] imm ] swap [ $ 1 l ] lshift ] or ] ; 11 | : >glyph ] swap ] over ] high ] glyphr1 ] -rot ] low ] glyphr1 ] swap ] ; 12 | : glyphcreate [ $ 0 l [ $ 0 l ] ; ( initialized to blank) 13 | : glyph! ( g0 g1 idx -- ) ] 2* ] fontstart ] + ] swap ] over ] i! ] 1+ ] i! ] ; 14 | : glyph@ ( idx -- g0 g1 ) ] 2* ] fontstart ] + ] dup ] 1+ ] i@ ] swap ] i@ ] ; 15 | : glyph>oled ] dup 16 | ] high ] >oled 17 | ] low ] >oled ] dup 18 | ] high ] >oled 19 | ] low ] >oled ] ; 20 | : c>gi [ $ 20 l ] - [ $ 7f l ] and ] ; 21 | 22 | ( display c on screen ) 23 | : oled.emit ( c -- ) ] c>gi ] glyph@ ] glyph>oled ] ; 24 | 25 | ( print RAM contents in one line ) 26 | ( ca must contain at least $ 20 bytes ) 27 | : oledglyph 32 | $ 0000 >glyph 33 | $ 0000 >glyph 34 | $ 0000 >glyph 35 | $ 0000 >glyph 36 | $ 0000 >glyph 37 | $ 0000 >glyph 38 | $ 0000 >glyph 39 | $ 00 glyph! 40 | 41 | glyphcreate 42 | $ 0000 >glyph 43 | $ 0010 >glyph 44 | $ 0010 >glyph 45 | $ 0010 >glyph 46 | $ 0010 >glyph 47 | $ 0000 >glyph 48 | $ 0010 >glyph 49 | $ 0000 >glyph 50 | $ 01 glyph! 51 | 52 | glyphcreate 53 | $ 0000 >glyph 54 | $ 0101 >glyph 55 | $ 0101 >glyph 56 | $ 0000 >glyph 57 | $ 0000 >glyph 58 | $ 0000 >glyph 59 | $ 0000 >glyph 60 | $ 0000 >glyph 61 | $ 02 glyph! 62 | 63 | glyphcreate 64 | $ 0000 >glyph 65 | $ 0000 >glyph 66 | $ 0010 >glyph 67 | $ 0111 >glyph 68 | $ 0010 >glyph 69 | $ 0111 >glyph 70 | $ 0010 >glyph 71 | $ 0000 >glyph 72 | $ 03 glyph! 73 | 74 | glyphcreate 75 | $ 0000 >glyph 76 | $ 0010 >glyph 77 | $ 0111 >glyph 78 | $ 0100 >glyph 79 | $ 0111 >glyph 80 | $ 0001 >glyph 81 | $ 0111 >glyph 82 | $ 0010 >glyph 83 | $ 04 glyph! 84 | 85 | glyphcreate 86 | $ 0000 >glyph 87 | $ 0101 >glyph 88 | $ 0001 >glyph 89 | $ 0010 >glyph 90 | $ 0010 >glyph 91 | $ 0100 >glyph 92 | $ 0101 >glyph 93 | $ 0000 >glyph 94 | $ 05 glyph! 95 | 96 | glyphcreate 97 | $ 0000 >glyph 98 | $ 0010 >glyph 99 | $ 0101 >glyph 100 | $ 0010 >glyph 101 | $ 0110 >glyph 102 | $ 0101 >glyph 103 | $ 0110 >glyph 104 | $ 0000 >glyph 105 | $ 06 glyph! 106 | 107 | glyphcreate 108 | $ 0000 >glyph 109 | $ 0010 >glyph 110 | $ 0100 >glyph 111 | $ 0000 >glyph 112 | $ 0000 >glyph 113 | $ 0000 >glyph 114 | $ 0000 >glyph 115 | $ 0000 >glyph 116 | $ 07 glyph! 117 | 118 | glyphcreate 119 | $ 0000 >glyph 120 | $ 0010 >glyph 121 | $ 0100 >glyph 122 | $ 0100 >glyph 123 | $ 0100 >glyph 124 | $ 0100 >glyph 125 | $ 0010 >glyph 126 | $ 0000 >glyph 127 | $ 08 glyph! 128 | 129 | glyphcreate 130 | $ 0000 >glyph 131 | $ 0100 >glyph 132 | $ 0010 >glyph 133 | $ 0010 >glyph 134 | $ 0010 >glyph 135 | $ 0010 >glyph 136 | $ 0100 >glyph 137 | $ 0000 >glyph 138 | $ 09 glyph! 139 | 140 | glyphcreate 141 | $ 0000 >glyph 142 | $ 0000 >glyph 143 | $ 0101 >glyph 144 | $ 0010 >glyph 145 | $ 0111 >glyph 146 | $ 0010 >glyph 147 | $ 0101 >glyph 148 | $ 0000 >glyph 149 | $ 0a glyph! 150 | 151 | glyphcreate 152 | $ 0000 >glyph 153 | $ 0010 >glyph 154 | $ 0010 >glyph 155 | $ 0111 >glyph 156 | $ 0010 >glyph 157 | $ 0010 >glyph 158 | $ 0000 >glyph 159 | $ 0000 >glyph 160 | $ 0b glyph! 161 | 162 | glyphcreate 163 | $ 0000 >glyph 164 | $ 0000 >glyph 165 | $ 0000 >glyph 166 | $ 0000 >glyph 167 | $ 0010 >glyph 168 | $ 0010 >glyph 169 | $ 0100 >glyph 170 | $ 0c glyph! 171 | 172 | glyphcreate 173 | $ 0000 >glyph 174 | $ 0000 >glyph 175 | $ 0000 >glyph 176 | $ 0000 >glyph 177 | $ 0111 >glyph 178 | $ 0000 >glyph 179 | $ 0000 >glyph 180 | $ 0000 >glyph 181 | $ 0d glyph! 182 | 183 | glyphcreate 184 | $ 0000 >glyph 185 | $ 0000 >glyph 186 | $ 0000 >glyph 187 | $ 0000 >glyph 188 | $ 0000 >glyph 189 | $ 0110 >glyph 190 | $ 0110 >glyph 191 | $ 0000 >glyph 192 | $ e glyph! 193 | 194 | glyphcreate 195 | $ 0000 >glyph 196 | $ 0001 >glyph 197 | $ 0001 >glyph 198 | $ 0010 >glyph 199 | $ 0010 >glyph 200 | $ 0100 >glyph 201 | $ 0100 >glyph 202 | $ 0000 >glyph 203 | $ 0f glyph! 204 | 205 | glyphcreate 206 | $ 0000 >glyph 207 | $ 0010 >glyph 208 | $ 0101 >glyph 209 | $ 0101 >glyph 210 | $ 0101 >glyph 211 | $ 0101 >glyph 212 | $ 0010 >glyph 213 | $ 0000 >glyph 214 | $ 10 glyph! 215 | 216 | glyphcreate 217 | $ 0000 >glyph 218 | $ 0010 >glyph 219 | $ 0110 >glyph 220 | $ 0010 >glyph 221 | $ 0010 >glyph 222 | $ 0010 >glyph 223 | $ 0111 >glyph 224 | $ 0000 >glyph 225 | $ 11 glyph! 226 | 227 | glyphcreate 228 | $ 0000 >glyph 229 | $ 0010 >glyph 230 | $ 0101 >glyph 231 | $ 0001 >glyph 232 | $ 0010 >glyph 233 | $ 0100 >glyph 234 | $ 0111 >glyph 235 | $ 0000 >glyph 236 | $ 12 glyph! 237 | 238 | glyphcreate 239 | $ 0000 >glyph 240 | $ 0010 >glyph 241 | $ 0101 >glyph 242 | $ 0010 >glyph 243 | $ 0001 >glyph 244 | $ 0101 >glyph 245 | $ 0010 >glyph 246 | $ 0000 >glyph 247 | $ 13 glyph! 248 | 249 | glyphcreate 250 | $ 0000 >glyph 251 | $ 0101 >glyph 252 | $ 0101 >glyph 253 | $ 0111 >glyph 254 | $ 0001 >glyph 255 | $ 0001 >glyph 256 | $ 0001 >glyph 257 | $ 0000 >glyph 258 | $ 14 glyph! 259 | 260 | glyphcreate 261 | $ 0000 >glyph 262 | $ 0111 >glyph 263 | $ 0100 >glyph 264 | $ 0110 >glyph 265 | $ 0001 >glyph 266 | $ 0101 >glyph 267 | $ 0010 >glyph 268 | $ 0000 >glyph 269 | $ 15 glyph! 270 | 271 | glyphcreate 272 | $ 0000 >glyph 273 | $ 0011 >glyph 274 | $ 0100 >glyph 275 | $ 0110 >glyph 276 | $ 0101 >glyph 277 | $ 0101 >glyph 278 | $ 0010 >glyph 279 | $ 0000 >glyph 280 | $ 16 glyph! 281 | 282 | glyphcreate 283 | $ 0000 >glyph 284 | $ 0111 >glyph 285 | $ 0001 >glyph 286 | $ 0001 >glyph 287 | $ 0010 >glyph 288 | $ 0100 >glyph 289 | $ 0100 >glyph 290 | $ 0000 >glyph 291 | $ 17 glyph! 292 | 293 | glyphcreate 294 | $ 0000 >glyph 295 | $ 0010 >glyph 296 | $ 0101 >glyph 297 | $ 0010 >glyph 298 | $ 0101 >glyph 299 | $ 0101 >glyph 300 | $ 0010 >glyph 301 | $ 0000 >glyph 302 | $ 18 glyph! 303 | 304 | glyphcreate 305 | $ 0000 >glyph 306 | $ 0010 >glyph 307 | $ 0101 >glyph 308 | $ 0101 >glyph 309 | $ 0011 >glyph 310 | $ 0101 >glyph 311 | $ 0010 >glyph 312 | $ 0000 >glyph 313 | $ 19 glyph! 314 | 315 | glyphcreate 316 | $ 0000 >glyph 317 | $ 0000 >glyph 318 | $ 0000 >glyph 319 | $ 0010 >glyph 320 | $ 0000 >glyph 321 | $ 0010 >glyph 322 | $ 0000 >glyph 323 | $ 0000 >glyph 324 | $ 1a glyph! 325 | 326 | glyphcreate 327 | $ 0000 >glyph 328 | $ 0000 >glyph 329 | $ 0010 >glyph 330 | $ 0000 >glyph 331 | $ 0000 >glyph 332 | $ 0010 >glyph 333 | $ 0010 >glyph 334 | $ 0100 >glyph 335 | $ 1b glyph! 336 | 337 | glyphcreate 338 | $ 0000 >glyph 339 | $ 0000 >glyph 340 | $ 0001 >glyph 341 | $ 0010 >glyph 342 | $ 0100 >glyph 343 | $ 0010 >glyph 344 | $ 0001 >glyph 345 | $ 0000 >glyph 346 | $ 1c glyph! 347 | 348 | glyphcreate 349 | $ 0000 >glyph 350 | $ 0000 >glyph 351 | $ 0000 >glyph 352 | $ 0111 >glyph 353 | $ 0000 >glyph 354 | $ 0111 >glyph 355 | $ 0000 >glyph 356 | $ 0000 >glyph 357 | $ 1d glyph! 358 | 359 | glyphcreate 360 | $ 0000 >glyph 361 | $ 0000 >glyph 362 | $ 0100 >glyph 363 | $ 0010 >glyph 364 | $ 0001 >glyph 365 | $ 0010 >glyph 366 | $ 0100 >glyph 367 | $ 0000 >glyph 368 | $ 1e glyph! 369 | 370 | glyphcreate 371 | $ 0000 >glyph 372 | $ 0010 >glyph 373 | $ 0101 >glyph 374 | $ 0001 >glyph 375 | $ 0010 >glyph 376 | $ 0000 >glyph 377 | $ 0010 >glyph 378 | $ 0000 >glyph 379 | $ 1f glyph! 380 | 381 | glyphcreate 382 | $ 0000 >glyph 383 | $ 0110 >glyph 384 | $ 1001 >glyph 385 | $ 1011 >glyph 386 | $ 1011 >glyph 387 | $ 1000 >glyph 388 | $ 0110 >glyph 389 | $ 0000 >glyph 390 | $ 20 glyph! 391 | 392 | glyphcreate 393 | $ 0000 >glyph 394 | $ 0010 >glyph 395 | $ 0101 >glyph 396 | $ 0111 >glyph 397 | $ 0101 >glyph 398 | $ 0101 >glyph 399 | $ 0101 >glyph 400 | $ 0000 >glyph 401 | $ 21 glyph! 402 | 403 | glyphcreate 404 | $ 0000 >glyph 405 | $ 0110 >glyph 406 | $ 0101 >glyph 407 | $ 0110 >glyph 408 | $ 0101 >glyph 409 | $ 0101 >glyph 410 | $ 0110 >glyph 411 | $ 0000 >glyph 412 | $ 22 glyph! 413 | 414 | glyphcreate 415 | $ 0000 >glyph 416 | $ 0010 >glyph 417 | $ 0101 >glyph 418 | $ 0100 >glyph 419 | $ 0100 >glyph 420 | $ 0101 >glyph 421 | $ 0010 >glyph 422 | $ 0000 >glyph 423 | $ 23 glyph! 424 | 425 | glyphcreate 426 | $ 0000 >glyph 427 | $ 0110 >glyph 428 | $ 0101 >glyph 429 | $ 0101 >glyph 430 | $ 0101 >glyph 431 | $ 0101 >glyph 432 | $ 0110 >glyph 433 | $ 0000 >glyph 434 | $ 24 glyph! 435 | 436 | glyphcreate 437 | $ 0000 >glyph 438 | $ 0111 >glyph 439 | $ 0100 >glyph 440 | $ 0110 >glyph 441 | $ 0100 >glyph 442 | $ 0100 >glyph 443 | $ 0111 >glyph 444 | $ 0000 >glyph 445 | $ 25 glyph! 446 | 447 | glyphcreate 448 | $ 0000 >glyph 449 | $ 0111 >glyph 450 | $ 0100 >glyph 451 | $ 0111 >glyph 452 | $ 0100 >glyph 453 | $ 0100 >glyph 454 | $ 0100 >glyph 455 | $ 0000 >glyph 456 | $ 26 glyph! 457 | 458 | glyphcreate 459 | $ 0000 >glyph 460 | $ 0010 >glyph 461 | $ 0101 >glyph 462 | $ 0100 >glyph 463 | $ 0111 >glyph 464 | $ 0101 >glyph 465 | $ 0010 >glyph 466 | $ 0000 >glyph 467 | $ 27 glyph! 468 | 469 | glyphcreate 470 | $ 0000 >glyph 471 | $ 0101 >glyph 472 | $ 0101 >glyph 473 | $ 0111 >glyph 474 | $ 0101 >glyph 475 | $ 0101 >glyph 476 | $ 0101 >glyph 477 | $ 0000 >glyph 478 | $ 28 glyph! 479 | 480 | glyphcreate 481 | $ 0000 >glyph 482 | $ 0111 >glyph 483 | $ 0010 >glyph 484 | $ 0010 >glyph 485 | $ 0010 >glyph 486 | $ 0010 >glyph 487 | $ 0111 >glyph 488 | $ 0000 >glyph 489 | $ 29 glyph! 490 | 491 | glyphcreate 492 | $ 0000 >glyph 493 | $ 0011 >glyph 494 | $ 0001 >glyph 495 | $ 0001 >glyph 496 | $ 0001 >glyph 497 | $ 0101 >glyph 498 | $ 0010 >glyph 499 | $ 0000 >glyph 500 | $ 2a glyph! 501 | 502 | glyphcreate 503 | $ 0000 >glyph 504 | $ 0101 >glyph 505 | $ 0101 >glyph 506 | $ 0110 >glyph 507 | $ 0101 >glyph 508 | $ 0101 >glyph 509 | $ 0101 >glyph 510 | $ 0000 >glyph 511 | $ 2b glyph! 512 | 513 | glyphcreate 514 | $ 0000 >glyph 515 | $ 0100 >glyph 516 | $ 0100 >glyph 517 | $ 0100 >glyph 518 | $ 0100 >glyph 519 | $ 0100 >glyph 520 | $ 0111 >glyph 521 | $ 0000 >glyph 522 | $ 2c glyph! 523 | 524 | glyphcreate 525 | $ 0000 >glyph 526 | $ 0101 >glyph 527 | $ 0111 >glyph 528 | $ 0111 >glyph 529 | $ 0101 >glyph 530 | $ 0101 >glyph 531 | $ 0101 >glyph 532 | $ 0000 >glyph 533 | $ 2d glyph! 534 | 535 | glyphcreate 536 | $ 0000 >glyph 537 | $ 0101 >glyph 538 | $ 0101 >glyph 539 | $ 0111 >glyph 540 | $ 0111 >glyph 541 | $ 0101 >glyph 542 | $ 0101 >glyph 543 | $ 0000 >glyph 544 | $ 2e glyph! 545 | 546 | glyphcreate 547 | $ 0000 >glyph 548 | $ 0010 >glyph 549 | $ 0101 >glyph 550 | $ 0101 >glyph 551 | $ 0101 >glyph 552 | $ 0101 >glyph 553 | $ 0010 >glyph 554 | $ 0000 >glyph 555 | $ 2f glyph! 556 | 557 | glyphcreate 558 | $ 0000 >glyph 559 | $ 0110 >glyph 560 | $ 0101 >glyph 561 | $ 0101 >glyph 562 | $ 0110 >glyph 563 | $ 0100 >glyph 564 | $ 0100 >glyph 565 | $ 0000 >glyph 566 | $ 30 glyph! 567 | 568 | glyphcreate 569 | $ 0000 >glyph 570 | $ 0010 >glyph 571 | $ 0101 >glyph 572 | $ 0101 >glyph 573 | $ 0111 >glyph 574 | $ 0111 >glyph 575 | $ 0011 >glyph 576 | $ 0000 >glyph 577 | $ 31 glyph! 578 | 579 | glyphcreate 580 | $ 0000 >glyph 581 | $ 0110 >glyph 582 | $ 0101 >glyph 583 | $ 0101 >glyph 584 | $ 0110 >glyph 585 | $ 0101 >glyph 586 | $ 0101 >glyph 587 | $ 0000 >glyph 588 | $ 32 glyph! 589 | 590 | glyphcreate 591 | $ 0000 >glyph 592 | $ 0010 >glyph 593 | $ 0101 >glyph 594 | $ 0010 >glyph 595 | $ 0001 >glyph 596 | $ 0101 >glyph 597 | $ 0010 >glyph 598 | $ 0000 >glyph 599 | $ 33 glyph! 600 | 601 | glyphcreate 602 | $ 0000 >glyph 603 | $ 0111 >glyph 604 | $ 0010 >glyph 605 | $ 0010 >glyph 606 | $ 0010 >glyph 607 | $ 0010 >glyph 608 | $ 0010 >glyph 609 | $ 0000 >glyph 610 | $ 34 glyph! 611 | 612 | glyphcreate 613 | $ 0000 >glyph 614 | $ 0101 >glyph 615 | $ 0101 >glyph 616 | $ 0101 >glyph 617 | $ 0101 >glyph 618 | $ 0101 >glyph 619 | $ 0010 >glyph 620 | $ 0000 >glyph 621 | $ 35 glyph! 622 | 623 | glyphcreate 624 | $ 0000 >glyph 625 | $ 0101 >glyph 626 | $ 0101 >glyph 627 | $ 0101 >glyph 628 | $ 0101 >glyph 629 | $ 0010 >glyph 630 | $ 0010 >glyph 631 | $ 0000 >glyph 632 | $ 36 glyph! 633 | 634 | glyphcreate 635 | $ 0000 >glyph 636 | $ 0101 >glyph 637 | $ 0101 >glyph 638 | $ 0101 >glyph 639 | $ 0111 >glyph 640 | $ 0111 >glyph 641 | $ 0101 >glyph 642 | $ 0000 >glyph 643 | $ 37 glyph! 644 | 645 | glyphcreate 646 | $ 0000 >glyph 647 | $ 0101 >glyph 648 | $ 0101 >glyph 649 | $ 0010 >glyph 650 | $ 0101 >glyph 651 | $ 0101 >glyph 652 | $ 0101 >glyph 653 | $ 0000 >glyph 654 | $ 38 glyph! 655 | 656 | glyphcreate 657 | $ 0000 >glyph 658 | $ 0101 >glyph 659 | $ 0101 >glyph 660 | $ 0101 >glyph 661 | $ 0010 >glyph 662 | $ 0010 >glyph 663 | $ 0010 >glyph 664 | $ 0000 >glyph 665 | $ 39 glyph! 666 | 667 | glyphcreate 668 | $ 0000 >glyph 669 | $ 0111 >glyph 670 | $ 0001 >glyph 671 | $ 0010 >glyph 672 | $ 0010 >glyph 673 | $ 0100 >glyph 674 | $ 0111 >glyph 675 | $ 0000 >glyph 676 | $ 3a glyph! 677 | 678 | glyphcreate 679 | $ 0000 >glyph 680 | $ 0111 >glyph 681 | $ 0100 >glyph 682 | $ 0100 >glyph 683 | $ 0100 >glyph 684 | $ 0100 >glyph 685 | $ 0111 >glyph 686 | $ 0000 >glyph 687 | $ 3b glyph! 688 | 689 | glyphcreate 690 | $ 0000 >glyph 691 | $ 0100 >glyph 692 | $ 0100 >glyph 693 | $ 0010 >glyph 694 | $ 0010 >glyph 695 | $ 0001 >glyph 696 | $ 0001 >glyph 697 | $ 0000 >glyph 698 | $ 3c glyph! 699 | 700 | glyphcreate 701 | $ 0000 >glyph 702 | $ 0111 >glyph 703 | $ 0001 >glyph 704 | $ 0001 >glyph 705 | $ 0001 >glyph 706 | $ 0001 >glyph 707 | $ 0111 >glyph 708 | $ 0000 >glyph 709 | $ 3d glyph! 710 | 711 | glyphcreate 712 | $ 0000 >glyph 713 | $ 0010 >glyph 714 | $ 0111 >glyph 715 | $ 0010 >glyph 716 | $ 0010 >glyph 717 | $ 0010 >glyph 718 | $ 0010 >glyph 719 | $ 0000 >glyph 720 | $ 3e glyph! 721 | 722 | glyphcreate 723 | $ 0000 >glyph 724 | $ 0000 >glyph 725 | $ 0000 >glyph 726 | $ 0000 >glyph 727 | $ 0000 >glyph 728 | $ 0000 >glyph 729 | $ 1111 >glyph 730 | $ 0000 >glyph 731 | $ 3f glyph! 732 | 733 | glyphcreate 734 | $ 0000 >glyph 735 | $ 0010 >glyph 736 | $ 0101 >glyph 737 | $ 0100 >glyph 738 | $ 0110 >glyph 739 | $ 0100 >glyph 740 | $ 0111 >glyph 741 | $ 0000 >glyph 742 | $ 40 glyph! 743 | 744 | glyphcreate 745 | $ 0000 >glyph 746 | $ 0000 >glyph 747 | $ 0110 >glyph 748 | $ 0001 >glyph 749 | $ 0011 >glyph 750 | $ 0101 >glyph 751 | $ 0011 >glyph 752 | $ 0000 >glyph 753 | $ 41 glyph! 754 | 755 | glyphcreate 756 | $ 0000 >glyph 757 | $ 0100 >glyph 758 | $ 0100 >glyph 759 | $ 0110 >glyph 760 | $ 0101 >glyph 761 | $ 0101 >glyph 762 | $ 0110 >glyph 763 | $ 0000 >glyph 764 | $ 42 glyph! 765 | 766 | glyphcreate 767 | $ 0000 >glyph 768 | $ 0000 >glyph 769 | $ 0010 >glyph 770 | $ 0101 >glyph 771 | $ 0100 >glyph 772 | $ 0101 >glyph 773 | $ 0010 >glyph 774 | $ 0000 >glyph 775 | $ 43 glyph! 776 | 777 | glyphcreate 778 | $ 0000 >glyph 779 | $ 0001 >glyph 780 | $ 0001 >glyph 781 | $ 0011 >glyph 782 | $ 0101 >glyph 783 | $ 0101 >glyph 784 | $ 0010 >glyph 785 | $ 0000 >glyph 786 | $ 44 glyph! 787 | 788 | glyphcreate 789 | $ 0000 >glyph 790 | $ 0000 >glyph 791 | $ 0010 >glyph 792 | $ 0101 >glyph 793 | $ 0110 >glyph 794 | $ 0100 >glyph 795 | $ 0011 >glyph 796 | $ 0000 >glyph 797 | $ 45 glyph! 798 | 799 | glyphcreate 800 | $ 0000 >glyph 801 | $ 0010 >glyph 802 | $ 0101 >glyph 803 | $ 0100 >glyph 804 | $ 0110 >glyph 805 | $ 0100 >glyph 806 | $ 0100 >glyph 807 | $ 0000 >glyph 808 | $ 46 glyph! 809 | 810 | glyphcreate 811 | $ 0000 >glyph 812 | $ 0000 >glyph 813 | $ 0010 >glyph 814 | $ 0101 >glyph 815 | $ 0101 >glyph 816 | $ 0011 >glyph 817 | $ 0101 >glyph 818 | $ 0010 >glyph 819 | $ 47 glyph! 820 | 821 | glyphcreate 822 | $ 0000 >glyph 823 | $ 0100 >glyph 824 | $ 0100 >glyph 825 | $ 0110 >glyph 826 | $ 0101 >glyph 827 | $ 0101 >glyph 828 | $ 0101 >glyph 829 | $ 0000 >glyph 830 | $ 48 glyph! 831 | 832 | glyphcreate 833 | $ 0000 >glyph 834 | $ 0010 >glyph 835 | $ 0000 >glyph 836 | $ 0110 >glyph 837 | $ 0010 >glyph 838 | $ 0010 >glyph 839 | $ 0111 >glyph 840 | $ 0000 >glyph 841 | $ 49 glyph! 842 | 843 | glyphcreate 844 | $ 0000 >glyph 845 | $ 0001 >glyph 846 | $ 0000 >glyph 847 | $ 0011 >glyph 848 | $ 0001 >glyph 849 | $ 0001 >glyph 850 | $ 0101 >glyph 851 | $ 0010 >glyph 852 | $ 4a glyph! 853 | 854 | glyphcreate 855 | $ 0000 >glyph 856 | $ 0100 >glyph 857 | $ 0100 >glyph 858 | $ 0101 >glyph 859 | $ 0110 >glyph 860 | $ 0101 >glyph 861 | $ 0101 >glyph 862 | $ 0000 >glyph 863 | $ 4b glyph! 864 | 865 | glyphcreate 866 | $ 0000 >glyph 867 | $ 0100 >glyph 868 | $ 0100 >glyph 869 | $ 0100 >glyph 870 | $ 0100 >glyph 871 | $ 0101 >glyph 872 | $ 0010 >glyph 873 | $ 0000 >glyph 874 | $ 4c glyph! 875 | 876 | glyphcreate 877 | $ 0000 >glyph 878 | $ 0000 >glyph 879 | $ 0101 >glyph 880 | $ 0111 >glyph 881 | $ 0111 >glyph 882 | $ 0101 >glyph 883 | $ 0101 >glyph 884 | $ 0000 >glyph 885 | $ 4d glyph! 886 | 887 | glyphcreate 888 | $ 0000 >glyph 889 | $ 0000 >glyph 890 | $ 0110 >glyph 891 | $ 0101 >glyph 892 | $ 0101 >glyph 893 | $ 0101 >glyph 894 | $ 0101 >glyph 895 | $ 0000 >glyph 896 | $ 4e glyph! 897 | 898 | glyphcreate 899 | $ 0000 >glyph 900 | $ 0000 >glyph 901 | $ 0010 >glyph 902 | $ 0101 >glyph 903 | $ 0101 >glyph 904 | $ 0101 >glyph 905 | $ 0010 >glyph 906 | $ 0000 >glyph 907 | $ 4f glyph! 908 | 909 | glyphcreate 910 | $ 0000 >glyph 911 | $ 0000 >glyph 912 | $ 0110 >glyph 913 | $ 0101 >glyph 914 | $ 0101 >glyph 915 | $ 0110 >glyph 916 | $ 0100 >glyph 917 | $ 0100 >glyph 918 | $ 50 glyph! 919 | 920 | glyphcreate 921 | $ 0000 >glyph 922 | $ 0000 >glyph 923 | $ 0011 >glyph 924 | $ 0101 >glyph 925 | $ 0101 >glyph 926 | $ 0011 >glyph 927 | $ 0001 >glyph 928 | $ 0001 >glyph 929 | $ 51 glyph! 930 | 931 | glyphcreate 932 | $ 0000 >glyph 933 | $ 0000 >glyph 934 | $ 0110 >glyph 935 | $ 0101 >glyph 936 | $ 0100 >glyph 937 | $ 0100 >glyph 938 | $ 0100 >glyph 939 | $ 0000 >glyph 940 | $ 52 glyph! 941 | 942 | glyphcreate 943 | $ 0000 >glyph 944 | $ 0000 >glyph 945 | $ 0011 >glyph 946 | $ 0100 >glyph 947 | $ 0010 >glyph 948 | $ 0001 >glyph 949 | $ 0110 >glyph 950 | $ 0000 >glyph 951 | $ 53 glyph! 952 | 953 | glyphcreate 954 | $ 0000 >glyph 955 | $ 0100 >glyph 956 | $ 0111 >glyph 957 | $ 0100 >glyph 958 | $ 0100 >glyph 959 | $ 0101 >glyph 960 | $ 0010 >glyph 961 | $ 0000 >glyph 962 | $ 54 glyph! 963 | 964 | glyphcreate 965 | $ 0000 >glyph 966 | $ 0000 >glyph 967 | $ 0101 >glyph 968 | $ 0101 >glyph 969 | $ 0101 >glyph 970 | $ 0101 >glyph 971 | $ 0010 >glyph 972 | $ 0000 >glyph 973 | $ 55 glyph! 974 | 975 | glyphcreate 976 | $ 0000 >glyph 977 | $ 0000 >glyph 978 | $ 0101 >glyph 979 | $ 0101 >glyph 980 | $ 0101 >glyph 981 | $ 0010 >glyph 982 | $ 0010 >glyph 983 | $ 0000 >glyph 984 | $ 56 glyph! 985 | 986 | glyphcreate 987 | $ 0000 >glyph 988 | $ 0000 >glyph 989 | $ 0101 >glyph 990 | $ 0101 >glyph 991 | $ 0111 >glyph 992 | $ 0111 >glyph 993 | $ 0101 >glyph 994 | $ 0000 >glyph 995 | $ 57 glyph! 996 | 997 | glyphcreate 998 | $ 0000 >glyph 999 | $ 0000 >glyph 1000 | $ 0101 >glyph 1001 | $ 0101 >glyph 1002 | $ 0010 >glyph 1003 | $ 0101 >glyph 1004 | $ 0101 >glyph 1005 | $ 0000 >glyph 1006 | $ 58 glyph! 1007 | 1008 | glyphcreate 1009 | $ 0000 >glyph 1010 | $ 0000 >glyph 1011 | $ 0101 >glyph 1012 | $ 0101 >glyph 1013 | $ 0011 >glyph 1014 | $ 0001 >glyph 1015 | $ 0101 >glyph 1016 | $ 0010 >glyph 1017 | $ 59 glyph! 1018 | 1019 | glyphcreate 1020 | $ 0000 >glyph 1021 | $ 0000 >glyph 1022 | $ 0111 >glyph 1023 | $ 0001 >glyph 1024 | $ 0010 >glyph 1025 | $ 0100 >glyph 1026 | $ 0111 >glyph 1027 | $ 0000 >glyph 1028 | $ 5a glyph! 1029 | 1030 | glyphcreate 1031 | $ 0000 >glyph 1032 | $ 0000 >glyph 1033 | $ 0001 >glyph 1034 | $ 0010 >glyph 1035 | $ 0110 >glyph 1036 | $ 0010 >glyph 1037 | $ 0001 >glyph 1038 | $ 0000 >glyph 1039 | $ 5b glyph! 1040 | 1041 | glyphcreate 1042 | $ 0000 >glyph 1043 | $ 0010 >glyph 1044 | $ 0010 >glyph 1045 | $ 0010 >glyph 1046 | $ 0010 >glyph 1047 | $ 0010 >glyph 1048 | $ 0010 >glyph 1049 | $ 0000 >glyph 1050 | $ 5c glyph! 1051 | 1052 | glyphcreate 1053 | $ 0000 >glyph 1054 | $ 0000 >glyph 1055 | $ 0100 >glyph 1056 | $ 0010 >glyph 1057 | $ 0011 >glyph 1058 | $ 0010 >glyph 1059 | $ 0100 >glyph 1060 | $ 0000 >glyph 1061 | $ 5d glyph! 1062 | 1063 | glyphcreate 1064 | $ 0000 >glyph 1065 | $ 0000 >glyph 1066 | $ 1010 >glyph 1067 | $ 0101 >glyph 1068 | $ 0000 >glyph 1069 | $ 0000 >glyph 1070 | $ 0000 >glyph 1071 | $ 0000 >glyph 1072 | $ 5e glyph! 1073 | 1074 | glyphcreate 1075 | $ 0000 >glyph 1076 | $ 0110 >glyph 1077 | $ 1001 >glyph 1078 | $ 0110 >glyph 1079 | $ 1100 >glyph 1080 | $ 0110 >glyph 1081 | $ 1001 >glyph 1082 | $ 0110 >glyph 1083 | $ 5f glyph! 1084 | 1085 | -------------------------------------------------------------------------------- /blocks/lerp.avrforth: -------------------------------------------------------------------------------- 1 | ( linear interpolation ) 2 | 3 | : um/ ] um/mod ] nip ] ; 4 | : range ] over ] - ] -rot ] - [ $ 0 l ] swap ] rot ] um/ ] ; 5 | 6 | : lerp ( x length table -- y ) ] >r ] 2dup [ $ 10 l ] swap ] - ] rshift 7 | ] -rot ] lshift ] swap 8 | ] r> ] + ] dup ] >r 9 | ] dup ] 1+ ] i@ ] swap ] i@ ] - ] um* ] nip ] r> ] i@ ] + ] ; 10 | 11 | : i2@ ] dup ] i@ ] swap ] 1+ ] i@ ] ; 12 | : dlerp ( x length table -- dy ) ] >r ] 2dup [ $ 10 l ] swap ] - ] rshift ] 2* 13 | ] -rot ] lshift ] swap 14 | ] r> ] + ] dup ] >r 15 | ] dup [ $ 2 l ] + ] i2@ ] rot ] i2@ ] d- ] rot ] ut* ] rot ] drop 16 | ] r> ] i2@ ] d+ ] ; 17 | 18 | -------------------------------------------------------------------------------- /blocks/main.avrforth: -------------------------------------------------------------------------------- 1 | 2 | : start 3 | ] oled.init 4 | ] oled.splash 5 | ] morse.init 6 | ] morse.start ] ; 7 | 8 | lineclear line>e ( clean up line in eeprom ) 9 | 10 | mark 11 | ' start it e! -------------------------------------------------------------------------------- /blocks/miniboard.avrforth: -------------------------------------------------------------------------------- 1 | ( miniboard hardware interface) 2 | 3 | 4 | ( TODO we really need a timer here ... ) 5 | : slow [ $ 00ff l ] for ] pause ] next ] ; 6 | : slow2 [ $ 1fff l ] for ] pause ] next ] ; 7 | 8 | 9 | ( status leds ) 10 | : led.A ] portc [ $ 04 l ] ; 11 | : led.A' ] portc [ $ 03 l ] ; ( same as btn.X') 12 | 13 | -------------------------------------------------------------------------------- /blocks/morse.avrforth: -------------------------------------------------------------------------------- 1 | ( morse input, enter text with 3 buttons ) 2 | 3 | ( physical buttons ) 4 | : btn.A ] portb [ $ 04 l ] ; ( MISO must be output for SPI) 5 | : btn.A' ] portb [ $ 02 l ] ; ( PCINT2 ) 6 | 7 | : btn.X ] portc [ $ 02 l ] ; ( PCINT10) 8 | : btn.X' ] portc [ $ 00 l ] ; 9 | 10 | : btn.Y ] portc [ $ 05 l ] ; ( PCINT13) 11 | : btn.Y' ] portc [ $ 03 l ] ; 12 | 13 | ( construct btn mask 0000 0AXY) 14 | : btns ( -- nibble ) ] btn.A ] pin@ 15 | [ $ 1 l ] lshift ] btn.X ] pin@ ] or 16 | [ $ 1 l ] lshift ] btn.Y ] pin@ ] or 17 | [ $ 0007 l ] xor 18 | ] ; 19 | 20 | 2 var btns-last btns btns-last ! 21 | 2 var btnsq 0 btnsq ! 22 | 23 | : btns.changed ( -- x ) ] btns-last ] @ ] btns ] dup ] btns-last ] ! ] xor ] ; 24 | 25 | ( button press queue into nice patterns in btnsq ) 26 | ( free, press A, release A => 040 ) 27 | ( free, press Y, release A => 010 ) 28 | ( hold A, press Y, release Y => 454 ) 29 | : btns.q ( nibble -- ) [ $ 000f l ] and ] btnsq ] @ [ $ 4 l ] lshift ] or ] btnsq ] ! ] ; 30 | 31 | ( current morse sequence ) 32 | 2 var morsing 1 morsing ! 33 | ( needs length somehow: always start morsebytes with 1 ) 34 | : /morsing [ $ 1 l ] morsing ] ! ] ; 35 | 36 | : dit ( m -- m' ) [ $ 1 l ] lshift [ $ 0 l ] or ] ; 37 | : dash ( m -- m' ) [ $ 1 l ] lshift [ $ 1 l ] or ] ; 38 | 39 | ( .|.|.|.|.|.|.| ) 40 | ( .|.|.|.|..||..||..||.. ) 41 | ( .|.|..||..||....||||....|| ) 42 | ( .|..||....||||........|||||| ) 43 | ihere 2 + ." etianmsurwdkgohvf_l_pjbxcyzq__" con morsetable 44 | ( morsetable itype ) 45 | 46 | : even? [ $ 1 l ] and ] 0? ] drop ] ; 47 | : cpick ( x a -- x' ) ] even? ] if ] high ] ; ] then ] low ] ; 48 | 49 | : morse@ ( ma -- c ) ] dup 50 | ] 2/ ] morsetable ] + ] i@ 51 | ] swap ] cpick 52 | ] ; 53 | 54 | ( ========== RAM line buffer ========== ) 55 | 56 | $ 02 var at 0 at ! 57 | $ 0100 con linesize ( must be 2ˣ ) 58 | linesize var &line &line linesize 0 fill 59 | 60 | ( ========== EEPROM line buffer ========== ) 61 | linesize evar &eline 62 | 63 | : line>e ( -- ) 64 | ] led.A ] set 65 | ] &line ] &eline ] linesize ] c>e 66 | ] slow2 67 | ] led.A ] clear 68 | ] ; 69 | : e>line ( -- ) ] &line ] &eline ] linesize ] e>c ] ; 70 | 71 | 72 | 73 | ( e>line line. ) 74 | ( line>e ) 75 | ( &eline linesize edump ) 76 | ( &line linesize dump ) 77 | 78 | : at! ( c --) ] at ] c@ ] &line ] + ] c! ] ; ( save c into at ) 79 | : at@ ( -- c) ] at ] c@ ] &line ] + ] c@ ] ; ( get c in line from at ) 80 | : at++ ] at ] c@ ] 1+ ] linesize ] 1- ] and ] at ] c! ] ; 81 | : at-- ] at ] c@ ] 1- ] linesize ] 1- ] and ] at ] c! ] ; 82 | : at!+ ] at ] c@ ] + ] linesize ] 1- ] and ] at ] c! ] ; 83 | 84 | ( store char c into line and move cursor ) 85 | : commit ( c -- ) ] at! ] at++ ] ; 86 | : lineclear ( -- ) ] &line ] linesize [ $ 20 l ] fill [ $ 0 l ] at ] ! ] ; 87 | 88 | ( holder for "callback" ) 89 | 2 var 'btns.handler ' drop 'btns.handler ! 90 | 2 var 'btns.updater ' line. 'btns.updater ! 91 | 2 var 'btns.special ' h. 'btns.special ! 92 | 93 | : update ] 'btns.updater ] @ ] execute ] ; 94 | : special ] 'btns.special ] @ ] execute ] ; 95 | 96 | ( btnsq -- ) 97 | : btns.handler [ $ 0fff l ] and 98 | [ $ 0010 l ] ?? ] drop ] =if ] morsing ] @ ] dash ] morsing ] ! ] update ] then 99 | [ $ 0040 l ] ?? ] drop ] =if ] morsing ] @ ] dit ] morsing ] ! ] update ] then 100 | [ $ 0020 l ] ?? ] drop ] =if ] morsing ] @ ] morse@ ] commit ] /morsing ] update ] then 101 | [ $ 0454 l ] ?? ] drop ] =if ] at++ ] /morsing ] update ] then 102 | [ $ 0151 l ] ?? ] drop ] =if ] at-- ] /morsing ] update ] then 103 | [ $ 0262 l ] ?? ] drop ] =if ] morsing ] @ ] morse@ ] special ] /morsing ] update ] then 104 | [ $ 0464 l ] ?? ] drop ] =if ] morsing ] @ ] morse@ ] special ] /morsing ] update ] then 105 | [ $ 0462 l ] ?? ] drop ] =if ] morsing ] @ ] morse@ ] special ] /morsing ] update ] then 106 | [ $ 0264 l ] ?? ] drop ] =if ] morsing ] @ ] morse@ ] special ] /morsing ] update ] then 107 | [ $ 0131 l ] ?? ] drop ] =if ] /morsing ] update ] then 108 | ] drop 109 | ] ; 110 | ' btns.handler 'btns.handler ! 111 | 112 | : invert ] invert ] ; 113 | 114 | ( print char at@ but in inverted colors ) 115 | : /at@. ] at@ ] c>gi ] glyph@ ] invert ] swap ] invert ] swap ] glyph>oled ] ; 116 | : row ( i -- row ) [ $ 5 l ] rshift ] ; 117 | 118 | : arrow> 119 | [ $ 00 l ] >oled 120 | [ $ 3c l ] >oled 121 | [ $ 18 l ] >oled 122 | [ $ 00 l ] >oled 123 | ] ; 124 | 125 | : C-a ] at ] @ [ $ e0 l ] and ] at ] ! ] line. ] ; 126 | : C-e ] C-a [ $ 1f l ] at!+ ] ; 127 | : C-n [ $ 20 l ] at!+ ] ; 128 | : C-p [ $ 20 l ] negate ] at!+ ] ; 129 | : C-s ] line>e ] ; 130 | 131 | ( usage: char a h. => 0061 ) 132 | : char [ $ 20 l ] word ] c@ ] ; 133 | 134 | 2 var last-mnemonic char a last-mnemonic ! 135 | 136 | : mnemonic ." special: " ] dup ] emit ] cr 137 | [ $ 0020 l ] ?? ] drop ] =if ] drop ] last-mnemonic ] @ ] mnemonic ] ; ] then 138 | [ char a l ] ?? ] drop ] =if ] C-a ] then 139 | [ char e l ] ?? ] drop ] =if ] C-e ] then 140 | [ char n l ] ?? ] drop ] =if ] C-n ] then 141 | [ char p l ] ?? ] drop ] =if ] C-p ] then 142 | [ char s l ] ?? ] drop ] =if ] C-s ] then 143 | ] last-mnemonic ] ! 144 | ] ; 145 | ' mnemonic 'btns.special ! 146 | 147 | 148 | ( redraw display ) 149 | : line. 150 | [ $ 7 l ] oled.page [ $ 0 l ] oled.x ] arrow> ] morsing ] @ ] morse@ ] oled.emit 151 | [ $ 6 l ] oled.page ] &line [ $ 0000 l ] + ] oledline 187 | ] line. 188 | ] ; 189 | 190 | : morse.start ] &btns-watch ] task-queue ] ; 191 | : morse.stop ] &btns-watch ] task-dequeue ] ; 192 | 193 | -------------------------------------------------------------------------------- /blocks/oled.avrforth: -------------------------------------------------------------------------------- 1 | ( driver for SSD1306 $2 OLED ) 2 | 3 | ( pins ) 4 | ( oled.GND hardwired to GND) 5 | : oled.Vcc ] portb [ $ 06 l ] ; 6 | : oled.D0 ] portb [ $ 07 l ] ; 7 | : oled.D1 ] portd [ $ 05 l ] ; 8 | : oled.RST ] portd [ $ 06 l ] ; 9 | : oled.DC ] portd [ $ 07 l ] ; 10 | : oled.CS ] portb [ $ 00 l ] ; 11 | 12 | 13 | : spi/data ( -- ) ] oled.DC ] set ] ; 14 | : spi/cmd ( -- ) ] oled.DC ] clear ] ; 15 | : >oled ( ub -- ) ] spi/data ] spitx ] ; 16 | 17 | : oled.charge ( ub -- ) ] spi/cmd [ $ 8d l ] spitx ] spitx ] ; 18 | : oled.precharge ( ub -- ) ] spi/cmd [ $ d9 l ] spitx ] spitx ] ; 19 | : oled.vcomh ( ub -- ) ] spi/cmd [ $ db l ] spitx ] spitx ] ; 20 | : oled.contrast ( ub -- ) ] spi/cmd [ $ 81 l ] spitx ] spitx ] ; 21 | : oled.reset ( -- ) 22 | ] oled.RST ] ground 23 | ] slow2 24 | ] oled.RST ] pull-up 25 | ] ; 26 | 27 | : oled.on ( -- ) ] spi/cmd [ $ af l ] spitx [ $ a4 l ] spitx ] ; 28 | : oled.off ( -- ) ] spi/cmd [ $ ae l ] spitx [ $ a5 l ] spitx ] ; 29 | : oled./inverse ( -- ) ] spi/cmd [ $ a6 l ] spitx ] ; 30 | : oled.inverse ( -- ) ] spi/cmd [ $ a7 l ] spitx ] ; 31 | : oled.rightwards ( -- ) ] spi/cmd [ $ a0 l ] spitx ] ; ( cursor direction) 32 | : oled.leftwards ( -- ) ] spi/cmd [ $ a1 l ] spitx ] ; ( cursor direction) 33 | : oled.vflip ( -- ) ] spi/cmd [ $ c8 l ] spitx ] ; 34 | : oled./vflip ( -- ) ] spi/cmd [ $ c0 l ] spitx ] ; 35 | : oled.page ( n -- ) ] spi/cmd [ $ b0 l ] or ] spitx ] ; 36 | : oled.x ( n -- ) ] spi/cmd ] imm ] dup ] low ] spitx ] high [ $ 10 l ] or ] spitx ] ; 37 | 38 | : oled.fillpage ( c -- ) [ $ 80 l ] for ] dup ] >oled ] next ] drop ] ; 39 | : oled.fill ( c -- ) 40 | [ $ 00 l ] oled.x 41 | [ $ 00 l ] oled.page ] dup ] oled.fillpage 42 | [ $ 01 l ] oled.page ] dup ] oled.fillpage 43 | [ $ 02 l ] oled.page ] dup ] oled.fillpage 44 | [ $ 03 l ] oled.page ] dup ] oled.fillpage 45 | [ $ 04 l ] oled.page ] dup ] oled.fillpage 46 | [ $ 05 l ] oled.page ] dup ] oled.fillpage 47 | [ $ 06 l ] oled.page ] dup ] oled.fillpage 48 | [ $ 07 l ] oled.page ] oled.fillpage 49 | ] ; 50 | 51 | : >oled16 ] dup 52 | [ $ 5 l ] oled.page ] high ] >oled 53 | [ $ 4 l ] oled.page ] low ] >oled 54 | ] ; 55 | 56 | : logo 57 | [ $ 8001 l ] >oled16 58 | [ $ 803d l ] >oled16 59 | [ $ 81e1 l ] >oled16 60 | [ $ 8fc1 l ] >oled16 61 | [ $ b921 l ] >oled16 62 | [ $ 8211 l ] >oled16 63 | [ $ 8409 l ] >oled16 64 | [ $ 8805 l ] >oled16 65 | [ $ 9001 l ] >oled16 66 | [ $ 907d l ] >oled16 67 | [ $ a005 l ] >oled16 68 | [ $ e0c5 l ] >oled16 69 | [ $ c385 l ] >oled16 70 | [ $ ce01 l ] >oled16 71 | [ $ 9801 l ] >oled16 72 | [ $ be01 l ] >oled16 73 | [ $ 8381 l ] >oled16 74 | [ $ 80e1 l ] >oled16 75 | [ $ 8381 l ] >oled16 76 | [ $ 8e01 l ] >oled16 77 | [ $ b801 l ] >oled16 78 | [ $ bffd l ] >oled16 79 | [ $ 8001 l ] >oled16 80 | [ $ 8001 l ] >oled16 81 | ] ; 82 | 83 | : oled.splash 84 | [ $ 00 l ] oled.fill 85 | [ $ 28 l ] oled.x ] logo 86 | ] slow2 ] slow2 ] slow2 ] slow2 87 | ] slow2 ] slow2 ] slow2 ] slow2 88 | [ $ 00 l ] oled.fill 89 | ] ; 90 | 91 | ( OBS: SD1306.pdf section 4.8 says: ) 92 | ( Power Pins [ VDD VCC ] can never be pulled to ground2 ) 93 | : oled.init 94 | ] oled.D0 ] floating ( hardwired to SCK/PB5 ) 95 | ] oled.D1 ] floating ( hardwired to MOSI ) 96 | ] oled.RST ] pull-up 97 | ] oled.DC ] ground 98 | ] oled.CS ] ground 99 | ] oled.Vcc ] vcc 100 | ( init SPI ) 101 | ] ddrb [ $ 3 l ] set ( unused, but MOSI must be output for SPI to work ) 102 | ] ddrb [ $ 5 l ] set ( SCK output ) 103 | ] spimaster 104 | ] spiclk/2 ] spiclk 105 | ] msb-first ] spiorder 106 | ] 0 ] spimode 107 | ] spi 108 | ( reset oled display, will cause delay ) 109 | ] oled.reset 110 | [ $ 04 l ] oled.charge 111 | [ $ f0 l ] oled.precharge 112 | [ $ 00 l ] oled.vcomh 113 | [ $ ff l ] oled.contrast 114 | ] oled.on 115 | ] oled.rightwards 116 | ] oled./inverse 117 | ] oled.vflip 118 | ] ; 119 | 120 | -------------------------------------------------------------------------------- /blocks/pin.avrforth: -------------------------------------------------------------------------------- 1 | ( pin) 2 | 3 | ( port bit -- ) 4 | : output ] swap ] 1- ] swap ] set ] ; ( ddrX == portX - 1) 5 | : input ] swap ] 1- ] swap ] clear ] ; 6 | 7 | : up ] set ] ; ( TODO make output and rename to vcc) 8 | : down ] clear ] ; ( TODO make output and rename to ground) 9 | 10 | : ground ] 2dup ] output ] clear ] ; 11 | : vcc ] 2dup ] output ] set ] ; 12 | 13 | : pull-up ] 2dup ] input ] up ] ; 14 | : floating ] 2dup ] input ] down ] ; 15 | 16 | : pin@ ] swap ] 1- ] 1- ] swap ] get ] ; 17 | 18 | ( external and pin change interrupt) 19 | 20 | : eimsk [ $ 3d l ] ; 21 | : eimsk.int0 ] eimsk [ $ 0 l ] ; 22 | : eimsk.int1 ] eimsk [ $ 1 l ] ; 23 | 24 | : pcicr [ $ 68 l ] ; 25 | : pcicr.pcie0 ] pcicr [ $ 0 l ] ; 26 | : pcicr.pcie1 ] pcicr [ $ 1 l ] ; 27 | : pcicr.pcie2 ] pcicr [ $ 2 l ] ; 28 | 29 | : eicra [ $ 69 l ] ; 30 | : eicra.isc00 ] eicra [ $ 0 l ] ; 31 | : eicra.isc01 ] eicra [ $ 1 l ] ; 32 | : eicra.isc10 ] eicra [ $ 2 l ] ; 33 | : eicra.isc11 ] eicra [ $ 3 l ] ; 34 | 35 | : pcmsk0 [ $ 6b l ] ; 36 | : pcmsk1 [ $ 6c l ] ; 37 | : pcmsk2 [ $ 6d l ] ; 38 | 39 | : pcmsk.pcint2 ] pcmsk0 [ $ 2 l ] ; 40 | : pcmsk.pcint4 ] pcmsk0 [ $ 4 l ] ; 41 | 42 | : pcmsk.pcint13 ] pcmsk1 [ $ 5 l ] ; 43 | 44 | : eifr [ $ 3c l ] ; 45 | : eifr.intf0 ] eifr [ $ 0 l ] ; 46 | : eifr.intf1 ] eifr [ $ 1 l ] ; 47 | 48 | : pcifr [ $ 3b l ] ; 49 | : pcifr.pcif0 ] pcifr [ $ 0 l ] ; 50 | : pcifr.pcif1 ] pcifr [ $ 1 l ] ; 51 | : pcifr.pcif2 ] pcifr [ $ 2 l ] ; 52 | -------------------------------------------------------------------------------- /config.f: -------------------------------------------------------------------------------- 1 | ( avrforth configuration ) 2 | 3 | ( device must be selected in makefile ) 4 | 5 | decimal 6 | 7 | ( cpu clock in hertz ) 8 | 8000000 constant cpu_frequency 9 | 10 | ( usart to use for terminal ) 11 | 00 constant usart 12 | 13 | ( baud rate of terminal ) 14 | 9600 constant baud_rate 15 | 16 | hex 17 | 18 | ( usart buffer sizes - must be a power of two ) 19 | 010 constant usart0_tx_size 20 | 010 constant usart0_rx_size 21 | 22 | ( interrupt stack sizes ) 23 | true constant int_stack 24 | $40 constant int_ds_size 25 | $40 constant int_rs_size 26 | 27 | -------------------------------------------------------------------------------- /drivers/adc.f: -------------------------------------------------------------------------------- 1 | ( a/d converter driver ) 2 | 3 | [ifdef] admux 4 | 5 | ( reference ) 6 | s" ref-aref" link, $00 const, 7 | s" ref-avcc" link, $01 const, 8 | s" ref-int" link, $03 const, 9 | 10 | s" adcref" link, ( x -- ) 11 | temp0 admux fetch 12 | tosl 0 bst, 13 | temp0 refs0 bld, 14 | tosl 1 bst, 15 | temp0 refs1 bld, 16 | admux temp0 store 17 | drop, 18 | ret, 19 | 20 | ( mux ) 21 | s" adcmux" link, ( x -- ) 22 | temp0 admux fetch 23 | tosl $0f andi, 24 | temp0 $f0 andi, 25 | temp0 tosl or, 26 | admux temp0 store 27 | drop, 28 | ret, 29 | 30 | ( result justification ) 31 | s" just-right" link, $00 const, 32 | s" just-left" link, $01 const, 33 | 34 | s" adcjust" link, ( x -- ) 35 | temp0 admux fetch 36 | tosl 0 bst, 37 | temp0 adlar bld, 38 | admux temp0 store 39 | drop, 40 | ret, 41 | 42 | ( prescaler ) 43 | s" adcclk/2" link, $01 const, 44 | s" adcclk/4" link, $02 const, 45 | s" adcclk/8" link, $03 const, 46 | s" adcclk/16" link, $04 const, 47 | s" adcclk/32" link, $05 const, 48 | s" adcclk/64" link, $06 const, 49 | s" adcclk/128" link, $07 const, 50 | 51 | s" adcclk" link, ( x -- ) 52 | temp0 adcsra fetch 53 | tosl $07 andi, 54 | temp0 $f8 andi, 55 | temp0 tosl or, 56 | adcsra temp0 store 57 | drop, 58 | ret, 59 | 60 | ( interrupt ) 61 | s" adcflag" link, adcsra adif 2lit, ret, 62 | s" adcint" link, adcsra adie 2lit, ret, 63 | 64 | s" 'adc" link, there constant &'adc 02 var, 65 | &'adc adc ramvector 66 | 67 | ( enable ) 68 | s" adc" link, ( -- ) 69 | adcsra aden set-bit 70 | ret, 71 | 72 | ( disable ) 73 | s" /adc" link, ( -- ) 74 | adcsra aden clear-bit 75 | ret, 76 | 77 | ( start conversion ) 78 | s" adcstart" link, ( -- ) 79 | adcsra adsc set-bit 80 | ret, 81 | 82 | ( wait for conversion ) 83 | s" adcwait" link, ( -- ) 84 | begin, 85 | adcsra adsc skip-bit-set 86 | ret, 87 | pause_ call 88 | again, 89 | 90 | ( registers ) 91 | s" adcdata" link, adcl const, 92 | [ifdef] didr0 s" adcdid" link, didr0 const, [then] 93 | 94 | [then] 95 | 96 | -------------------------------------------------------------------------------- /drivers/can.f: -------------------------------------------------------------------------------- 1 | ( can ) 2 | 3 | [ifdef] cangcon 4 | 5 | s" brp" link, ( n -- ) 6 | tosl 1 subi, 7 | tosl lsl, 8 | tosl 07e andi, 9 | canbt1 tosl store 10 | drop, 11 | ret, 12 | 13 | 14 | s" sjw" link, ( n -- ) 15 | tosl 1 subi, 16 | tosl lsl, 17 | tosl lsl, 18 | tosl lsl, 19 | tosl lsl, 20 | tosl lsl, 21 | tosl 060 andi, 22 | 23 | temp0 canbt2 fetch 24 | temp0 00e andi, 25 | temp0 tosl or, 26 | canbt2 temp0 store 27 | 28 | drop, 29 | ret, 30 | 31 | 32 | s" prs" link, ( n -- ) 33 | tosl 1 subi, 34 | tosl lsl, 35 | tosl 00e andi, 36 | 37 | temp0 canbt2 fetch 38 | temp0 060 andi, 39 | temp0 tosl or, 40 | canbt2 temp0 store 41 | 42 | drop, 43 | ret, 44 | 45 | 46 | s" phs2" link, ( n -- ) 47 | tosl 1 subi, 48 | tosl lsl, 49 | tosl lsl, 50 | tosl lsl, 51 | tosl lsl, 52 | tosl 070 andi, 53 | 54 | temp0 canbt3 fetch 55 | temp0 00f andi, 56 | temp0 tosl or, 57 | canbt3 temp0 store 58 | 59 | drop, 60 | ret, 61 | 62 | 63 | s" phs1" link, ( n -- ) 64 | tosl 1 subi, 65 | tosl lsl, 66 | tosl 00e andi, 67 | 68 | temp0 canbt3 fetch 69 | temp0 071 andi, 70 | temp0 tosl or, 71 | canbt3 temp0 store 72 | 73 | drop, 74 | ret, 75 | 76 | 77 | s" smp" link, ( n -- ) 78 | tosl 001 andi, 79 | 80 | temp0 canbt3 fetch 81 | temp0 07e andi, 82 | temp0 tosl or, 83 | canbt3 temp0 store 84 | 85 | drop, 86 | ret, 87 | 88 | 89 | s" can" link, ( -- ) 90 | temp0 enastb 2^ ldi, 91 | cangcon temp0 store 92 | ret, 93 | 94 | 95 | s" /can" link, ( -- ) 96 | cangcon zero store 97 | ret, 98 | 99 | 100 | s" mob" link, ( n -- ) 101 | tosl 00f andi, 102 | tosl swap, 103 | canpage tosl store 104 | drop, 105 | ret, 106 | 107 | 108 | s" mobclr" link, ( -- ) 109 | label mobclr_ 110 | ( clear mob control registers ) 111 | xl canstmob lo ldi, 112 | xh canstmob hi ldi, 113 | zero stx+, ( canstmob ) 114 | zero stx+, ( cancdmob ) 115 | zero stx+, ( canidt4 ) 116 | zero stx+, ( canidt3 ) 117 | zero stx+, ( canidt2 ) 118 | zero stx+, ( canidt1 ) 119 | zero stx+, ( canidm4 ) 120 | zero stx+, ( canidm3 ) 121 | zero stx+, ( canidm2 ) 122 | zero stx+, ( canidm1 ) 123 | 124 | ( move to canmsg ) 125 | xx 2 adiw, 126 | 127 | ( clear data fifo ) 128 | zero stx, 129 | zero stx, 130 | zero stx, 131 | zero stx, 132 | zero stx, 133 | zero stx, 134 | zero stx, 135 | zero stx, 136 | ret, 137 | 138 | 139 | s" mobclrall" link, ( -- ) 140 | temp0 0e0 ldi, 141 | 142 | begin, 143 | canpage temp0 store 144 | mobclr_ call 145 | temp0 010 subi, 146 | c until, 147 | ret, 148 | 149 | 150 | s" mobget" link, ( -- n ; f ) 151 | temp0 0e0 ldi, 152 | 153 | begin, 154 | canpage temp0 store 155 | temp1 cancdmob fetch 156 | temp1 conmob1 2^ conmob0 2^ or andi, 157 | z if, ( found free mob ) 158 | dup, 159 | tosl temp0 mov, 160 | tosl swap, 161 | tosh clr, 162 | true, 163 | ret, 164 | then, 165 | 166 | temp0 010 subi, 167 | c until, 168 | 169 | ( all mobs in use ) 170 | false, 171 | ret, 172 | 173 | 174 | ( to standard id format ) 175 | 176 | label tostd_ 177 | tosl lsl, 178 | tosh rol, 179 | tosl lsl, 180 | tosh rol, 181 | tosl lsl, 182 | tosh rol, 183 | tosl lsl, 184 | tosh rol, 185 | tosl lsl, 186 | tosh rol, 187 | ret, 188 | 189 | 190 | ( from standard id format ) 191 | 192 | label fromstd_ 193 | tosh lsr, 194 | tosl ror, 195 | tosh lsr, 196 | tosl ror, 197 | tosh lsr, 198 | tosl ror, 199 | tosh lsr, 200 | tosl ror, 201 | tosh lsr, 202 | tosl ror, 203 | ret, 204 | 205 | 206 | s" id!" link, ( x -- ) 207 | tostd_ call 208 | canidt2 tosl store 209 | canidt1 tosh store 210 | \ cbi_ cancdmob ide clear-bit 211 | cancdmob zero store 212 | drop, 213 | ret, 214 | 215 | 216 | s" id@" link, ( -- x ) 217 | dup, 218 | tosl canidt2 fetch 219 | tosh canidt1 fetch 220 | fromstd_ jump 221 | 222 | 223 | s" mask!" link, ( x -- ) 224 | tostd_ call 225 | canidm2 tosl store 226 | canidm1 tosh store 227 | drop, 228 | ret, 229 | 230 | 231 | s" mask@" link, ( -- x ) 232 | dup, 233 | tosl canidm2 fetch 234 | tosh canidm1 fetch 235 | fromstd_ jump 236 | 237 | 238 | ( to extended id format ) 239 | 240 | label toext_ 241 | xl ldy+, 242 | xh ldy+, 243 | xl lsl, 244 | xh rol, 245 | tosl rol, 246 | tosh rol, 247 | xl lsl, 248 | xh rol, 249 | tosl rol, 250 | tosh rol, 251 | xl lsl, 252 | xh rol, 253 | tosl rol, 254 | tosh rol, 255 | ret, 256 | 257 | 258 | ( from extended id format ) 259 | 260 | label fromext_ 261 | tosh lsr, 262 | tosl ror, 263 | xh ror, 264 | xl ror, 265 | tosh lsr, 266 | tosl ror, 267 | xh ror, 268 | xl ror, 269 | tosh lsr, 270 | tosl ror, 271 | xh ror, 272 | xl ror, 273 | xh st-y, 274 | xl st-y, 275 | ret, 276 | 277 | 278 | s" xid!" link, ( d -- ) 279 | toext_ call 280 | canidt4 xl store 281 | canidt3 xh store 282 | canidt2 tosl store 283 | canidt1 tosh store 284 | \ cancdmob ide set-bit 285 | temp0 ide 2^ ldi, 286 | cancdmob temp0 store 287 | drop, 288 | ret, 289 | 290 | 291 | s" xid@" link, ( -- d ) 292 | dup, 293 | xl canidt4 fetch 294 | xh canidt3 fetch 295 | tosl canidt2 fetch 296 | tosh canidt1 fetch 297 | fromext_ jump 298 | 299 | 300 | s" xmask!" link, ( d -- ) 301 | toext_ call 302 | canidm4 xl store 303 | canidm3 xh store 304 | canidm2 tosl store 305 | canidm1 tosh store 306 | drop, 307 | ret, 308 | 309 | 310 | s" xmask@" link, ( -- d ) 311 | dup, 312 | xl canidm4 fetch 313 | xh canidm3 fetch 314 | tosl canidm2 fetch 315 | tosh canidm1 fetch 316 | fromext_ jump 317 | 318 | 319 | s" dlc!" link, ( n -- ) 320 | temp0 cancdmob fetch 321 | temp0 0f0 andi, 322 | 323 | tosl 00f andi, 324 | temp0 tosl or, 325 | cancdmob temp0 store 326 | 327 | drop, 328 | ret, 329 | 330 | 331 | s" dlc@" link, ( -- n ) 332 | dup, 333 | tosl cancdmob fetch 334 | tosl 00f andi, 335 | tosh clr, 336 | ret, 337 | 338 | 339 | s" canc!" link, ( c -- ) 340 | canmsg tosl store 341 | drop, 342 | ret, 343 | 344 | 345 | s" can!" link, ( x -- ) 346 | canmsg tosh store 347 | canmsg tosl store 348 | drop, 349 | ret, 350 | 351 | 352 | s" canc@" link, ( -- c ) 353 | dup, 354 | tosl canmsg fetch 355 | tosh clr, 356 | ret, 357 | 358 | 359 | s" can@" link, ( -- x ) 360 | dup, 361 | tosh canmsg fetch 362 | tosl canmsg fetch 363 | ret, 364 | 365 | 366 | s" moboff" link, ( -- ) 367 | temp0 cancdmob fetch 368 | temp0 conmob1 2^ conmob0 2^ or invert lo andi, 369 | cancdmob temp0 store 370 | ret, 371 | 372 | 373 | s" mobtx" link, ( -- ) 374 | canstmob zero store 375 | temp0 cancdmob fetch 376 | temp0 conmob0 2^ ori, 377 | cancdmob temp0 store 378 | ret, 379 | 380 | 381 | s" mobrx" link, ( -- ) 382 | canstmob zero store 383 | temp0 cancdmob fetch 384 | temp0 conmob1 2^ ori, 385 | cancdmob temp0 store 386 | ret, 387 | 388 | 389 | s" mobrxb" link, ( -- ) 390 | canstmob zero store 391 | temp0 cancdmob fetch 392 | temp0 conmob1 2^ conmob0 2^ or ori, 393 | cancdmob temp0 store 394 | ret, 395 | 396 | 397 | s" cantx?" link, ( -- ; f ) 398 | temp0 canstmob fetch 399 | temp0 txok 2^ andi, 400 | ret, 401 | 402 | 403 | s" canrx?" link, ( -- ; f ) 404 | temp0 canstmob fetch 405 | temp0 rxok 2^ andi, 406 | ret, 407 | 408 | 409 | s" mobst" link, ( -- ) 410 | canstmob zero store 411 | ret, 412 | 413 | [endif] 414 | 415 | -------------------------------------------------------------------------------- /drivers/gpio.f: -------------------------------------------------------------------------------- 1 | ( gpio ) 2 | 3 | [ifdef] pina s" pina" link, pina const, [then] 4 | [ifdef] ddra s" ddra" link, ddra const, [then] 5 | [ifdef] porta s" porta" link, porta const, [then] 6 | 7 | [ifdef] pinb s" pinb" link, pinb const, [then] 8 | [ifdef] ddrb s" ddrb" link, ddrb const, [then] 9 | [ifdef] portb s" portb" link, portb const, [then] 10 | 11 | [ifdef] pinc s" pinc" link, pinc const, [then] 12 | [ifdef] ddrc s" ddrc" link, ddrc const, [then] 13 | [ifdef] portc s" portc" link, portc const, [then] 14 | 15 | [ifdef] pind s" pind" link, pind const, [then] 16 | [ifdef] ddrd s" ddrd" link, ddrd const, [then] 17 | [ifdef] portd s" portd" link, portd const, [then] 18 | 19 | [ifdef] pine s" pine" link, pine const, [then] 20 | [ifdef] ddre s" ddre" link, ddre const, [then] 21 | [ifdef] porte s" porte" link, porte const, [then] 22 | 23 | [ifdef] pinf s" pinf" link, pinf const, [then] 24 | [ifdef] ddrf s" ddrf" link, ddrf const, [then] 25 | [ifdef] portf s" portf" link, portf const, [then] 26 | 27 | [ifdef] ping s" ping" link, ping const, [then] 28 | [ifdef] ddrg s" ddrg" link, ddrg const, [then] 29 | [ifdef] portg s" portg" link, portg const, [then] 30 | 31 | [ifdef] external_interrupt_0 32 | s" 'ei0" link, there constant &'ei0 02 var, 33 | &'ei0 external_interrupt_0 ramvector 34 | [then] 35 | 36 | [ifdef] external_interrupt_1 37 | s" 'ei1" link, there constant &'ei1 02 var, 38 | &'ei1 external_interrupt_1 ramvector 39 | [then] 40 | 41 | [ifdef] pin_change_interrupt_0 42 | s" 'pci0" link, there constant &'pci0 02 var, 43 | &'pci0 pin_change_interrupt_0 ramvector 44 | [then] 45 | 46 | [ifdef] pin_change_interrupt_1 47 | s" 'pci1" link, there constant &'pci1 02 var, 48 | &'pci1 pin_change_interrupt_1 ramvector 49 | [then] 50 | 51 | [ifdef] pin_change_interrupt_2 52 | s" 'pci2" link, there constant &'pci2 02 var, 53 | &'pci2 pin_change_interrupt_2 ramvector 54 | [then] 55 | 56 | -------------------------------------------------------------------------------- /drivers/pll.f: -------------------------------------------------------------------------------- 1 | ( pll ) 2 | 3 | [ifdef] pllcsr 4 | 5 | cpu_frequency #8000000 = [if] 6 | pllp1 2^ pllp0 2^ or constant pll_prescaler 7 | [then] 8 | 9 | cpu_frequency #16000000 = [if] 10 | device s" at90usb647" compare 0= [if] 11 | pllp2 2^ pllp1 2^ or constant pll_prescaler 12 | [then] 13 | device s" at90usb1287" compare 0= [if] 14 | pllp2 2^ pllp0 2^ or constant pll_prescaler 15 | [then] 16 | [then] 17 | 18 | ( wait for pll lock ) 19 | label pll_wait 20 | begin, 21 | pllcsr plock skip-bit-clear 22 | ret, 23 | pause_ call 24 | again, 25 | 26 | ( enable pll ) 27 | s" pll" link, ( -- ) 28 | pllcsr pll_prescaler plle 2^ or load 29 | pll_wait jump 30 | 31 | ( disable pll ) 32 | s" /pll" link, ( -- ) 33 | pllcsr zero store 34 | ret, 35 | 36 | [then] 37 | 38 | -------------------------------------------------------------------------------- /drivers/spi.f: -------------------------------------------------------------------------------- 1 | ( spi ) 2 | 3 | [ifdef] spdr 4 | 5 | ( transfer complete interrupt enable ) 6 | s" spiint" link, ( -- bit ) 7 | spcr spie 2lit, 8 | ret, 9 | 10 | ( transfer complete interrupt flag ) 11 | s" spiflag" link, ( -- bit ) 12 | spsr spif 2lit, 13 | ret, 14 | 15 | ( spi mode ) 16 | s" spimode" link, ( x -- ) 17 | tosl $03 andi, 18 | tosl lsl, 19 | tosl lsl, 20 | temp0 spcr fetch 21 | temp0 $f3 andi, 22 | temp0 tosl or, 23 | spcr temp0 store 24 | drop, 25 | ret, 26 | 27 | ( spi clock prescaler ) 28 | 29 | s" spiclk/4" link, $00 const, 30 | s" spiclk/16" link, $01 const, 31 | s" spiclk/64" link, $02 const, 32 | s" spiclk/128" link, $03 const, 33 | s" spiclk/2" link, $04 const, 34 | s" spiclk/8" link, $05 const, 35 | s" spiclk/32" link, $06 const, 36 | 37 | s" spiclk" link, ( x -- ) 38 | temp0 spsr fetch 39 | tosl $02 bst, 40 | temp0 spi2x bld, 41 | spsr temp0 store 42 | tosl $03 andi, 43 | temp0 spcr fetch 44 | temp0 $fc andi, 45 | temp0 tosl or, 46 | spcr temp0 store 47 | drop, 48 | ret, 49 | 50 | ( enable spi ) 51 | s" spi" link, ( -- ) 52 | spcr spe set-bit 53 | ret, 54 | 55 | ( disable spi ) 56 | s" /spi" link, ( -- ) 57 | spcr spe clear-bit 58 | ret, 59 | 60 | ( data order ) 61 | 62 | s" msb-first" link, $00 const, 63 | s" lsb-first" link, $01 const, 64 | 65 | s" spiorder" link, ( x -- ) 66 | temp0 spcr fetch 67 | tosl $00 bst, 68 | temp0 dord bld, 69 | spcr temp0 store 70 | drop, 71 | ret, 72 | 73 | ( write collision flag ) 74 | s" spicol" link, ( -- bit ) 75 | spsr wcol 2lit, 76 | ret, 77 | 78 | ( configure master mode ) 79 | s" spimaster" link, ( -- ) 80 | spcr mstr set-bit 81 | ss-ddr set-bit 82 | sck-ddr set-bit 83 | mosi-ddr set-bit 84 | miso-ddr clear-bit 85 | ret, 86 | 87 | ( configure slave mode ) 88 | s" spislave" link, ( -- ) 89 | spcr mstr clear-bit 90 | ss-ddr clear-bit 91 | sck-ddr clear-bit 92 | mosi-ddr clear-bit 93 | miso-ddr set-bit 94 | ret, 95 | 96 | ( spi data register ) 97 | s" spidata" link, spdr const, 98 | 99 | ( transfer byte ) 100 | s" spix" link, ( c1 -- c2 ) 101 | label spix_ 102 | ( start transmission ) 103 | spdr tosl store 104 | 105 | ( wait until complete ) 106 | begin, 107 | temp0 spsr fetch 108 | temp0 spif 2^ andi, 109 | z while, 110 | pause_ call 111 | repeat, 112 | 113 | ( get response ) 114 | tosl spdr fetch 115 | tosh clr, 116 | ret, 117 | 118 | ( send byte ) 119 | s" spitx" link, ( c -- ) 120 | spix_ call 121 | drop, 122 | ret, 123 | 124 | ( receive byte ) 125 | s" spirx" link, ( -- c ) 126 | 0 lit, 127 | spix_ jump 128 | 129 | [then] 130 | 131 | -------------------------------------------------------------------------------- /drivers/tick.f: -------------------------------------------------------------------------------- 1 | ( system tick ) 2 | 3 | 02 var ticks 4 | 5 | s" ticks" link, ( -- x ) 6 | dup, 7 | cli, 8 | tosl ticks fetch 9 | tosh ticks 1 + fetch 10 | sei, 11 | ret, 12 | 13 | idpx 14 | 15 | s" ticks+" link, ( -- ) 16 | zl ticks fetch 17 | zh ticks 1 + fetch 18 | zz 1 adiw, 19 | ticks zl store 20 | ticks 1 + zh store 21 | ret, 22 | 23 | idpx 24 | 25 | -------------------------------------------------------------------------------- /drivers/timer.f: -------------------------------------------------------------------------------- 1 | ( timers ) 2 | 3 | ( synchronous timer ) 4 | s" clk-none" link, $00 const, 5 | s" clk/1" link, $01 const, 6 | s" clk/8" link, $02 const, 7 | s" clk/64" link, $03 const, 8 | s" clk/256" link, $04 const, 9 | s" clk/1024" link, $05 const, 10 | s" clk-ext-fall" link, $06 const, 11 | s" clk-ext-rise" link, $07 const, 12 | 13 | ( asynchronous timer ) 14 | s" aclk-none" link, $00 const, 15 | s" aclk/1" link, $01 const, 16 | s" aclk/8" link, $02 const, 17 | s" aclk/32" link, $03 const, 18 | s" aclk/64" link, $04 const, 19 | s" aclk/128" link, $05 const, 20 | s" aclk/256" link, $06 const, 21 | s" aclk/1024" link, $07 const, 22 | 23 | ( waveform generation mode ) 24 | s" wgm-normal" link, $00 const, 25 | s" wgm-pwm8" link, $01 const, 26 | s" wgm-pwm9" link, $02 const, 27 | s" wgm-pwm10" link, $03 const, 28 | s" wgm-ctc-oc" link, $04 const, 29 | s" wgm-fast8" link, $05 const, 30 | s" wgm-fast9" link, $06 const, 31 | s" wgm-fast10" link, $07 const, 32 | s" wgm-correct-ic" link, $08 const, 33 | s" wgm-correct-oc" link, $09 const, 34 | s" wgm-pwm-ic" link, $0a const, 35 | s" wgm-pwm-oc" link, $0b const, 36 | s" wgm-ctc-ic" link, $0c const, 37 | s" wgm-fast-ic" link, $0e const, 38 | s" wgm-fast-oc" link, $0f const, 39 | 40 | ( output compare pin action ) 41 | s" com-normal" link, $00 const, 42 | s" com-toggle" link, $01 const, 43 | s" com-clear" link, $02 const, 44 | s" com-set" link, $03 const, 45 | 46 | ( input capture edge ) 47 | s" ice-fall" link, $00 const, 48 | s" ice-rise" link, $01 const, 49 | 50 | 2variable index 51 | 52 | : indexedname ( str1 str2 -- str3 ) 53 | 2swap pad $! 54 | index 2@ pad $+! 55 | pad $+! 56 | pad $@ ; 57 | 58 | : tccra s" tccr" s" a" indexedname evaluate ; 59 | : tccrb s" tccr" s" b" indexedname evaluate ; 60 | : tccrc s" tccr" s" c" indexedname evaluate ; 61 | 62 | : toie s" toie" s" -bit" indexedname evaluate ; 63 | : ociea s" ocie" s" a-bit" indexedname evaluate ; 64 | : ocieb s" ocie" s" b-bit" indexedname evaluate ; 65 | : ociec s" ocie" s" c-bit" indexedname evaluate ; 66 | : icie s" icie" s" -bit" indexedname evaluate ; 67 | 68 | : tov s" tov" s" -bit" indexedname evaluate ; 69 | : ocfa s" ocf" s" a-bit" indexedname evaluate ; 70 | : ocfb s" ocf" s" b-bit" indexedname evaluate ; 71 | : ocfc s" ocf" s" c-bit" indexedname evaluate ; 72 | : icf s" icf" s" -bit" indexedname evaluate ; 73 | 74 | 75 | [ifdef] tcnt0 76 | [ifdef] wgm02 77 | s" 0" index 2! include timer8new.f 78 | [else] 79 | s" 0" index 2! include timer8old.f 80 | [then] 81 | [then] 82 | [ifdef] tcnt0l s" 0" index 2! include timer16.f [then] 83 | 84 | [ifdef] tcnt1 85 | [ifdef] wgm12 86 | s" 1" index 2! include timer8new.f 87 | [else] 88 | s" 1" index 2! include timer8old.f 89 | [then] 90 | [then] 91 | [ifdef] tcnt1l s" 1" index 2! include timer16.f [then] 92 | 93 | [ifdef] tcnt2 94 | [ifdef] wgm22 95 | s" 2" index 2! include timer8new.f 96 | [else] 97 | s" 2" index 2! include timer8old.f 98 | [then] 99 | [then] 100 | [ifdef] tcnt2l s" 2" index 2! include timer16.f [then] 101 | 102 | [ifdef] tcnt3 103 | [ifdef] wgm32 104 | s" 3" index 2! include timer8new.f 105 | [else] 106 | s" 3" index 2! include timer8old.f 107 | [then] 108 | [then] 109 | [ifdef] tcnt3l s" 3" index 2! include timer16.f [then] 110 | 111 | -------------------------------------------------------------------------------- /drivers/timer16.f: -------------------------------------------------------------------------------- 1 | ( 16 bit timer ) 2 | 3 | s" tcnt" s" l" indexedname find-name [if] 4 | s" t" s" cnt" indexedname link, s" tcnt" s" l" indexedname evaluate const, 5 | s" t" s" ovfint" indexedname link, toie 2lit, ret, 6 | s" t" s" ovfflag" indexedname link, tov 2lit, ret, 7 | s" 't" s" ovf" indexedname link, there s" &'t" s" ovf" indexedname nextname constant 02 var, 8 | s" &'t" s" ovf" indexedname evaluate s" timer" s" _overflow" indexedname evaluate ramvector 9 | 10 | s" t" s" clk" indexedname link, ( n -- ) 11 | tosl $07 andi, 12 | 13 | temp0 tccrb fetch 14 | temp0 $f8 andi, 15 | temp0 tosl or, 16 | tccrb temp0 store 17 | 18 | drop, 19 | ret, 20 | 21 | s" t" s" wgm" indexedname link, ( n -- ) 22 | tosh tosl mov, 23 | 24 | tosh lsl, 25 | tosh $18 andi, 26 | 27 | temp0 tccrb fetch 28 | temp0 $e7 andi, 29 | temp0 tosh or, 30 | tccrb temp0 store 31 | 32 | tosl $03 andi, 33 | 34 | temp0 tccra fetch 35 | temp0 $fc andi, 36 | temp0 tosl or, 37 | tccra temp0 store 38 | 39 | drop, 40 | ret, 41 | 42 | [then] 43 | 44 | s" ocr" s" al" indexedname find-name [if] 45 | s" t" s" oca" indexedname link, s" ocr" s" al" indexedname evaluate const, 46 | s" t" s" ocaint" indexedname link, ociea 2lit, ret, 47 | s" t" s" ocaflag" indexedname link, ocfa 2lit, ret, 48 | s" 't" s" oca" indexedname link, there s" &'t" s" oca" indexedname nextname constant 02 var, 49 | s" &'t" s" oca" indexedname evaluate s" timer" s" _compare_a" indexedname evaluate ramvector 50 | 51 | s" t" s" coma" indexedname link, ( n -- ) 52 | tosl lsl, 53 | tosl lsl, 54 | tosl lsl, 55 | tosl lsl, 56 | tosl lsl, 57 | tosl lsl, 58 | tosl $c0 andi, 59 | 60 | temp0 tccra fetch 61 | temp0 $3f andi, 62 | temp0 tosl or, 63 | tccra temp0 store 64 | 65 | drop, 66 | ret, 67 | 68 | [then] 69 | 70 | s" ocr" s" bl" indexedname find-name [if] 71 | s" t" s" ocb" indexedname link, s" ocr" s" bl" indexedname evaluate const, 72 | s" t" s" ocbint" indexedname link, ocieb 2lit, ret, 73 | s" t" s" ocbflag" indexedname link, ocfb 2lit, ret, 74 | s" 't" s" ocb" indexedname link, there s" &'t" s" ocb" indexedname nextname constant 02 var, 75 | s" &'t" s" ocb" indexedname evaluate s" timer" s" _compare_b" indexedname evaluate ramvector 76 | 77 | s" t" s" comb" indexedname link, ( n -- ) 78 | tosl lsl, 79 | tosl lsl, 80 | tosl lsl, 81 | tosl lsl, 82 | tosl $30 andi, 83 | 84 | temp0 tccra fetch 85 | temp0 $cf andi, 86 | temp0 tosl or, 87 | tccra temp0 store 88 | 89 | drop, 90 | ret, 91 | 92 | [then] 93 | 94 | s" ocr" s" cl" indexedname find-name [if] 95 | s" t" s" occ" indexedname link, s" ocr" s" cl" indexedname evaluate const, 96 | s" t" s" occint" indexedname link, ociec 2lit, ret, 97 | s" t" s" occflag" indexedname link, ocfc 2lit, ret, 98 | s" 't" s" occ" indexedname link, there s" &'t" s" occ" indexedname nextname constant 02 var, 99 | s" &'t" s" occ" indexedname evaluate s" timer" s" _compare_c" indexedname evaluate ramvector 100 | 101 | s" t" s" comc" indexedname link, ( n -- ) 102 | tosl lsl, 103 | tosl lsl, 104 | tosl $0c andi, 105 | 106 | temp0 tccra fetch 107 | temp0 $f3 andi, 108 | temp0 tosl or, 109 | tccra temp0 store 110 | 111 | drop, 112 | ret, 113 | 114 | [then] 115 | 116 | s" icr" s" l" indexedname find-name [if] 117 | s" t" s" ic" indexedname link, s" icr" s" l" indexedname evaluate const, 118 | s" t" s" icint" indexedname link, icie 2lit, ret, 119 | s" t" s" icflag" indexedname link, icf 2lit, ret, 120 | s" 't" s" ic" indexedname link, there s" &'t" s" ic" indexedname nextname constant 02 var, 121 | s" &'t" s" ic" indexedname evaluate s" timer" s" _capture" indexedname evaluate ramvector 122 | 123 | s" t" s" icf" indexedname link, tccrb $07 2lit, ret, 124 | 125 | s" t" s" ice" indexedname link, ( n -- ) 126 | tosl $00 bst, 127 | 128 | temp0 tccrb fetch 129 | temp0 $06 bld, 130 | tccrb temp0 store 131 | 132 | drop, 133 | ret, 134 | 135 | [then] 136 | 137 | -------------------------------------------------------------------------------- /drivers/timer8new.f: -------------------------------------------------------------------------------- 1 | ( new 8 bit timer ) 2 | 3 | s" tcnt" s" " indexedname find-name [if] 4 | s" t" s" cnt" indexedname link, s" tcnt" s" " indexedname evaluate const, 5 | s" t" s" ovfint" indexedname link, toie 2lit, ret, 6 | s" t" s" ovfflag" indexedname link, tov 2lit, ret, 7 | s" 't" s" ovf" indexedname link, there s" &'t" s" ovf" indexedname nextname constant 02 var, 8 | s" &'t" s" ovf" indexedname evaluate s" timer" s" _overflow" indexedname evaluate ramvector 9 | 10 | s" t" s" clk" indexedname link, ( n -- ) 11 | tosl $07 andi, 12 | 13 | temp0 tccrb fetch 14 | temp0 $f8 andi, 15 | temp0 tosl or, 16 | tccrb temp0 store 17 | 18 | drop, 19 | ret, 20 | 21 | s" t" s" wgm" indexedname link, ( n -- ) 22 | tosh tosl mov, 23 | 24 | tosh $08 andi, 25 | 26 | temp0 tccrb fetch 27 | temp0 $f7 andi, 28 | temp0 tosh or, 29 | tccrb temp0 store 30 | 31 | tosh tosl mov, 32 | tosh lsr, 33 | tosh $02 andi, 34 | 35 | tosl $01 andi, 36 | 37 | temp0 tccra fetch 38 | temp0 $fc andi, 39 | temp0 tosh or, 40 | temp0 tosl or, 41 | tccra temp0 store 42 | 43 | drop, 44 | ret, 45 | 46 | [then] 47 | 48 | s" ocr" s" a" indexedname find-name [if] 49 | s" t" s" oca" indexedname link, s" ocr" s" a" indexedname evaluate const, 50 | s" t" s" ocaint" indexedname link, ociea 2lit, ret, 51 | s" t" s" ocaflag" indexedname link, ocfa 2lit, ret, 52 | s" 't" s" oca" indexedname link, there s" &'t" s" oca" indexedname nextname constant 02 var, 53 | s" &'t" s" oca" indexedname evaluate s" timer" s" _compare_a" indexedname evaluate ramvector 54 | 55 | s" t" s" coma" indexedname link, ( n -- ) 56 | tosl lsl, 57 | tosl lsl, 58 | tosl lsl, 59 | tosl lsl, 60 | tosl lsl, 61 | tosl lsl, 62 | tosl $c0 andi, 63 | 64 | temp0 tccra fetch 65 | temp0 $3f andi, 66 | temp0 tosl or, 67 | tccra temp0 store 68 | 69 | drop, 70 | ret, 71 | 72 | [then] 73 | 74 | s" ocr" s" b" indexedname find-name [if] 75 | s" t" s" ocb" indexedname link, s" ocr" s" b" indexedname evaluate const, 76 | s" t" s" ocbint" indexedname link, ocieb 2lit, ret, 77 | s" t" s" ocbflag" indexedname link, ocfb 2lit, ret, 78 | s" 't" s" ocb" indexedname link, there s" &'t" s" ocb" indexedname nextname constant 02 var, 79 | s" &'t" s" ocb" indexedname evaluate s" timer" s" _compare_b" indexedname evaluate ramvector 80 | 81 | s" t" s" comb" indexedname link, ( n -- ) 82 | tosl lsl, 83 | tosl lsl, 84 | tosl lsl, 85 | tosl lsl, 86 | tosl $30 andi, 87 | 88 | temp0 tccra fetch 89 | temp0 $cf andi, 90 | temp0 tosl or, 91 | tccra temp0 store 92 | 93 | drop, 94 | ret, 95 | 96 | [then] 97 | 98 | -------------------------------------------------------------------------------- /drivers/timer8old.f: -------------------------------------------------------------------------------- 1 | ( old 8 bit timer ) 2 | 3 | s" tcnt" s" " indexedname find-name [if] 4 | s" t" s" cnt" indexedname link, s" tcnt" s" " indexedname evaluate const, 5 | s" t" s" ovfint" indexedname link, toie 2lit, ret, 6 | s" t" s" ovfflag" indexedname link, tov 2lit, ret, 7 | s" 't" s" ovf" indexedname link, there s" &'t" s" ovf" indexedname nextname constant 02 var, 8 | s" &'t" s" ovf" indexedname evaluate s" timer" s" _overflow" indexedname evaluate ramvector 9 | 10 | s" t" s" clk" indexedname link, ( n -- ) 11 | tosl $07 andi, 12 | 13 | temp0 tccra fetch 14 | temp0 $f8 andi, 15 | temp0 tosl or, 16 | tccra temp0 store 17 | 18 | drop, 19 | ret, 20 | 21 | s" t" s" wgm" indexedname link, ( n -- ) 22 | tosh tosl mov, 23 | 24 | tosh lsl, 25 | tosh $08 andi, 26 | 27 | tosl lsl, 28 | tosl lsl, 29 | tosl lsl, 30 | tosl lsl, 31 | tosl lsl, 32 | tosl lsl, 33 | tosl $40 andi, 34 | 35 | temp0 tccra fetch 36 | temp0 $b7 andi, 37 | temp0 tosh or, 38 | temp0 tosl or, 39 | tccra temp0 store 40 | 41 | drop, 42 | ret, 43 | 44 | [then] 45 | 46 | s" ocr" s" a" indexedname find-name [if] 47 | s" t" s" oca" indexedname link, s" ocr" s" a" indexedname evaluate const, 48 | s" t" s" ocaint" indexedname link, ociea 2lit, ret, 49 | s" t" s" ocaflag" indexedname link, ocfa 2lit, ret, 50 | s" 't" s" oca" indexedname link, there s" &'t" s" oca" indexedname nextname constant 02 var, 51 | s" &'t" s" oca" indexedname evaluate s" timer" s" _compare_a" indexedname evaluate ramvector 52 | 53 | s" t" s" coma" indexedname link, ( n -- ) 54 | tosl lsl, 55 | tosl lsl, 56 | tosl lsl, 57 | tosl lsl, 58 | tosl $30 andi, 59 | 60 | temp0 tccra fetch 61 | temp0 $cf andi, 62 | temp0 tosl or, 63 | tccra temp0 store 64 | 65 | drop, 66 | ret, 67 | 68 | [then] 69 | 70 | -------------------------------------------------------------------------------- /drivers/twi.f: -------------------------------------------------------------------------------- 1 | ( two wire interface ) 2 | 3 | [ifdef] twdr 4 | 5 | s" twi" link, ( -- ) 6 | ( enable twi ) 7 | ( set scl to 400kHz at 16MHz system clock ) 8 | temp0 0c ldi, 9 | twbr temp0 store 10 | 11 | ( enable twi ) 12 | temp0 twen 2^ ldi, 13 | twcr temp0 store 14 | ret, 15 | 16 | 17 | s" /twi" link, ( -- ) 18 | ( disable twi ) 19 | twcr zero store 20 | ret, 21 | 22 | 23 | s" twiwait" link, ( -- ) 24 | ( wait for twi operation to complete ) 25 | label twiwait_ 26 | begin, 27 | twcr twint skip-bit-clear 28 | ret, 29 | pause_ call 30 | again, 31 | 32 | 33 | s" twistart" link, ( -- ) 34 | ( send a start condition ) 35 | temp0 twint 2^ twsta 2^ or twen 2^ or ldi, 36 | twcr temp0 store 37 | twiwait_ jump 38 | 39 | 40 | s" twistop" link, ( -- ) 41 | ( send a stop condition ) 42 | temp0 twint 2^ twsto 2^ or twen 2^ or ldi, 43 | twcr temp0 store 44 | ret, 45 | 46 | 47 | s" twitx" link, ( c -- ) 48 | ( send byte ) 49 | twdr tosl store 50 | drop, 51 | temp0 twint 2^ twen 2^ or ldi, 52 | twcr temp0 store 53 | twiwait_ jump 54 | 55 | 56 | s" twirx" link, ( -- c ) 57 | ( receive byte, send ack ) 58 | temp0 twint 2^ twea 2^ or twen 2^ or ldi, 59 | twcr temp0 store 60 | twiwait_ call 61 | dup, 62 | tosl twdr fetch 63 | tosh clr, 64 | ret, 65 | 66 | 67 | s" twirxn" link, ( -- c ) 68 | ( receive byte, send nack ) 69 | temp0 twint 2^ twen 2^ or ldi, 70 | twcr temp0 store 71 | twiwait_ call 72 | dup, 73 | tosl twdr fetch 74 | tosh clr, 75 | ret, 76 | 77 | 78 | s" twistat" link, ( -- c ) 79 | ( get twi status code ) 80 | dup, 81 | tosl twsr fetch 82 | tosl 0f8 andi, 83 | tosh clr, 84 | ret, 85 | 86 | [then] 87 | 88 | -------------------------------------------------------------------------------- /drivers/usart.f: -------------------------------------------------------------------------------- 1 | ( usart driver ) 2 | 3 | [ifdef] udr0 4 | 5 | ( data buffer ) 6 | 7 | usart0_tx_size 1 - constant usart0_tx_mask 8 | usart0_rx_size 1 - constant usart0_rx_mask 9 | 10 | 01 var usart0_tx_in 11 | 01 var usart0_tx_out 12 | usart0_tx_size var usart0_tx_data 13 | 14 | 01 var usart0_rx_in 15 | 01 var usart0_rx_out 16 | usart0_rx_size var usart0_rx_data 17 | 18 | s" usart0" link, ( -- ) 19 | ( enable usart ) 20 | label usart0_ 21 | usart0_tx_in zero store 22 | usart0_tx_out zero store 23 | usart0_rx_in zero store 24 | usart0_rx_out zero store 25 | temp0 usbs 2^ ucsz0 2^ or ucsz1 2^ or ldi, ( 2 stop bits, 8cs) 26 | ucsr0c temp0 store 27 | temp0 txen 2^ rxen 2^ or rxcie 2^ or ldi, 28 | ucsr0b temp0 store 29 | ret, 30 | 31 | s" /usart0" link, ( -- ) 32 | ( disable usart ) 33 | label /usart0_ 34 | ucsr0b zero store 35 | ret, 36 | 37 | s" baud0" link, ( u -- ) 38 | ( set baud divisor ) 39 | label baud0_ 40 | ubrr0l tosl store 41 | ubrr0h tosh store 42 | drop, 43 | ret, 44 | 45 | s" tx0" link, ( c -- ) 46 | ( send character to usart ) 47 | label tx0_ 48 | begin, 49 | xl usart0_tx_in fetch 50 | xl inc, 51 | xl usart0_tx_mask andi, 52 | 53 | xh usart0_tx_out fetch 54 | xh xl cp, 55 | z while, 56 | pause_ call 57 | repeat, 58 | 59 | usart0_tx_in xl store 60 | zl usart0_tx_data lo ldi, 61 | zh usart0_tx_data hi ldi, 62 | zl xl add, 63 | zh zero adc, 64 | tosl stz, 65 | drop, 66 | ucsr0b udrie set-bit 67 | ret, 68 | 69 | s" tx0?" link, ( -- ; f ) 70 | ( test if character can be sent ) 71 | label tx0?_ 72 | xl usart0_tx_in fetch 73 | xl inc, 74 | xl usart0_tx_mask andi, 75 | xh usart0_tx_out fetch 76 | xh xl cp, 77 | ret, 78 | 79 | idpx 80 | 81 | usart0_udre vector 82 | pushsreg 83 | xl push, 84 | xh push, 85 | zl push, 86 | zh push, 87 | 88 | xl usart0_tx_in fetch 89 | xh usart0_tx_out fetch 90 | 91 | xh xl cp, 92 | z if, 93 | ucsr0b udrie clear-bit 94 | else, 95 | xh inc, 96 | xh usart0_tx_mask andi, 97 | usart0_tx_out xh store 98 | 99 | zl usart0_tx_data lo ldi, 100 | zh usart0_tx_data hi ldi, 101 | zl xh add, 102 | zh zero adc, 103 | 104 | xl ldz, 105 | udr0 xl store 106 | then, 107 | 108 | zh pop, 109 | zl pop, 110 | xh pop, 111 | xl pop, 112 | popsreg 113 | reti, 114 | 115 | idpx 116 | 117 | s" rx0" link, ( -- c ) 118 | ( fetch character from uart ) 119 | label rx0_ 120 | begin, 121 | xh usart0_rx_out fetch 122 | 123 | xl usart0_rx_in fetch 124 | xh xl cp, 125 | z while, 126 | pause_ call 127 | repeat, 128 | 129 | xh inc, 130 | xh usart0_rx_mask andi, 131 | usart0_rx_out xh store 132 | 133 | zl usart0_rx_data lo ldi, 134 | zh usart0_rx_data hi ldi, 135 | zl xh add, 136 | zh zero adc, 137 | 138 | dup, 139 | tosl ldz, 140 | tosh clr, 141 | ret, 142 | 143 | s" rx0?" link, ( -- ; f ) 144 | ( test if character is available ) 145 | label rx0?_ 146 | usart0_rx_out fetch 147 | usart0_rx_in fetch 148 | xh xl cp, 149 | ret, 150 | 151 | idpx 152 | 153 | usart0_rxc vector 154 | pushsreg 155 | xl push, 156 | xh push, 157 | zl push, 158 | zh push, 159 | 160 | xl usart0_rx_in fetch 161 | xh usart0_rx_out fetch 162 | 163 | xl inc, 164 | xl usart0_rx_mask andi, 165 | xh xl cp, 166 | z if, 167 | xl udr0 fetch 168 | else, 169 | usart0_rx_in xl store 170 | 171 | zl usart0_rx_data lo ldi, 172 | zh usart0_rx_data hi ldi, 173 | zl xl add, 174 | zh zero adc, 175 | 176 | xl udr0 fetch 177 | xl stz, 178 | then, 179 | 180 | zh pop, 181 | zl pop, 182 | xh pop, 183 | xl pop, 184 | popsreg 185 | reti, 186 | 187 | idpx 188 | 189 | [endif] 190 | 191 | [ifdef] udr1 192 | 193 | ( data buffer ) 194 | 195 | usart1_tx_size 1 - constant usart1_tx_mask 196 | usart1_rx_size 1 - constant usart1_rx_mask 197 | 198 | 01 var usart1_tx_in 199 | 01 var usart1_tx_out 200 | usart1_tx_size var usart1_tx_data 201 | 202 | 01 var usart1_rx_in 203 | 01 var usart1_rx_out 204 | usart1_rx_size var usart1_rx_data 205 | 206 | s" usart1" link, ( -- ) 207 | ( enable usart ) 208 | label usart1_ 209 | usart1_tx_in zero store 210 | usart1_tx_out zero store 211 | usart1_rx_in zero store 212 | usart1_rx_out zero store 213 | temp0 txen 2^ rxen 2^ or rxcie 2^ or ldi, 214 | ucsr1b temp0 store 215 | ret, 216 | 217 | s" /usart1" link, ( -- ) 218 | ( disable usart ) 219 | label /usart1_ 220 | ucsr1b zero store 221 | ret, 222 | 223 | s" baud1" link, ( u -- ) 224 | ( set baud divisor ) 225 | label baud1_ 226 | ubrr1l tosl store 227 | ubrr1h tosh store 228 | drop, 229 | ret, 230 | 231 | s" tx1" link, ( c -- ) 232 | ( send character to usart ) 233 | label tx1_ 234 | begin, 235 | xl usart1_tx_in fetch 236 | xl inc, 237 | xl usart1_tx_mask andi, 238 | 239 | xh usart1_tx_out fetch 240 | xh xl cp, 241 | z while, 242 | pause_ call 243 | repeat, 244 | 245 | usart1_tx_in xl store 246 | zl usart1_tx_data lo ldi, 247 | zh usart1_tx_data hi ldi, 248 | zl xl add, 249 | zh zero adc, 250 | tosl stz, 251 | drop, 252 | ucsr1b udrie set-bit 253 | ret, 254 | 255 | s" tx1?" link, ( -- ; f ) 256 | ( test if character can be sent ) 257 | label tx1?_ 258 | xl usart1_tx_in fetch 259 | xl inc, 260 | xl usart1_tx_mask andi, 261 | xh usart1_tx_out fetch 262 | xh xl cp, 263 | ret, 264 | 265 | idpx 266 | 267 | usart1_udre vector 268 | pushsreg 269 | xl push, 270 | xh push, 271 | zl push, 272 | zh push, 273 | 274 | xl usart1_tx_in fetch 275 | xh usart1_tx_out fetch 276 | 277 | xh xl cp, 278 | z if, 279 | ucsr1b udrie clear-bit 280 | else, 281 | xh inc, 282 | xh usart1_tx_mask andi, 283 | usart1_tx_out xh store 284 | 285 | zl usart1_tx_data lo ldi, 286 | zh usart1_tx_data hi ldi, 287 | zl xh add, 288 | zh zero adc, 289 | 290 | xl ldz, 291 | udr1 xl store 292 | then, 293 | 294 | zh pop, 295 | zl pop, 296 | xh pop, 297 | xl pop, 298 | popsreg 299 | reti, 300 | 301 | idpx 302 | 303 | s" rx1" link, ( -- c ) 304 | ( fetch character from uart ) 305 | label rx1_ 306 | begin, 307 | xh usart1_rx_out fetch 308 | 309 | xl usart1_rx_in fetch 310 | xh xl cp, 311 | z while, 312 | pause_ call 313 | repeat, 314 | 315 | xh inc, 316 | xh usart1_rx_mask andi, 317 | usart1_rx_out xh store 318 | 319 | zl usart1_rx_data lo ldi, 320 | zh usart1_rx_data hi ldi, 321 | zl xh add, 322 | zh zero adc, 323 | 324 | dup, 325 | tosl ldz, 326 | tosh clr, 327 | ret, 328 | 329 | s" rx1?" link, ( -- ; f ) 330 | ( test if character is available ) 331 | label rx1?_ 332 | usart1_rx_out fetch 333 | usart1_rx_in fetch 334 | xh xl cp, 335 | ret, 336 | 337 | idpx 338 | 339 | usart1_rxc vector 340 | pushsreg 341 | xl push, 342 | xh push, 343 | zl push, 344 | zh push, 345 | 346 | xl usart1_rx_in fetch 347 | xh usart1_rx_out fetch 348 | 349 | xl inc, 350 | xl usart1_rx_mask andi, 351 | xh xl cp, 352 | z if, 353 | xl udr1 fetch 354 | else, 355 | usart1_rx_in xl store 356 | 357 | zl usart1_rx_data lo ldi, 358 | zh usart1_rx_data hi ldi, 359 | zl xl add, 360 | zh zero adc, 361 | 362 | xl udr1 fetch 363 | xl stz, 364 | then, 365 | 366 | zh pop, 367 | zl pop, 368 | xh pop, 369 | xl pop, 370 | popsreg 371 | reti, 372 | 373 | idpx 374 | 375 | [endif] 376 | 377 | -------------------------------------------------------------------------------- /drivers/usb-device.f: -------------------------------------------------------------------------------- 1 | ( usb device ) 2 | 3 | [ifdef] udcon 4 | 5 | ( remote wake up ) 6 | s" usb-wakeup" link, ( -- ) 7 | udcon rmwkup set-bit 8 | ret, 9 | 10 | ( attach ) 11 | s" usb-attach" link, ( -- ) 12 | udcon detach clear-bit 13 | ret, 14 | 15 | ( detach ) 16 | s" usb-detach" link, ( -- ) 17 | udcon detach set-bit 18 | ret, 19 | 20 | ( detect reset ) 21 | s" usb-reset?" link, ( -- f ) 22 | dup, 23 | tos zero movw, 24 | udint eorsti skip-bit-clear 25 | tos 1 sbiw, 26 | ret, 27 | 28 | ( acknowledge reset ) 29 | s" usb-reset-ack" link, ( -- ) 30 | udint eorsti clear-bit 31 | ret, 32 | 33 | ( address ) 34 | 35 | s" usb-address" link, ( n -- ) 36 | tosl $7f andi, 37 | udaddr tosl store 38 | drop, 39 | ret, 40 | 41 | s" usb-address-enable" link, ( -- ) 42 | udaddr adden set-bit 43 | ret, 44 | 45 | ( endpoint control ) 46 | 47 | s" ep-set" link, ( n -- ) 48 | tosl $07 andi, 49 | uenum tosl store 50 | drop, 51 | ret, 52 | 53 | s" ep-get" link, ( -- n ) 54 | dup, 55 | tosl uenum fetch 56 | tosl $07 andi, 57 | tosh clr, 58 | ret, 59 | 60 | s" ep-stall" link, ( -- ) 61 | ueconx stallrq set-bit 62 | ret, 63 | 64 | s" ep-continue" link, ( -- ) 65 | ueconx stallrqc set-bit 66 | ret, 67 | 68 | s" ep-reset-toggle" link, ( -- ) 69 | ueconx rstdt set-bit 70 | ret, 71 | 72 | s" ep-enable" link, ( -- ) 73 | ueconx epen set-bit 74 | ret, 75 | 76 | s" ep-disable" link, ( -- ) 77 | ueconx epen clear-bit 78 | ret, 79 | 80 | s" ep-enabled?" link, ( -- f ) 81 | dup, 82 | tos zero movw, 83 | ueconx epen skip-bit-clear 84 | tos 1 sbiw, 85 | ret, 86 | 87 | s" type-control" link, $00 const, 88 | s" type-isochronous" link, $40 const, 89 | s" type-bulk" link, $80 const, 90 | s" type-interrupt" link, $c0 const, 91 | 92 | s" ep-type" link, ( n -- ) 93 | tosl $c0 andi, 94 | temp0 uecfg0x fetch 95 | temp0 $3f andi, 96 | temp0 tosl or, 97 | uecfg0x temp0 store 98 | drop, 99 | ret, 100 | 101 | s" dir-out" link, $00 const, 102 | s" dir-in" link, $01 const, 103 | 104 | s" ep-dir" link, ( n -- ) 105 | tosl $01 andi, 106 | temp0 uecfg0x fetch 107 | temp0 $fe andi, 108 | temp0 tosl or, 109 | uecfg0x temp0 store 110 | drop, 111 | ret, 112 | 113 | s" size-8bytes" link, $00 const, 114 | s" size-16bytes" link, $10 const, 115 | s" size-32bytes" link, $20 const, 116 | s" size-64bytes" link, $30 const, 117 | s" size-128bytes" link, $40 const, 118 | s" size-256bytes" link, $50 const, 119 | 120 | s" ep-size" link, ( n -- ) 121 | tosl $70 andi, 122 | temp0 uecfg1x fetch 123 | temp0 $8f andi, 124 | temp0 tosl or, 125 | uecfg1x temp0 store 126 | drop, 127 | ret, 128 | 129 | s" bank-single" link, $00 const, 130 | s" bank-double" link, $04 const, 131 | 132 | s" ep-bank" link, ( n -- ) 133 | tosl $0c andi, 134 | temp0 uecfg1x fetch 135 | temp0 $f3 andi, 136 | temp0 tosl or, 137 | uecfg1x temp0 store 138 | drop, 139 | ret, 140 | 141 | s" ep-allocate" link, ( -- ) 142 | uecfg1x alloc set-bit 143 | ret, 144 | 145 | s" ep-deallocate" link, ( -- ) 146 | uecfg1x alloc clear-bit 147 | ret, 148 | 149 | s" ep-ready?" link, ( -- f ) 150 | dup, 151 | tos zero movw, 152 | ueintx rwal skip-bit-clear 153 | tos 1 sbiw, 154 | ret, 155 | 156 | s" rx-setup?" link, ( -- f ) 157 | dup, 158 | tos zero movw, 159 | ueintx rxstpi skip-bit-clear 160 | tos 1 sbiw, 161 | ret, 162 | 163 | s" setup-ack" link, ( -- ) 164 | ueintx rxstpi clear-bit 165 | ret, 166 | 167 | s" rx-out?" link, ( -- f ) 168 | dup, 169 | tos zero movw, 170 | ueintx rxouti skip-bit-clear 171 | tos 1 sbiw, 172 | ret, 173 | 174 | s" out-ack" link, ( -- ) 175 | ueintx rxouti clear-bit 176 | ueintx fifocon clear-bit 177 | ret, 178 | 179 | s" tx-in?" link, ( -- f ) 180 | dup, 181 | tos zero movw, 182 | ueintx txini skip-bit-clear 183 | tos 1 sbiw, 184 | ret, 185 | 186 | s" in-ack" link, ( -- ) 187 | ueintx txini clear-bit 188 | ueintx fifocon clear-bit 189 | ret, 190 | 191 | s" epc!" link, ( c -- ) 192 | uedatx tosl store 193 | drop, 194 | ret, 195 | 196 | s" ep!" link, ( x -- ) 197 | uedatx tosl store 198 | uedatx tosh store 199 | drop, 200 | ret, 201 | 202 | s" epc@" link, ( -- c ) 203 | dup, 204 | tosl uedatx fetch 205 | tosh clr, 206 | ret, 207 | 208 | s" ep@" link, ( -- x ) 209 | dup, 210 | tosl uedatx fetch 211 | tosh uedatx fetch 212 | ret, 213 | 214 | s" ep-bytes" link, ( -- n ) 215 | dup, 216 | tosl uebclx fetch 217 | tosh uebchx fetch 218 | ret, 219 | 220 | [then] 221 | 222 | -------------------------------------------------------------------------------- /drivers/usb.f: -------------------------------------------------------------------------------- 1 | ( usb ) 2 | 3 | [ifdef] uhwcon 4 | 5 | ( usb modes ) 6 | 7 | s" usb-host" link, ( -- ) 8 | uhwcon zero store 9 | ret, 10 | 11 | s" usb-device" link, ( -- ) 12 | uhwcon uimod 2^ load 13 | ret, 14 | 15 | s" usb-uid" link, ( -- ) 16 | uhwcon uide 2^ load 17 | ret, 18 | 19 | ( enable ) 20 | s" usb" link, ( -- ) 21 | temp0 usbcon fetch 22 | temp0 usbe 2^ otgpade 2^ or ori, 23 | usbcon temp0 store 24 | uhwcon uvrege set-bit 25 | ret, 26 | 27 | ( disable ) 28 | s" /usb" link, ( -- ) 29 | temp0 usbcon fetch 30 | temp0 usbe 2^ otgpade 2^ or invert andi, 31 | usbcon temp0 store 32 | uhwcon uvrege clear-bit 33 | ret, 34 | 35 | ( freeze ) 36 | s" usb-freeze" link, ( -- ) 37 | usbcon frzclk set-bit 38 | ret, 39 | 40 | ( thaw ) 41 | s" usb-thaw" link, ( -- ) 42 | usbcon frzclk clear-bit 43 | ret, 44 | 45 | ( vbus status ) 46 | s" usb-vbus?" link, ( -- f ) 47 | dup, 48 | tos zero movw, 49 | usbsta vbus skip-bit-clear 50 | tos 1 sbiw, 51 | ret, 52 | 53 | [then] 54 | 55 | -------------------------------------------------------------------------------- /drivers/wdt.f: -------------------------------------------------------------------------------- 1 | ( wdt ) 2 | 3 | [ifdef] wdp3 s" wdp3" link, wdp3 const, [then] 4 | [ifdef] wdce s" wdce" link, wdce const, [then] 5 | [ifdef] wde s" wde" link, wde const, [then] 6 | [ifdef] wdp2 s" wdp2" link, wdp2 const, [then] 7 | [ifdef] wdp1 s" wdp1" link, wdp1 const, [then] 8 | [ifdef] wdtcsr s" wdtcsr" link, wdtcsr const, [then] 9 | [ifdef] wdif s" wdif" link, wdif const, [then] 10 | [ifdef] wdie s" wdie" link, wdie const, [then] 11 | [ifdef] wdp3 s" wdp3" link, wdp3 const, [then] 12 | [ifdef] wdce s" wdce" link, wdce const, [then] 13 | [ifdef] wde s" wde" link, wde const, [then] 14 | [ifdef] wdp2 s" wdp2" link, wdp2 const, [then] 15 | [ifdef] wdp1 s" wdp1" link, wdp1 const, [then] 16 | [ifdef] wdp0 s" wdp0" link, wdp0 const, [then] 17 | 18 | [ifdef] wdrf s" wdrf" link, wdrf const, [then] 19 | [ifdef] borf s" borf" link, borf const, [then] 20 | [ifdef] extrf s" extrf" link, extrf const, [then] 21 | [ifdef] porf s" porf" link, porf const, [then] 22 | [ifdef] mcusr s" mcusr" link, mcusr const, [then] 23 | -------------------------------------------------------------------------------- /drivers/xmem.f: -------------------------------------------------------------------------------- 1 | ( external memory ) 2 | 3 | [ifdef] xmcra 4 | 5 | ( enable ) 6 | s" xmem" link, ( -- ) 7 | xmcra sre set-bit 8 | ret, 9 | 10 | ( disable ) 11 | s" /xmem" link, ( -- ) 12 | xmcra sre clear-bit 13 | ret, 14 | 15 | ( upper/lower split address ) 16 | 17 | s" xmem-split" link, ( x -- ) 18 | tosl $07 andi, 19 | tosl swap, 20 | temp0 xmcra fetch 21 | temp0 $8f andi, 22 | temp0 tosl or, 23 | xmcra temp0 store 24 | ret, 25 | 26 | ( wait states ) 27 | 28 | s" xmem-wait-lower" link, ( x -- ) 29 | tosl $03 andi, 30 | temp0 xmcra fetch 31 | temp0 $fc andi, 32 | temp0 tosl or, 33 | xmcra temp0 store 34 | drop, 35 | ret, 36 | 37 | s" xmem-wait-upper" link, ( x -- ) 38 | tosl $03 andi, 39 | tosl lsl, 40 | tosl lsl, 41 | temp0 xmcra fetch 42 | temp0 $f3 andi, 43 | temp0 tosl or, 44 | xmcra temp0 store 45 | ret, 46 | 47 | ( bus keepers ) 48 | s" xmem-keep" link, ( -- bit ) 49 | xmcrb xmbk 2lit, 50 | ret, 51 | 52 | ( address mask bits ) 53 | s" xmem-mask" link, ( x -- ) 54 | tosl $07 andi, 55 | temp0 xmcrb fetch 56 | temp0 $f8 andi, 57 | temp0 tosl or, 58 | xmcrb temp0 store 59 | ret, 60 | 61 | [then] 62 | 63 | -------------------------------------------------------------------------------- /img/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kristianlm/avr-emacs/947884b10983b9459440071088db85618185a0f8/img/board.jpg -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # user modifiable secion is up here 2 | BAUD=9600 3 | DEVICE=atmega328p 4 | PROGRAMMER=avrispmkII 5 | PROGPORT=usb 6 | TERMPORT=/dev/ttyACM0 7 | 8 | # hopefully, you don't have to touch anything down here 9 | VERSION=2010.06.13 10 | 11 | SEND=gforth ./send.f $(TERMPORT) 12 | AVRDUDE=sudo avrdude -c $(PROGRAMMER) -p $(DEVICE) -P $(PROGPORT) 13 | GFORTH=gforth 14 | 15 | avrforth: avrforth.f config.f asm/* drivers/* 16 | $(GFORTH) -e ": device s\" $(DEVICE)\" ;" -e ": version s\" $(VERSION)\" ;" avrforth.f -e "bye" 17 | 18 | test: avrforth.f config.f asm/* drivers/* 19 | $(GFORTH) -e ": device s\" $(DEVICE)\" ;" -e ": version s\" $(VERSION)\" ;" avrforth.f 20 | 21 | upload: flash eeprom 22 | $(AVRDUDE) -e -U flash:w:flash:r -U eeprom:w:eeprom:r 23 | 24 | upload-highlevel: 25 | $(AVRDUDE) -e -U flash:w:flash.backup:r -U eeprom:w:eeprom.backup:r 26 | 27 | verify: flash eeprom 28 | $(AVRDUDE) -U flash:v:flash:r -U eeprom:v:flash:r 29 | 30 | download: 31 | $(AVRDUDE) -U flash:r:flash.backup:r -U eeprom:r:eeprom.backup:r 32 | 33 | terminal: 34 | $(AVRDUDE) -t -u 35 | 36 | reset: 37 | $(AVRDUDE) 38 | 39 | serial: 40 | # delbs : so that backspace works in my terminal 41 | # lfcr : so that newline works inside emacs (C-u M-x run-forth make serial) 42 | picocom -l --stopbits 2 --omap delbs,lfcr -b $(BAUD) $(TERMPORT) 43 | 44 | repl: 45 | # delbs : so that backspace works in my terminal 46 | # lfcr : so that newline works inside emacs (C-u M-x run-forth make serial) 47 | stty -F $(TERMPORT) $(BAUD) raw -echo 48 | csi -s repl.scm $(TERMPORT) 49 | 50 | highlevel: blocks/core.avrforth blocks/assembler.avrforth blocks/bit.avrforth blocks/extend.avrforth \ 51 | blocks/flag.avrforth blocks/lerp.avrforth blocks/eeprom.avrforth blocks/debug.avrforth \ 52 | blocks/pin.avrforth blocks/miniboard.avrforth blocks/oled.avrforth \ 53 | blocks/font4x6.avrforth blocks/morse.avrforth blocks/main.avrforth 54 | for block_ in $^; do $(SEND) $$block_ ; done 55 | 56 | 57 | # writing fuses can be dangerous, it can bring your chip. 58 | ___fuse: 59 | $(AVRDUDE) -U hfuse:w:0xD9:m -U lfuse:w:0xF2:m 60 | # we usually don't need to change efuse 61 | fuse: 62 | $(AVRDUDE) 63 | 64 | clean: 65 | rm -f flash eeprom 66 | 67 | dist: 68 | git archive --format=tar --prefix=avrforth-$(VERSION)/ \ 69 | $(VERSION) | gzip > /tmp/avrforth-$(VERSION).tar.gz 70 | 71 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | [avrforth]: http://krue.net/avrforth/ 3 | [ATmega328p]: https://en.wikipedia.org/wiki/ATmega328 4 | 5 | # A solderless mini text editor for $4.50 6 | 7 | Build a standalone [ATmega328p]-based text editor that is very simple 8 | to wire up. Not so simple to use, perhaps. This project exists mainly 9 | to educate myself on the innter workings of Forth, and Forth on the 10 | AVR microcontrollers, and use in practice. 11 | 12 | This is an [avrforth] adventure of mine. This is basically a fork of 13 | [avrforth-2010.06.13](http://krue.net/avrforth/avrforth-2010.06.13.tar.gz), 14 | but without the prior history because I couldn't find the official 15 | source repo. 16 | 17 | ![finished board](img/board.jpg) 18 | 19 | ``` 20 | ------ 21 | | oled | 22 | ____________ 23 | | | 24 | | | 25 | | mcu | 26 | | | 27 | |_A______X_Y_| 28 | 29 | ``` 30 | 31 | ## Parts 32 | 33 | - [ATmega328p](https://www.aliexpress.com/item/ATMEGA328P-ATMEGA328P-PU-DIP-28-New-parts-best-price-and-short-lead-time/32824792718.html) $1.50 34 | - [128x64 SD1306 0.96" OLED](https://www.aliexpress.com/item/0-96-White-0-96-Inch-OLED-Module-128X64-OLED-LCD-LED-Display-Module-For-Arduino/32847644906.html) $2.61 35 | - [prototyping board](https://www.aliexpress.com/item/Solderless-Mini-Breadboard-size-3-5x4-5cm-Black-color/32804715393.html) $0.30 36 | - [LED](https://www.aliexpress.com/item/Smart-Electronics-100pcs-lot-F3-3MM-Round-Red-Color-Highlight-Diffused-Round-DIP-Light-Emitting-Diode/32601503663.html) (100 pieces for $0.50) 37 | - [3 push buttons](https://www.aliexpress.com/item/1x-Tactile-Push-Button-Switch-Momentary-Tact-6x6x4-3-mm-2-pin-DIP-Through-Hole/32639451079.html) $ 0.08 each 38 | - One resistor to pull-up the RESET pin. Can be skipped for the brave 39 | hearted I think. 40 | - Some short breadboard cables (I make my own with [this](https://www.sparkfun.com/products/11367)). 41 | 42 | You will also need an AVR programmer that's capable of burning to the 43 | bootsector (I use avrispmkII) and a serial connection to bootstrap the 44 | code (I use Arduino). Getting this part set up is always such a 45 | hassle :-( 46 | 47 | ## Building 48 | 49 | - Update with your avrdude parameters in `makefile` 50 | - Update your termianl parameters in `makefile` 51 | - Update your chip model, usart and baud in `config.f` 52 | 53 | ```sh 54 | $ make # produces ./flash and ./eeprom 55 | $ make upload # burns these using avrdude 56 | $ make serial # check that you have a prompt. exit with C-a C-q for good stty settings 57 | $ make highlevel # sends blocks via serial, compiles avrforth code on-chip. watch for errors 58 | # reset chip and cross your fingers 59 | ``` 60 | 61 | > AVRispmkii might not work while your OLED screen is connected 62 | > because it doesn't like sharing the SPI connections for some reason. 63 | 64 | > Make sure you have your right fuses set. Remember that Arduino uses 65 | > an external crystal and our board does not. You have to program the 66 | > chip fuses so that it uses its internal oscillator. 67 | 68 | # Examples 69 | 70 | The documentation for [avrforth] is rather scarse. Your best option is 71 | probably to read the source code itself, which is luckily a pleasant 72 | experience. 73 | 74 | Below are some notes that I gathered while I was working on this. 75 | 76 | ### `$` ( -- x) 77 | 78 | Read upcoming 16bit hex value. You'll need this in front of your 79 | numerical input (except for some constants like `0` and `1`). See 80 | `core.avrforth`. 81 | 82 | ### `mark` 83 | 84 | This is an interesting one. All your colon definitions are immediately 85 | compiled and written to flash because the chip doesn't really have 86 | anywhere else to place your new instructions. These new definitions 87 | are found in a lookup dictionary starting on the address of the `link` 88 | pointer. 89 | 90 | If you reset your AVR, the new `link` address is lost and you're back 91 | to the dictionary since last `mark`. This can be very convenient when 92 | your previous definitions were buggy. 93 | 94 | `mark` will store your `link` from RAM into eeprom (`~link`). So 95 | `mark` will persist your dictionary across resets. 96 | 97 | ```forth 98 | > : test ] ; 99 | : test ] ; ok 100 | > ' test h. ( found! ) 101 | ' test h. ( found! ) 2a42 ok 102 | > empty 103 | empty ok 104 | > ' test h. ( gone ) 105 | ' test h. ( gone ) 0000 ok 106 | > : test ] ; 107 | : test ] ; ok 108 | > mark 109 | mark ok 110 | > empty 111 | empty ok 112 | > ' test h. ( survived ) 113 | ' test h. ( survived ) 2a18 ok 114 | ``` 115 | 116 | ### `empty` 117 | 118 | Revert your `link` and friends to your last `mark`. 119 | 120 | ### `it` 121 | 122 | This is a pointer to an eeprom variable that you can use to set the 123 | startup procedure, aka turnkey. 124 | 125 | : start ." booting ..." ." done!" ] cr ] ; 126 | mark 127 | ' start it e! 128 | ( chip reset should now display "booting ...done!" ) 129 | 130 | ## `if` (just checks the `z` flag) 131 | 132 | > : tst ( x -- x) ] 0? ] if ." nonzero " ] ; ] then ." zero " ] ; 133 | > $ 000 tst h. 134 | h.zero 0000 ok 135 | $ 001 tst h. 136 | nonzero 0001 ok 137 | 138 | ## `=if` 139 | 140 | > : equal? ( x1 x1 -- ) ] ?? ] drop ] drop ] =if ." yes " ] ; ] then ." no " ] ; 141 | ok 142 | > $ abba $ abba equal? 143 | yes ok 144 | > $ abba $ beef equal? 145 | no ok 146 | 147 | ## `+!` 148 | 149 | > 2 var K 150 | 2 var K ok 151 | > K @ h. 152 | K @ h. 3433 ok 153 | > 0 K ! h. 154 | 0 K ! h. 0100 ok 155 | > K @ h. 156 | K @ h. 0000 ok 157 | > 1 K +! h. 158 | > $ abba 1 K +! h. 159 | $ abba 1 K +! h. abba ok 160 | > K @ h. 161 | K @ h. 0002 ok 162 | > $ abba 4 K +! h. 163 | $ abba 4 K +! h. abba ok 164 | > K @ h. 165 | K @ h. 0006 ok 166 | 167 | ## `word` 168 | 169 | > : echo" [ $ 22 l ] word ] type ] ; 170 | : echo" [ $ 22 l ] word ] type ] ; ok 171 | > $ beef echo" testing 123" h. 172 | 173 | ### `digit` ( c -- n ) 174 | 175 | `n` is ascii value of `c` 176 | 177 | ### `#` ( x -- x') 178 | 179 | Print the uppermost hex digit of `x`. `x'` becomes digits shifted one 180 | left. `h.` uses this internally. 181 | 182 | > $ 1234 # # # # 1234 ok 183 | 184 | ### `10*` ( x1 -- x2 ) 185 | 186 | `x2` is `x1` shifted left 1 hex digit. 187 | 188 | 189 | ### `task-queue` 190 | 191 | [avrforth] offers an impressive multitasking feature that lets you run 192 | your interactive shell alongside other jobs. The shell can stop and 193 | redefine words used by other tasks on-the-fly (see `'btns.updater` for 194 | how to do this). 195 | 196 | ```forth 197 | ( silly busy-waiting task ) 198 | : annoying ." annoying" ] cr [ $ ffff l ] for ] pause ] next ] annoying ] ; 199 | 200 | ( reserve RAM for task) 201 | $ 40 var task.annoying 202 | 203 | \ mytask $ 100 $ ff fill 204 | \ mytask $ fff0 and $ 101 dump 205 | 206 | ' annoying $ 20 $ 20 task.annoying task-init ( set various return pointers etc in RAM ) 207 | 208 | task.annoying task-queue ( next pause will now take us to annoying ) 209 | ( now watch it print while prompt is still alive ) 210 | ( then do this: ) 211 | task.annoying task-dequeue ( to stop the annoying printouts ) 212 | ``` 213 | 214 | # Troubleshooting 215 | 216 | There is an ocean of things that can go wrong. Usually nothing will 217 | tell you what that is though. 218 | 219 | ### `send.f` hangs 220 | 221 | Make sure your serial is set up ok: 222 | 223 | for i in {{ 0 100 }} ; do echo test $i ; done > testlines 224 | ./send.f /dev/ttyUSB0 testlines 225 | 226 | ### Flashing is ok, but any colon-definition freezes the controller 227 | 228 | Maybe the fuse bits are wrong? You need to set them so there's a big 229 | bootloader. See `make fuse`. 230 | 231 | ### Serial port drops characters randomly 232 | 233 | Are you sure only one program is using it the tty? Try: 234 | 235 | sudo lsof | grep /dev/ttyACM0 # or your equivalent 236 | 237 | # License 238 | 239 | Like [avrforth], this project is Public Domain. 240 | -------------------------------------------------------------------------------- /repl.scm: -------------------------------------------------------------------------------- 1 | ;;; CHICKEN Scheme repl util 2 | ;;; 3 | ;;; usage: csi -s repl.scm /dev/ttyUSB0 4 | ;;; 5 | ;;; Always prints data coming in from tty 6 | ;;; Reads lines from stdin and waiting for ack \r on tty 7 | ;;; before sending next line. 8 | ;;; 9 | ;;; This is basically exactly what send.f does, but reads from tty 10 | ;;; continuously. I don't have the gforth foo to do this in gforth yet. 11 | (use posix srfi-18 srfi-13) 12 | 13 | (define debug (begin print void)) 14 | (define tty (file-open (car (command-line-arguments)) open/rdwr)) 15 | 16 | (define ttyin (open-input-file* tty)) 17 | 18 | ;; slurp all data available and wait for newline 19 | (define (flush-input block?) 20 | (let loop () 21 | (if (or block? (char-ready? ttyin)) 22 | 23 | (let* ((got (file-read tty 1)) 24 | (read (cadr got)) ;; number of bytes 25 | (byte (car got)) 26 | (_ (if (= 0 read) (exit)))) 27 | (cond ((eof-object? byte)) 28 | ((equal? "\n" byte) (loop)) 29 | ((equal? "\r" byte) (display "\n") (flush-output)) ;; exits loop 30 | (else (display byte) (flush-output) (loop)))) 31 | (begin (debug "strange, no data here"))))) 32 | 33 | (debug "tty: " tty) 34 | (let loop () 35 | (debug "waiting for tty or stdin") 36 | ;; aggressive tty data slurping 37 | (let ((readyfd (car (file-select (list tty 0) '())))) 38 | (debug "ready on " readyfd) 39 | (cond ((= readyfd tty) 40 | (debug ">> handling tty") 41 | (flush-input #f) 42 | (debug ">> handling tty done")) 43 | ((= readyfd 0) 44 | (debug "> handing stdin") 45 | (let ((line (read-line))) 46 | (when (eof-object? line) (exit 0)) 47 | (unless (string-prefix? "\\ " line) 48 | (file-write tty line))) 49 | (file-write tty "\r") 50 | (debug "> waiting for nl") 51 | (flush-input #t) 52 | (debug "> block done")))) 53 | (loop)) 54 | -------------------------------------------------------------------------------- /send.f: -------------------------------------------------------------------------------- 1 | #! /usr/bin/gforth 2 | 3 | ( send source file to serial port ) 4 | 5 | hex 6 | 0d constant nl 7 | 80 constant bufsize 8 | 9 | 0 value ser 10 | 0 value src 11 | 12 | ( older versions of gforth use different argument numbers ) 13 | version-string s" 0.6.9-20070604" compare 0< [if] 14 | : arg 1 + arg ; 15 | [then] 16 | 17 | : init ( -- ) 18 | 1 arg r/w open-file throw to ser 19 | 2 arg r/o open-file throw to src ; 20 | : fini ( -- ) ser close-file throw src close-file throw ; 21 | 22 | : getsrc ( -- u f ) pad bufsize src read-line throw ; 23 | : putsrc ( u -- ) pad swap ser write-line throw nl ser emit-file throw ser flush-file throw ; 24 | : resp ( -- ) begin ser key-file dup nl <> while emit repeat drop ser key-file drop cr ; 25 | 26 | : lines begin getsrc while putsrc resp repeat ; 27 | 28 | init lines fini bye 29 | 30 | -------------------------------------------------------------------------------- /uno.avrforth: -------------------------------------------------------------------------------- 1 | 2 | ( wait a little ) 3 | : idle [ $ 8000 l ] for ] next ] ; 4 | 5 | ( $ 00 portb c! ) 6 | 7 | : on [ $ 00 l ] ddrb ] c! ] ; 8 | : off [ $ ff l ] ddrb ] c! ] ; 9 | 10 | ( testing ) 11 | on 12 | off 13 | 14 | : blink ] on ] idle ] off ] idle ] ; 15 | : blinks ] for ] blink ] next ] ; 16 | 17 | ( blink 10 times ) 18 | $ a blinks 19 | --------------------------------------------------------------------------------