<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title> amforth.asm </title><meta name="keywords" content="amforth programming language Forth ATmega ATMEL"><meta name="description" content="amforth - laguage Forth for ATMEL ATmega"><!-- AUTOINCLUDE START "Page/Head.en.ihtml" DO NOT REMOVE --><link rel="StyleSheet" href="../../../../Web/CSS/MLAB.css" type="text/css" title="MLAB Basic Style"><link rel="StyleSheet" href="../../../../Web/CSS/MLAB_Print.css" type="text/css" media="print"><link rel="shortcut icon" type="image/x-icon" href="../../../../Web/PIC/MLAB.ico"><script type="text/javascript" src="../../../../Web/JS/MLAB_Menu.js"></script><!-- AUTOINCLUDE END --></head><body lang="en"><!-- AUTOINCLUDE START "Page/Header.en.ihtml" DO NOT REMOVE --><!-- ============== HEADER ============== --><div class="Header"><script type="text/javascript"><!--SetRelativePath("../../../../");DrawHeader();// --></script><noscript><p><b> JavaScript is required for including of the header </b></p></noscript></div><!-- AUTOINCLUDE END --><!-- AUTOINCLUDE START "Page/Menu.en.ihtml" DO NOT REMOVE --><!-- ============== MENU ============== --><div class="Menu"><script type="text/javascript"><!--SetRelativePath("../../../../");DrawMenu();// --></script><noscript><p><b> JavaScript is required for including of the menu </b><p></noscript></div><!-- AUTOINCLUDE END --><!-- ============== TEXT ============== --><div class="Text"><h1> amforth.asm </h1><p><input type=button onClick="history.back()" value="Back"><input type=button onClick="history.forward()" value="Forward"><a href="../WordList.en.html">Jump to Vocabulary</a></p><pre>;;;; avr forth;;;;;;;; GPL V2 (only).set pc_ = pc.org $0000rjmp reset.org pc_; main entry pointreset:clr zerolclr zeroh; init first user data arealdi zl, low(heap)ldi zh, high(heap)movw upl, zl; init return stack pointerldi temp0,low(ramend)out SPL,temp0std Z+2, temp0ldi temp1,high(ramend)out SPH,temp1std Z+3, temp1; init parameter stack pointerldi yl,low(stackstart)std Z+6, ylldi yh,high(stackstart)std Z+7, yh; allocate space for User Area.set heap = heap + USERSIZE; load Forth IP with starting wordldi xl, low(PFA_COLD)ldi xh, high(PFA_COLD); the following should be turnkey-action, but adds a few more words to the the dictionarycall_ device_init; its a far jump...jmp_ DO_NEXT; ISR routines.include "words/intx.asm".include "words/usart.asm"; lower part of the dictionary.include "dict_minimum.asm".if dict_optional==1.include "dict_optional.asm".endif.set lowflashlast = pc; high part of the dictionary (primitives and words for self programming).org nrww; the inner interpreter.DO_DODOES:adiw wl, 1savetosmovw tosl, wlpop whpop wlpush xhpush xlmovw xl, wlrjmp DO_NEXTDO_COLON: ; 31 CPU cycles to ijmppush xhpush xl ; PUSH IPadiw wl, 1 ; set W to PFAmovw xl, wlDO_NEXT: ; 24 CPU cycles to ijmpbrts DO_INTERRUPTmovw zl,xl ; READ IPlsl zlrol zhlpm wl, Z+lpm wh, Z ; done read IPadiw xl, 1 ; INC IPDO_EXECUTE: ; 12 cpu cycles to ijmpmovw zl, wllsl zlrol zhlpm temp0, Z+lpm temp1, Zmovw zl, temp0ijmpDO_INTERRUPT: ; 12 cpu cycles to rjmp (+12=24 to ijmp); here we deal with interrupts the forth waylds temp0, intcurldi zl, LOW(intvec)ldi zh, HIGH(intvec)add zl, temp0adc zh, zerohldd wl, Z+0ldd wh, Z+1clt ; clear the t flag to indicate that the interrupt is handledrjmp DO_EXECUTE.include "dict_high.asm".if dict_optional==2.include "dict_optional.asm".endif.set flashlast = pc.eseg.dw lowflashlast ; DP.dw VE_HEAD ; HEAD.dw heap ; HEAP.dw edp ; EDP.dw XT_VER ; TURNKEY.dw baud_rate ; BAUDRATE; 1st free address in EEPROM, see aboveedp:.cseg</pre><p><input type=button onClick="history.back()" value="Back"><input type=button onClick="history.forward()" value="Forward"><a href="../WordList.en.html">Jump to Vocabulary</a></p></div><!-- AUTOINCLUDE START "Page/Footer.en.ihtml" DO NOT REMOVE --><!-- ============== FOOTER ============== --><div class="Footer"><script type="text/javascript"><!--SetRelativePath("../../../../");DrawFooter();// --></script><noscript><p><b> JavaScript is required for including of the footer </b></p></noscript></div><!-- AUTOINCLUDE END --></body></html>