09 - Sequential Logic
09 - Sequential Logic
CS270 Unit 3
Max Luttrell, Fall 2016
Simple Machine coding
• translate high-language to simple machine code
val1gtr:
larger = val1;
done:
…
larger program
#
# if (0 > (val2-val1)) goto val1gtr;
0x100a # (addr=0) load VAL1
0x900b # sub VAL2
0x4000 # mvac
0x6007 # (addr=3) jlt val1gtr
# larger=val2;
0x100b # load VAL2
0x200c # store LARGER
# goto done;
0x7009 # jmp done
# val1gtr: larger=val1;
0x100a # (addr=7)val1gtr: load VAL1
0x200c # store LARGER
# done:
0x0000 # halt
0xFFFB # (addr=0xA) VAL1:first operand
0xFFF0 # (addr=0xB) VAL2:second operand
0x0000 # (addr=0xC) LARGER
looping
• the Simple machine offers a counter register and
3 instructions which are helpful for looping
op-
instr name description
code
again:
j += i;
i--;
check:
if (i<0) goto done;
goto again
done:
…
Exercise 3A
http://fog.ccsf.edu/~mluttrel/cs270/exercises/ex3a.html
Exercise 3B
1. examine the file sim/tests/addloop. note that the
comments are missing in more than half of the
program.