EE319KMid-Term1S10-sol

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

This preview shows pages 1–4. 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: 1 1 1 1 1 0 0 0 ; Carry 0 0 0 1 1 1 1 0 ; 30 + 1 1 1 1 1 0 0 1 ; -7 0 0 0 1 0 1 1 1 ; 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 0 0 1 1 1 ldaa #\$1B asla \$36 0 0 0 X ldaa #50 suba #70 -20/236 1 0 1 0 ldaa #-86 suba #108 62 0 0 X 1

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(); } x1 rmb 1 x2 rmb 2 ldaa x1 cmpa x2 bhi else jsr foo ; x1<=x2 so foo bra out else jsr bar ; else bar out 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] (0) (1) psha (2) stx 2,-sp (3) sty 2,sp- (4) leas 2,sp (5) pula (6) pulx (3) SP-> (2)(4) SP-> \$44 \$56 (5) SP-> \$55 \$12 (1) SP-> \$34 (0)(6) SP-> --- Register A will have \$56 X: \$1234
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] \$0702 The opcode for bsr is 07 and The offset here is \$400A - \$4006 – 2 = \$02 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 R \$4005 \$3B \$4006 \$4000 W \$3FFE \$00 \$4006 \$3FFE W \$3FFF \$18 \$4006 \$3FFE c. [8 points] Show the contents of the Stack when the subroutine dump is entered. Also show the value of the Stack Pointer (SP).

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 8

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

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

View Full Document
Ask a homework question - tutors are online