Easy68K assembly only please!! Not C++, C, Java, etc. Assembly only. Example com
ID: 3865841 • Letter: E
Question
Easy68K assembly only please!! Not C++, C, Java, etc. Assembly only. Example commands include MOVE, CMP, ORG $1000, BRA, etc. Thank you!
Please initialize an array [5, 0, 12, 3, 8, 21, 1, 14, 2, 16] and perform the following operations on this array. You need to use subroutine and branch to finish this question. There should be 3 major subroutines “a”, “b” and “c” in the program, one for each requirement given below:
Subroutine “a”: Keep loading numbers from keyboard until the input is 0 or 1. Hint: load the input from keyboard. Check whether the input is 0 or 1, and ask user to load another input if it’s neither 0 nor 1. Store the value only when it’s 0 or 1 and continue to part b
Subroutine “b”: Go through all the elements and pass current odd/even number to subroutine “c” for display. Hint: find out all odd/even elements in the initialized array. That is, if the stored input is 0, use the subroutine “c” to print out ONLY the elements with odd values (5, 3, 21, 1). If the stored input is 1, use the subroutine “c” to print out ONLY the elements with even values (0, 12, 8, 14, 2, 16)
Subroutine “c”: Print out value passed by subroutine “b”, one in each line. Hint: print out the value from subroutine “b” on separate lines. You need to call this subroutine for 4 or 6 times inside the subroutine “b” to print out odd/even numbers.
Explanation / Answer
ORG $1000
START: ; first instruction of program
* Put program code here
LEA Array,A0
MOVE.B #5,0(A0)
MOVE.B #7,1(A0)
MOVE.B #12,2(A0)
MOVE.B #3,3(A0)
MOVE.B #8,4(A0)
MOVE.B #21,5(A0)
MOVE.B #11,6(A0)
MOVE.B #1,7(A0)
MOVE.B #2,8(A0)
MOVE.B #16,9(A0)
* Put variables and constants here
ARRAY DS.B 10 ; NOTE! The array was moved out of the code area
END START ; last line of source
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.