Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (53 sloc) 902 Bytes
R6 <- 0 # S_0
R7 <- 0 # S_1
R10 <- 74 # just a test value
R3 <- 0 # output register
R2 <- (-1 + -1) # mask to zero LSB
R5 <- lsh(1 + 1) # 4
R5 <- lsh(R5 + R5) # 16
goto START
STATE_0:
R3 <- (R3 + 1)
(R4); if Z goto START # only change state if input is 1
R6 <- 1
goto START
STATE_1:
(R4); if Z goto B # only change s if I is 0
goto START
B:
R6 <- 0
R7 <- 1
goto START
STATE_2:
(R4); if Z goto START
R6 <- 1
goto START
STATE_3:
R3 <- (R3 + 1)
(R4); if Z goto I
goto START
I:
R6 <- 0
R7 <- 0
START: # begin of main loop
(R5); if Z goto END # quit
R5 <- (R5 + -1)
(R10); if N goto MSB_1
R4 <- 0
goto Y
MSB_1:
R4 <- 1
Y:
R10 <- lsh(R10)
R3 <- lsh(R3) # left shift R3 to make room for the next output
(R6); if Z goto M # switch execution according to state
(R7); if Z goto N
goto STATE_3
N:
goto STATE_1
M:
(R7); if Z goto O
goto STATE_2
O:
goto STATE_0
END: # the end
Something went wrong with that request. Please try again.