Homework 3

22C:18, Spring 1996

Due Tuesday Feb. 6, 1996, in discussion

Douglas W. Jones

Notice: We are working to install MAS on all macs in 103 MLH. It is installed on many of them (under the Apple menu). PLEASE DO NOT EDIT OR DELETE FILES IN THE MAS FOLDER!

  1. Use MAS to produce a printed assembly listing of the following, with added comments that give your name, the name of this class, and your section:
    	xref	stop, newline, strout
    start:
    	lea	msg,a0		; address
    	move.w  #msglen,d0	; length
    	jsr	strout		; call strout( address, count )
    	jsr	newline		; call newline
    	jsr	stop		; the end!
    
    	data
    
    msg:	dc.b	'hello world'
    msglen: equ	*-hello
    
    	end
    

  2. Given that the low word of d3 holds x, a 16 bit value, write a short sequence of M68000 instructions to compute abs(x) (the absolute value).

  3. What value does the following sequence of M68000 instructions leave in d5?
    	move.w	#$00FF,d5
    	ori.w	#$0F0F,d5
    	andi.w	#$3333,d5
    	eori.w	#$5555,d5
    
  4. Assuming that all variables are 32 bit integers, and that the registers d1, d2 and d3 are used to hold the variablex x, y and z, write a sequence of M68000 assembly language instructions that is equivalent to the following sequence of Pascal instructions:
        x := 0;
        y := 1;
        repeat
    	z := x + y;
    	y := x;
    	x := z;
    	writeln( 'value = ', z )
        until z > 1000
    
    You need not run this program, but you may; this problem counts twice as much as the previous problems on this assignment!