Final exam review help

Guys, I have this question that my teacher gave as a review. I dont find anything wrong. Please help
Examine the following fragment of pseudocode and its translation into 68K assembly language. Work through this code and ensure that you understand it. Is the program correct? Can you improve it?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
* X = 5  
* Y = 7 
* FOR I= 1 TO 9  
* Y == Y + I
*IF T(I) = J(I) + X THEN J(I) = T(I) * 4 - Y
*                   ELSE J(I) = J ( D - T(I)
*END_FOR 
*  
            ORG         $400  
            MOVEA       #T, A0            A0 point at base of array T
            MOVEA       #J,A1             Al points at base of array J  
            MOVE        #1,D0             Use D0 as a counter to hold I                
            MOVE        #5,D1             X = 5; Dl is X
            MOVE        #7,D2             Y = 7;  D2 is Y  
Next        ADD         D0,D2	   Y = Y + I 
            MOVE        (A0), D3	    Read T(I) into D3
            MOVE        (A1),D4	    Read J(I) into D4
            MOVE        D4,D5		    D5 is a temp copy of J(I)
            ADD         D1,D5		    Compute J(I) + X in D5
            CMP	        D5,D3	    IF T(I) = J(I) +X
        BNE Else
            MULU        #4,D3		   THEN compute T(I) * 4 -Y
            SUB         D2,D3
            MOVE        D3, (Al) 	     J(I)= T(I) *4 -Y
        BRA End_loop
Else 		SUB D3,D4		      J(I)=J(I) -T(I)
             MOVE       D4,(Al)			
End_Loop ADDA #2,A0		     Point to next element in T
            ADDA        #2, Al		     Point to next element in J
            ADD         #1, D0		     Increment the loop counter
            CMP         #10,D0		      Repeat until I=10
            BNE 	Next
Last edited on
I know next to nothing about 68k asm but
1
2
3
FOR 1= 1 TO 9[\code] doesn't right to me. If you can't see it then maybe you need to try a font that isn't shit.

[code]ELSE J(I) = J ( D - T(I) 
This is making me dizzy, it's putting me off balance.

Someone's using tabs for alignment instead of spaces. It makes the comments a little hard to read when they zig-zag across the screen... Scratch that, someone's using MIXED tabs and spaces for alignment.


IS that better?
Topic archived. No new replies allowed.