vextoly/cryn

[# a linked list built from raw blocks: node = [value next] #]
make string "\n" nl
make int64 total

define newline result nothing
  address nl
  output text
  set nothing
  return
end

define main
  make 2 of int64 n1
  make 2 of int64 n2
  make 2 of int64 n3
  make 2 of int64 cur

  move n3
  read
  move at
  set 30
  move 0
  write
  back
  set 0
  move 1
  write
  back

  move n3
  read
  convert int64
  push
  move n2
  read
  move at
  set 20
  move 0
  write
  back
  move 1
  pop
  write
  back

  move n2
  read
  convert int64
  push
  move n1
  read
  move at
  set 10
  move 0
  write
  back
  move 1
  pop
  write
  back

  set 0
  move total
  write

  move n1
  read
  push
  move cur
  write
  set 0
  move total
  write
  pop
  home

  mark walk
  move cur
  read
  compare 0
  jump done when equal

  move cur
  read
  move at
  move 0
  read
  output
  call newline
  push
  move total
  read
  add
  move total
  write

  move cur
  read
  move at
  move 1
  read
  convert address array of int64
  move cur
  write
  home
  jump walk

  mark done
  move total
  read
  output

  move n1
  read
  free
  move n2
  read
  free
  move n3
  read
  free
  return
end