brought calculadora from other sketch folder
This commit is contained in:
parent
a3bc94ac1d
commit
5cc8389f89
|
@ -92,6 +92,7 @@ ready-assembled projects:
|
||||||
* `nibble.tal`: small demo drawing all the nibble dice
|
* `nibble.tal`: small demo drawing all the nibble dice
|
||||||
* `audio-prototype0.tal`: first iteration of sequencer / tracker with nibble dice. the dice are used to read/write into memory:
|
* `audio-prototype0.tal`: first iteration of sequencer / tracker with nibble dice. the dice are used to read/write into memory:
|
||||||
- you can manipulate the dice in order to change pulse period (1 byte), pitch (1 byte), adsr values (2 bytes), volume (1 byte), "bang" sequencing (?) (1 byte); to toggle a melody sequencer (1 bit), and/or modify the melody (8 bytes), and even the super low-res wave shape (8 bytes), for two audio devices (3 columns for the first one, 3 columns for the second one)
|
- you can manipulate the dice in order to change pulse period (1 byte), pitch (1 byte), adsr values (2 bytes), volume (1 byte), "bang" sequencing (?) (1 byte); to toggle a melody sequencer (1 bit), and/or modify the melody (8 bytes), and even the super low-res wave shape (8 bytes), for two audio devices (3 columns for the first one, 3 columns for the second one)
|
||||||
|
* `calculadora.tal`: experiment for an 8-bit rpn calculator, from before there was a console/vector available. for the moment it uses the keyboard input
|
||||||
|
|
||||||
# media
|
# media
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
( dev/console )
|
||||||
|
|
||||||
|
%RTN { JMP2r }
|
||||||
|
%print { DUP #18 DEO }
|
||||||
|
%printhex { DUP #19 DEO #0a #18 DEO }
|
||||||
|
%printnl { #0a #18 DEO }
|
||||||
|
%resetnumber { #00 STH }
|
||||||
|
%setnumber { #01 STH }
|
||||||
|
|
||||||
|
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|
||||||
|
|80 @Teclado [ &vector $2 &button $1 &key ]
|
||||||
|
|
||||||
|
|0000
|
||||||
|
|
||||||
|
|
||||||
|
( init )
|
||||||
|
|
||||||
|
|0100 ( -> )
|
||||||
|
|
||||||
|
( theme )
|
||||||
|
#a1f3 .System/r DEO2
|
||||||
|
#a14d .System/g DEO2
|
||||||
|
#a16c .System/b DEO2
|
||||||
|
|
||||||
|
LIT 'h #18 DEO
|
||||||
|
LIT 'o #18 DEO
|
||||||
|
LIT 'l #18 DEO
|
||||||
|
LIT 'a #18 DEO
|
||||||
|
#0a #18 DEO ( \n )
|
||||||
|
|
||||||
|
( #db ( 219 )
|
||||||
|
( #63 ,printdigits JSR )
|
||||||
|
|
||||||
|
( printhex )
|
||||||
|
|
||||||
|
resetnumber ( estado de número )
|
||||||
|
|
||||||
|
|
||||||
|
;tecla .Teclado/vector DEO2
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
|
||||||
|
@tecla
|
||||||
|
( get key )
|
||||||
|
.Teclado/key DEI
|
||||||
|
|
||||||
|
( echo )
|
||||||
|
print
|
||||||
|
|
||||||
|
( is digit? )
|
||||||
|
DUP #2f GTH ,numGT JCN
|
||||||
|
|
||||||
|
DUP #20 EQU ,spacebar JCN
|
||||||
|
|
||||||
|
( + )
|
||||||
|
DUP #2b EQU ,add JCN
|
||||||
|
|
||||||
|
( - )
|
||||||
|
DUP #2d EQU ,sub JCN
|
||||||
|
|
||||||
|
( * )
|
||||||
|
DUP #2a EQU ,mul JCN
|
||||||
|
|
||||||
|
( / )
|
||||||
|
DUP #2f EQU ,div JCN
|
||||||
|
|
||||||
|
( enter )
|
||||||
|
DUP #0d EQU ,enter JCN
|
||||||
|
|
||||||
|
POP ( descarta input leido )
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@spacebar
|
||||||
|
POP
|
||||||
|
( printhex )
|
||||||
|
STHr POP
|
||||||
|
resetnumber
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@enter
|
||||||
|
POP
|
||||||
|
printnl
|
||||||
|
LIT '> #18 DEO
|
||||||
|
#20 #18 DEO
|
||||||
|
,printdigits JSR
|
||||||
|
( printhex )
|
||||||
|
STHr POP
|
||||||
|
resetnumber
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@add
|
||||||
|
POP
|
||||||
|
ADD
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@sub
|
||||||
|
POP
|
||||||
|
SUB
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@mul
|
||||||
|
POP
|
||||||
|
MUL
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@div
|
||||||
|
POP
|
||||||
|
DIV
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@numGT
|
||||||
|
DUP #3a LTH ,numLT JCN
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@numLT ( is number )
|
||||||
|
#30 SUB ( calculate number )
|
||||||
|
STHr ,decimal JCN ( if not the first digit )
|
||||||
|
setnumber ( estado de número )
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@decimal
|
||||||
|
SWP #0a MUL
|
||||||
|
ADD
|
||||||
|
( printhex )
|
||||||
|
setnumber ( estado de número )
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@printdigits ( subroutine to print a byte in decimal )
|
||||||
|
DUP #64 DIV ( divide over 100 )
|
||||||
|
DUP2 #64 MUL SUB SWP DUP ( get the remainder )
|
||||||
|
,&print3digits JCN ( jump if there are 3 digits )
|
||||||
|
POP
|
||||||
|
|
||||||
|
( print 2 digits )
|
||||||
|
DUP #0a DIV ( divide over 10 )
|
||||||
|
DUP2 #0a MUL SUB SWP DUP ( get the remainder )
|
||||||
|
,&print2nddigit JCN ( jump if there are 2 digits )
|
||||||
|
POP
|
||||||
|
,&print1stdigit JMP
|
||||||
|
|
||||||
|
&print2nddigit
|
||||||
|
#30 ADD #18 DEO
|
||||||
|
|
||||||
|
&print1stdigit
|
||||||
|
#30 ADD #18 DEO
|
||||||
|
POP
|
||||||
|
printnl
|
||||||
|
RTN
|
||||||
|
|
||||||
|
&print3digits
|
||||||
|
#30 ADD #18 DEO
|
||||||
|
|
||||||
|
( print 2 digits )
|
||||||
|
( same routine as above but without conditionals )
|
||||||
|
DUP #0a DIV DUP2 #0a MUL SUB SWP
|
||||||
|
#30 ADD #18 DEO ( 2nd digit )
|
||||||
|
#30 ADD #18 DEO ( 1st digit )
|
||||||
|
|
||||||
|
POP
|
||||||
|
printnl
|
||||||
|
RTN
|
Loading…
Reference in New Issue