Verilog HW #8 Due Nov. 13, 100점 만점, 발표자 보너스 최대 30점

Download Report

Transcript Verilog HW #8 Due Nov. 13, 100점 만점, 발표자 보너스 최대 30점

Verilog HW #8

Write an assembly program to calculate the sum of
the ten scores stored in memory as shown on the
right. Store the sum in the address 99.

You can use any instruction used in the lecture
slides but try to minimize your instruction set.

If you need, you can make your own instruction such
as LDC. But, remember that you have to implement it
in your CPU eventually.
LDC // Load constant number to AC
ex) LDC 9 // AC <= 9

Calculate the total cycles to complete the program.
1

과제마감은 11월 13일

11월 10일에 자신의 어셈블리코드에 대한
발표를 하는 학생은 최대 30점 보너스.
2
function call vs. goto
main ( ) {
for (i=0; i < 10; i++)
add (&sum, score );
printf (“%d”, sum);
main ( ) {
i = 0;
loop : sum = sum + score[i];
i = i + 1;
if (i != 10) goto loop;
}
printf (“%d”, sum);
add (&sum, score ) {
sum = sum + score[i];
}
}
3
Symbol I = 0
I=1
Description
AND
ADD
BUN
BSA
ISZ
8xxx
9xxx
Cxxx
Dxxx
Exxx
AND memory word to AC
Add memory word to AC
Branch unconditionally
Branch and save return address
Increment and skip if zero
0xxx
1xxx
4xxx
5xxx
6xxx
add 110
// AC <= AC + mem[110]
add [110] // AC <= AC + mem[mem[110]]
isz 100 // mem[100]= mem[100]+1
// if mem[100] == 0, skip next instruction,
isz T4 ~ T6 :
D6T4: DR <- M[AR]
D6T5: DR <- DR +1
D6T6: M[AR] <- DR, if (DR = 0)
then PC <- PC +1, SC <- 0