Notice: Machine problems should be turned in as assembly listings, so that we can examine and comment on the way you wrote your code, and on diskette, so we can test your program. The MAS source code for MP1 should be in a file called MP1 in the diskette's top-level directory. In addition to the comment containing your name, the course number, your section, and the program title, you should include this information on the label on the diskette so it can be easily returned to you!
program spin( input, output ); var t: 0..65535; begin write( "enter a positive number:" ); readln( t ); repeat writeln( t ); if odd( t ) then t := (t * 3) + 1; else t := t div 2; until t <= 1; writeln( t ); end.In this exercise, don't worry about detecting overflow!
MULS.W #3,D0 ADDQ.W #1,D0Part A: Modify this code to detect overflow! That is, make it branch to code to print an error message and stop the program if the result of either the addition or the multiplication is greater than 65535.
Part B: The multiply instruction on the M68000 chip is a complex instruction that takes a long time to compute its result, while the add and shift instructions (see ASL, for example) are quite fast. Rewrite the above instruction sequence, without attention to overflow, so that it uses a sequence of fast instructions instead of the slow MULS instruction.
var x: array [1..8] of record x,y: -2048 .. 2048 end;