



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Department of Electrical & Computer Engineering
We are given a table of student's test scores where there are three scores in a semester per student. Unfortunately, the person who entered the grades put them in the wrong order. They presently are in the following order. Student #1 test #2/test #3/test #1, Student #2 test #2/test #3/test #1… Student #200 test #2/test #3/test #1. We would like them to be in the following order. Student #1 test #1/test #2/test #3, Student #2 test #1/test #2/test #3… Student #200 test #1/test #2/test #3. Assume all scores start at 1000H (SRAM).
N EQU 200 TABLE EQU $ NEG1 EQU %11111111 ; $FF
ORG $1800 ; temporary data area TEMP DS.B 1 COUNT DS.B 1
ORG $ LDAA #N STAA COUNT LDX #TABLE ; ptr to top of table (immediate addressing) Loop_pt LDAB 0,X ; get test #2 score (indexed addressing) LDAA 1,X ; get test #3 score (indexed addressing) STAA TEMP ; save test #3 score in temp area (extended) LDAA 2,X ; get test #1 score (indexed) Re_order_data STAA 0,X ; store test #1 score (indexed) STAB 1,X ; store test #2 score (indexed) LDAA TEMP ; get test #3 score (extended) STAA 2,X ; store test #3 score (indexed) Check_counter LDAA COUNT ; retrieve count (extended) LDAB #NEG1 ; decrement counter (immediate) SUM_BA ; count = count -1 (inherent)
Department of Electrical & Computer Engineering
This code grabs a number from Table #1 @ $1100 and a number from Table #2 @ $1110 and then computes an average value which is then stored in a Table #3, starting at $1120.
b) This process is repeated 16 ($10) decimal times. c) We must save the count in a temporary memory location because the A register is corrupted inside the loop that retrieves the data and computes the average value.
Address (Hex)
Data (Hex) Instructions 0 08 LDX^ #$ 1 00 2 11 3 02 LDAA^ #$ 4 10 5 06 STAA^ $ 6 00 7 12 8 0C LOOP:^ LDAA 0,X 9 00 A 0E LDAB^ $10,X B 10 C 15 SUM_AB D 1F SHFB_R E 12 STAB $20,X F 20 10 30 INX 11 03 LDAB^ #$FF 12 FF 13 04 LDAA^ $ 14 00 15 12 16 14 SUM_BA 17 20 BEQ^ DONE 18 1E 19 06 STAA^ $ 1A 00 1B 12 1C 21 BNE LOOP 1D 08 1E 20 DONE:^ BEQ^ DONE 1F 1E
Address (Hex)
Data (Hex) Instructions 0 08 00 11^ LDX^ #$ 3 02 10^ LDAA^ #$ 5 06 00 12^ STAA^ $ 8 0C 00^ LOOP:^ LDAA^ 0,X A 0E 10^ LDAB^ $10,X C 15 SUM_AB D 1F SHFB_R E 12 20^ STAB^ $20,X 10 30 INX 11 03 FF LDAB #$FF 13 04 00 12^ LDAA^ $ 16 14 SUM_BA 17 20 1E^ BEQ^ DONE 19 06 00 12^ STAA^ $ 1C 21 08^ BNE^ LOOP 1E 20 1E^ DONE:^ BEQ^ DONE
Department of Electrical & Computer Engineering
ORG $ STAA $1400 ; temporarily store the A reg value COMA ; /A AND_BA ; /AB STAA $1401 ; save /AB for future use LDAA $1400 ; restore original A reg value COMB ; /B AND_BA ; A /B TAB LDAA $1401 ; retrieve /AB OR_BA ; (A/B) + (/AB)
This code performs the exclusive or of registers A and B (A xor B = A/B + /AB) and then returns this value in register A. Two temporary locations are required, 1400H and 1401H.
NUM EQU $7F+1 ; = $ Neg1 EQU $FF Neg37 EQU $DB ; -37 = -$25 = -(%0010 0101) Table EQU $
Department of Electrical & Computer Engineering
Q5:0 IR5:0 Z N D5:0 MSA MSB MSC IR_LD RW PMXY SEL PC_LD M_LD X_LD Y_LD XD YD 000001 110010 - - 110100 01 10 0000 0 1 1000 00 00 00 00 00 0 0 110100 ------ - - 000000 01 10 0000 0 1 0000 00 10 00 00 00 0 0
$addr => PCL