Nick Johnson Chapter 4 problems 2. 0xCCDD 7. a) sethi 0xABCD, %r12 0001 1001 0000 0000 1010 1011 1100 1101 b) call label_b 0111 1111 1111 1111 1111 1111 1111 1111 c) orcc %r15, 255, %r22 1010 1100 1001 0011 1100 0000 0000 1111 d) be label_d 0000 0010 1000 0000 0000 0000 0100 1100 e) st %r25, [%r9 + 128] 1111 0010 0010 0100 0000 0000 1000 1001 f) srl %r8, 31, %r9 1001 0011 0011 0010 0010 0000 00001 1111 8. a) illegal, because 0xABCDEF is more than 22 bits b) legal c) legal d) illegal, missing operands e) legal f) illegal, shift number must be between 0-31 12. ! swaps x = 25 and y = 50 which are in memory ld [x + %r0], %r1 ! %r1 ← 25 ld [y + %r0], %r2 ! %r2 ← 50 st %r1, [y + %r0] ! y ← 25 st %r2, [x + %r0] ! x ← 50 13. loads 40 into %r1 subtracts 4 from %r1 and loads it back into %r1 = 36 and set condition codes stores %r1 = 36 into [k] bneg doesn't branch because N flag is not set loads value in address [%r1 + a] into %r2 loads value in address [%r1 + b] into %r3 adds values in %r2 and %r3 and stores result in %r4 and sets condition codes stores that result in that is in %r4 into address [%r1 + c] branch always to Y which is the beginning of the code This code simulates a while-loop. It keeps subtracting 4 from [k] until [k] becomes negative. Then it will branch to [X] where it will jump to address [%r15 + 4]. 16. sethi can't load 32 bits because instructions are only 32 bits wide. There is no room for a 32 bit immediate in an instruction. 17. data linkage 18. One machine is little-endian and the other is big-endian.