( 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