Commit efc5e2b6 authored by atzedijkstra@gmail.com's avatar atzedijkstra@gmail.com
Browse files

initial

parents
lx: ly: l1: lz: ldc 3 ldc 4 ldc -4 ldc 0x5 ldc -0x6 ldc l3 annote SP -3 0 red "Pushed constants" add mul sub bra l2 l3: bra l1 l2: bra l3 ldc l4: bsr l4
\ No newline at end of file
LDC 2 LDC 3 ADD
\ No newline at end of file
LDC 4 LDC 5 MUL LDC 2 LDC 6 MUL ADD
\ No newline at end of file
; ; Iterative version of faculty ; bra main Fac: link 1 ; fac( int n ) LDC 1 ; int res = 1 ; stl 1 FacTst: ldl -2 ; while ( n > 1 ) LDC 1 gt brf FacEnd ldl -2 ; res = res * n ldl 1 mul stl 1 ldl -2 ; n = n - 1 LDC 1 sub stl -2 bra FacTst FacEnd: ldl 1 ; return( res ) str RR unlink sts -1 ret main: LDC 6 bsr Fac ; fac( 6 ) trap 0 halt
\ No newline at end of file
bra main Fac: link 0 // fac( int n ) ldl -2 // if ( n <= 1 ) LDC 1 le brt FacTh ldl -2 // else return( n * fac( n-1 ) ) ; ldl -2 LDC 1 sub bsr Fac ldr RR mul bra FacEnd FacTh: LDC 1 // then return( 1 ) FacEnd: str RR unlink sts -1 ret main: LDC 6 annote SP 0 0 green argument bsr Fac // fac( 6 ) halt
\ No newline at end of file
BRA Main DoPtr: LINK 2 LDC 0x33333333 ; i = ... STL 2 LDLA 2 ; pi = & i STL 1 LDL 1 ; i = *pi LDA 0 STL 2 LDC 0x44444444 LDL 1 ; *pi = ... STA 0 LDC 0x55555555 ; invalid ref, *0x55555555 LDA 0 UNLINK RET Main: BSR DoPtr
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment