COMP226 Tutorial 5

Hand-in questions

This tutorial is about hand assembling and disassembling SPARC machine code. Students should refer to their copy of the reference card.

  1. The machine code for nop is 0x01000000 What is this instruction 'really'? Suggest some alternative instructions which have the same effect as nop.
  2. What does the following fragment of machine code do?
       0xB2100000
       0xB28D0019 
       0xB4A6A001 
       0x12BFFFFE 
       0x01000000
    
  3. Assemble the following SPARC code fragment
            add     %g0, 0, %i2
    loop:   andcc   %i3, 0x1, %g0
    	bz      skip 
    	srl     %i3, 1, %i3 
    	add     %i2, %i0, %i2 
    skip:   cmp     %i3, %g0 
    	bne     loop 
    	sll     %i0, 1, %i0
    

Discussion questions

  1. Your assignment expects you to do significant calculations using integer arithmetic. Isn't that unrealistic? Don't all machines nowadays have floating point capability? Why might you want to use integer arithmetic to calculate a division that's not expected to necessarily give a whole number answer?
  2. Speaking of arithmetic, computers always get the right answer right? Comment.
  3. Think of some occasions when you could run the same program on different computers and get different outcomes. As hints, consider non-integer arithmetic (one type of occasion) and things that might happen when other programs are running at the same time (another type of occasion). There may be more types too.

Kate and Mike, 2013. COMP226 home page