EE319KMid-Term1S10

# EE319KMid-Term1S10 - 1/8 EE 319K Spring 2010 First Mid-Term...

This preview shows pages 1–5. Sign up to view the full content.

1/8 EE 319K Spring 2010 First Mid-Term Dr. Ramesh Yerraballi Full Name : Duration : 75 minutes This is a closed book exam; No calculators are allowed; Write answers within the space provided after each of the questions. There are FOUR questions on the test, read all of them first so you may properly allocate your time to answer them. 1. [ 40 pts ] Answer the following a. [8 points] Compute the difference of the two decimal numbers 30 and 7 (i.e., 30-7 = 23) using 2’s complement binary representations for the two numbers. Show the working of the computation below: _ _ _ _ _ _ _ ; Carry _ _ _ _ _ _ _ _ ; 30 + _ _ _ _ _ _ _ _ ; -7 _ _ _ _ _ _ _ _ ; Result (23) b. [12 points] What would the values of N, Z, C and V flags and register A be after each of the instruction sequences given below. Use binary, decimal or hexadecimal to represent the contents of register A and show your notation appropriately. An X indicates you may ignore that bit. Instruction Sequence Register A N Z C V ldaa #128 adda #128 ldaa #\$1B asla X ldaa #50 suba #70 ldaa #-86 suba #108 X

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2/8 c. [10 points] Write the assembly code equivalent of the following C code snippet. Assume that there are assembly routines by the same names foo and bar that you can call. Specifically, you must declare x1 and x2 and write the code for the if-then- else statement. unsigned char x1,x2; . . // x1 and x2 are . // computed here . if (x1 <= x2) { foo(); } else { bar(); } d. [10 points] Assume RegA = \$34, RegX=\$4455 and RegY = \$5612. What is the value in Register X after executing these instructions? [Hint: Visualize the contents of the stack] psha stx 2,-sp sty 2,sp- leas 2,sp pula pulx X:
3/8 2. [25 points] Given the following partial listing file: Address Assembly Code Machine Code \$4000 org \$4000 \$4000 main lds #\$4000 \$CF4000 \$4003 ldd #24 \$CC0018 \$4005 pshd \$3B \$4006 bsr dump _______ \$4008 stop \$400A dump a. [7 points] Complete the listing by providing the machine code at location \$4006. [You may refer to the bsr instruction details provided] b. [10 points] Show the memory bus cycles for the execution of the pshd instruction (indicated with an arrow ) [You may or may not need all or more rows] Read/Write Address Data PC SP c. [8 points] Show the contents of the Stack when the subroutine dump is entered. Also show the value of the Stack Pointer (SP). [You may or may not need all or more rows] Address Contents SP:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3. [15 points] The following subroutine is intended to perform multiplication by means of successive addition. The comment next to each line states what needs to be done. You have to provide the assembly code that does it. ;**** Multiplication using successive addition **** ;inputs: Two unsigned non-zero numbers placed on the stack ; by the caller ;output: Result in Register D Mult _______ ; Save the return address in RegX pulb ; B gets multiplicand pula ; A gets multiplier _______ ; initialize Y (stores the temporary result) more _______ ; add B to Y
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/20/2012 for the course EE 319K taught by Professor Bard during the Fall '08 term at University of Texas.

### Page1 / 8

EE319KMid-Term1S10 - 1/8 EE 319K Spring 2010 First Mid-Term...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online