Thursday, December 24, 2009

I need some help coding theese to problems in 68000 assembly language. Any help would be appreciated.?

1.


Write a 68000 program, which calculates the factorial of the minimum value, stored in the following array:





The list to be sorted is: INPUT DC.B Put your student id in a comma separated list


(exclude 0s at start of student id)





Your program should store the minimum value in a memory location called MIN.


The factorial of the minimum value should be stored in a memory location, called MINFACT.





2.


Write a 68000 program, which determines whether the maximum number in the INPUT array is odd or even.


Your program should store the answer in register D7.


A value of 1 indicates that the number is odd and a value of 0 indicates that the number is even.





Your program should also store the maximum answer in a memory location, called MAX, which you must define.





3.


Write a 68000 program, which processes the INPUT array by calculating the factorial values of all odd numbers.





Your program should store the factorial answers in an array, called FACTS.I need some help coding theese to problems in 68000 assembly language. Any help would be appreciated.?
lea a0, INPUT





# find min


moveq #NumberOfStudentIDBytesThatYouHaveNotTol鈥?d0





move.b (a0)+, d1 // Current minimum





minLoop:


move.b (a0)+, d2


cmb.p d1,d2


bge minNoChange


move.b d2, d1 // Update minimum





minNoChange:


subq #1, d0


bne.s minLoop





move.b d1, MIN // Save minimum





moveq #1, d2 // Start factorial





doFactorial:


mult d1, d2 // I forget this exact instruction - some multiply


subq #1, d1


bge doFactorial





move.w d2, MINFACT // I presume you need 16 bits for the factorial of 8 bits ...





That's roughly it ... I'm sure there are bugs. It's been 15 years since I touched a 68K computer.








#2 ... to detect if a value is odd





moveq #1, d0


and.b d0, d1


bne.s OddNumber





# 3


Factorial calculation is above -you should be able to munge it together.

No comments:

Post a Comment