CS 224, F2015 Homework #5 S05: Stacks / Interrupts Name Questions: Answers: Section Score / 38 1. (3 points) Define subroutine cohesion. What properties of cohesion should be found in your subroutines? 2. (3 points) Define subroutine coupling. What properties of coupling should be found in your subroutines? 3. (6 points) What is wrong (if anything) with the following blinky program? DELAY mainloop: xor.b push.w call jmp delay: push.w mov.w delay02: dec.w jne dec.w jne pop.w ret .equ 100 #0x01,&P1OUT ; toggle P1.0 #DELAY ; pass delay #delay ; call delay mainloop r15 #0,r15 ; callee-save ; init counter r15 delay02 2(SP) delay02 r15 ; ; ; ; ; ; delay over? n y, outer done? n y, restore r15 return 4. (6 points) What would be the difference in code size and the cycles used to toggle the LED on and off then (assume it is off), if the delay subroutine below was placed in-line? DELAY mainloop: xor.b mov.w call jmp delay: dec.w jne ret .equ 10 #0x01,&P1OUT ; toggle P1.0 #DELAY,r15 ; pass delay #delay ; call delay mainloop r15 delay BYU, CS 224, F2015 ; delay over? ; n ; y, return Homework #5 Page 1/2 5. (4 points) What values may be found in a subroutine activation record? 6. (6 points) When an Internet surfer opens Google and types in a keyword, the command goes to one of the company’s U.S. data centers, which are large-scale facilities with hundreds of computer servers. In the last seven years (2002-2008), the utility bills to power and cool the servers and auxiliary equipment at U.S. data centers increased from $15 billion to $30 billion in 2008. List 3 ways we as computer software developers, can reduce power consumption and realize significant environmental and economic benefits? 7. (4 points) Power consumption is directly related to the number of instruction cycles used by a system. Show and explain the difference in power consumption between a. adding a Program A (that uses a billion cycles on startup and then another billion cycles once per subsequent year) to a system, and b. adding a single extra instruction cycle to an existing Program B (which executes 1024 times per second). Explain your answer in terms of cycles per year. 8. (6 points) A watch crystal has a strange looking frequency of 32,768 Hz (cycles/second). This frequency is convenient for real-time clocks because it is the largest positive value that can be used with a decrementing 16-bit counter. When the timer counts down to zero, one second has expired. a. John Harrison’s H4 chronometer (clock) accumulated an error of 5.1 seconds over 81 days when it was first taken to sea for testing in 1761. A typical watch crystal has an error of 20 parts per million (ppm). How many times more accurate was Harrison’s clock than a watch crystal controlled clock? b. How accurate of a crystal is needed for a real-time clock (in parts per million error) in order to be at least as accurate as Harrison’s clock? (Hint: Read “Clock accuracy in ppm” found in the Readings section of References.) BYU, CS 224, F2015 Homework #5 Page 2/2