judofyr/rcpu — pull request #10 by Deradon (2012-04-09 19:09:39+00:00)
Title: readline doing 'SUB a,1" 2 times.

Read line was doing 2 times:

SUB a, 1

This seemed wrong to me.
I was not able to enter, lets say 10 charactes with readline.
But I was able to use exactly half the characters.

block :readline do
SET push, j

label :write

# We are only allowed to read i characters.
IFE a, 0
SET pc, :done

SUB a, 1

# There are no characters left in the stream.
IFE [b], 0
SET pc, :done

SET j, [b+1]
IFE j, 10 # newline
SET pc, :done

SET [c], j
ADD c, 1
SUB a, 1

# Next char.
SET pc, :write

label :done
SET j, pop
SET pc, pop
end