.. and my not so elegant code, it works as well and is commented a little bit. Good for beginners who are not reading forth's sources.. Thanks a lot Marcin, your code is of course optimised to the bones..Pito \ Assembler demo \ ATmega 1284p, amforth 4.0 \ v68.0, Pito 9/2010 marker -asstest : loadtos, R24 Y+ ld, R25 Y+ ld, ; \ define macro : savetos, -Y R25 st, -Y R24 st, ; \ tosl=R24, tosh=R25
code ++_ \ ( x1 x2 x3 -- x4 ) \ R8 R6 - tmp reg. \ x3 already in tos R8 R24 mov, R6 R25 mov, \ tmp = x3 \ drop x3 loadtos, \ x2 in tos R8 R24 add, R6 R25 adc, \ add tmp = x3 + x2 \ drop x2 loadtos, \ x1 in tos R8 R24 add, R6 R25 adc, \ add tmp = x3 + x2 + x1 \ drop x1 loadtos, \ put x4 on tos, x4 = tmp R24 R8 mov, R25 R6 mov, savetos, end-code ---------------------------- Ex: > 1111 2222 3333 ++_ . .sls 6666 [TOS> ] ok > 30000 -28000 -4000 ++_ . .sls -2000 [TOS> ] ok > -30000 15000 15000 ++_ . .sls 0 [TOS> ] ok > ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ Amforth-devel mailing list Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel