Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 HW #6 Write an assembly program to calculate the sum of the ten scores stored in memory as shown on the right. You can use any instruction used in the.

Similar presentations


Presentation on theme: "1 HW #6 Write an assembly program to calculate the sum of the ten scores stored in memory as shown on the right. You can use any instruction used in the."— Presentation transcript:

1 1 HW #6 Write an assembly program to calculate the sum of the ten scores stored in memory as shown on the right. You can use any instruction used in the lecture slides but try to minimize your instruction set. If you need to, you can make your own instruction such as LDC. LDC // Load constant number to AC ex) LDC 9 // AC <= 9

2 function call vs. goto main ( ) { for (i=0; i < 10; i++) add (&sum, score ); printf (“%d”, sum); } add (&sum, score ) { sum = sum + score[i]; } 2 main ( ) { i = 0; loop : sum = sum + score[i]; i = i + 1; if (i != 10) goto loop; printf (“%d”, sum); }

3 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, AND 0xxx 8xxxAND memory word to AC ADD 1xxx 9xxxAdd memory word to AC BUN 4xxx CxxxBranch unconditionally BSA 5xxx DxxxBranch and save return address ISZ 6xxx ExxxIncrement and skip if zero SymbolI = 0I = 1Description isz T4 ~ T6 : D 6 T 4 : DR <- M[AR] D 6 T 5 : DR <- DR +1 D 6 T 6 : M[AR] <- DR, if (DR = 0) then PC <- PC +1, SC <- 0


Download ppt "1 HW #6 Write an assembly program to calculate the sum of the ten scores stored in memory as shown on the right. You can use any instruction used in the."

Similar presentations


Ads by Google