Skip to content

Instantly share code, notes, and snippets.

View owskio's full-sized avatar

Theodore Robert Cackowski owskio

View GitHub Profile
@owskio
owskio / symbolic_decade_solver.pl
Created February 5, 2021 01:12
A very nifty way of solving arithmetic constraints in Prolog
% This is a pretty neat program.
% Here I'm able to accomplish some lazy constraint programming with very few lines of code
% The trick is to make sure that terms in the base-case rules are grounded
% But this means using binary so that we only have to code for two grounded symbols (0, and 1)
% It also means representing the numbers in reverse ( and as lists )
% so that the least significant bits can be processed first at the top of the call stack
%
% The result is a generator (prolog generator) that can be placed into a 'findall' to enumerate answers
% It doesn't require any meta programming or search algorithms.
@owskio
owskio / AvrAssembly_DataStack.as
Last active April 1, 2018 22:09
I moved from a 1284 breadboard to an arduino-nano without the arduino software for forth development, so I'm accommodating 328p's now. Also added a data stack. (so this will be a subroutine threaded forth, but am toying with converting to a direct-threaded model) And cleaned up some things, dirtied some things, as usual.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;MAKEFILE EXCERPT
;
;#Output file in intel hex format with -fI
;
;serial:
; sudo putty /dev/ttyUSB0 -serial -sercfg 8,2,9600,n,N # "-cs ISO-8859-1" not necessary
;
;compile:
@owskio
owskio / AvrAssembly_EvalRom.as
Last active March 31, 2018 04:09
I can eval rom strings now! like the one in this gist "one lsl led". Composition capability unlocked!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;MAKEFILE EXCERPT
;
;#Output file in intel hex format with -fI
;
;serial:
; sudo putty /dev/ttyUSB0 -serial -sercfg 8,2,9600,n,N # "-cs ISO-8859-1" not necessary
;
;compile:
@owskio
owskio / AvrAssembly_ReadSearchDictExecute.as
Last active March 27, 2018 01:37
This single file assembly program is on its way to becoming a forth implementation! It reads uart input into a buffer, searches a dictionary structure for that 'word' and then executes the code associated with that word or prints 'Definition not found' via uart if that word is undefined.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;MAKEFILE EXCERPT
;
;#Output file in intel hex format with -fI
;
;serial:
; sudo putty /dev/ttyUSB0 -serial -sercfg 8,2,9600,n,N # "-cs ISO-8859-1" not necessary
;
;compile:
@owskio
owskio / AvrAssembly_BufferWordAndUartEcho.as
Last active March 11, 2018 01:18
This gist records uart-user-input in a 32 byte buffer and prints/echoes that value out via uart upon encountering a whitespace.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;MAKEFILE EXCERPT
;
;#Output file in intel hex format with -fI
;
;serial:
; sudo putty /dev/ttyUSB0 -serial -sercfg 8,2,9600,n,N # "-cs ISO-8859-1" not necessary
;
;compile:
@owskio
owskio / AvrAssembly_PrintRamMessageToUart.as
Created March 10, 2018 21:18
Was going to make the next gist buffing a word and then printing that out upon whitespace, but instead found this to be a good intermediate point
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;MAKEFILE EXCERPT
;
;#Output file in intel hex format with -fI
;
;serial:
; sudo putty /dev/ttyUSB0 -serial -sercfg 8,2,9600,n,N # "-cs ISO-8859-1" not necessary
;
;compile:
@owskio
owskio / AvrAssembly_PrintFlashMessageToUart.as
Last active March 9, 2018 05:17
Prints "Ted does assembly!" to the open uart serial terminal. (a more legitimate 'hello world')
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;MAKEFILE EXCERPT
;
;#Output file in intel hex format with -fI
;
;serial:
; sudo putty /dev/ttyUSB0 -serial -sercfg 8,2,9600,n,N # "-cs ISO-8859-1" not necessary
;
;compile:
@owskio
owskio / AvrAssembly_HelloWorld.as
Last active March 9, 2018 05:13
The simplest avr assembly program I could come up with (does however include a macro), just initializes a port's direction and sets its output value to drive an 8 led array
;
; Hello world in assembly, for me, is actually just setting a port to a value,
; This can affect the state of a single LED, or 8 as in my case
; m1284def.asm can be found online
;
; Output file in intel hex format with -fI
;
; wine avrasm2.exe -fI -l test.lst test.asm \
;
; avrdude -c usbtiny -p atmega1284 -U flash:w:test.hex
@owskio
owskio / AvrAssembly_UartCharacterEcho.as
Last active March 11, 2018 00:41
Sets up a uart connection in avr assembly and just echoes the entered chars except for CRs which need LFs supplied because we are not catching/buffering
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;MAKE TARGETS - DONT FORGET THE TAB CHARS FOR MAKE
;
;serial:
; sudo putty /dev/ttyUSB0 -serial -sercfg 8,2,9600,n,N # "-cs ISO-8859-1" not necessary
;
; Output file in intel hex format with -fI
;compile:
; wine avrasm2.exe -fI -l test.lst test.asm
@owskio
owskio / AvrAssembly_PreprocessorVsAsmMacros.as
Last active March 9, 2018 05:16
Still trying to formulate some opinions about these, routines seem to be good for saving memory (haha) and keeping the listing file readable, while macros seem to be good for abstracting expressions that leverage assembler features like 'high()','low()', or 'x*2'
;
; Output file in intel hex format with -fI
;
; wine avrasm2.exe -fI -l test.lst test.asm and; avrdude -c usbtiny -p atmega1284 -U flash:w:test.hex
;
.nolist
.include "./m1284def.asm"
.list