T-Machine (pronounce
tea-machine)
Instruction format
op:5 d:5 s1:5 s2:5
add d s1 s2, r[d] =
r[s1] + r[s2]
op:5 d:5 ads:22
ld d ads, r[d] =
M[ads]
st ads d, M[ads]
= r[d]
jmp - ads
jt d ads
jf d ads
instruction encoding
1 add
2 le
3 ld
4 st
5 jmp
6 jt
7 jf
Register Transfer Level
fetch
mbus <- M[pc]
ir <- mbus;
pc <- pc+1
add
T <-
alu(add,s2,s1), [next]
r[d] <- T,
[fetch]
ld
r[d] <- M[ads],
[fetch]
st
M[ads] <-
alu(pass,d,-), [fetch]
jmp
pc <- ads
jt
if alu(true,d,-) then
pc <- ads
Example of an assembly language program for t-machine
To add 1..10 and keep the result in r[3]
assume
r[1] = 1,
r[2] = 10,
r[0] = 0
r[3] = result, initially 0
r[4] = tmp
r[5] = flag
// assembly program
add r4 r1 r0 // set r4 1
loop: add r3 r4 r3
add r4 r4 r1 // increment i
le r5 r4 r2 // i <= 10?
jt r5 loop
end
last update 24 Jan 2012