• 沒有找到結果。

Midterm Exam

N/A
N/A
Protected

Academic year: 2022

Share "Midterm Exam"

Copied!
2
0
0

加載中.... (立即查看全文)

全文

(1)

922 25300 Computer Organization and Assembly Languages National Taiwan University

Fall 2005 Department of CSIE

Midterm Exam

November 10, 2005

Signed integers are represented using two’s complement representation. Real numbers are represented usign IEEE Standard 754 format.

For the questions that we ask you to write a program, you can assume that you are given a template program as in page 76 of the textbook and only need to fill in the essential part.

Please use the following notations for logic gates. Feel free to change the orientations of the gates and the positions of inputs and outputs. You are free to use other circuits. However, if they are not introduced in the class, you have to implement them before using them.

NOT gate AND gate OR gate NAND gate XOR gate

4-bit full adder

X Y

4 4

4

S COUT CIN

4-bit comparator

X Y

4 4

X>Y X=Y X<Y

X>Y X=Y X<Y

4-bit 2-MUX

X Y

4 4

4

Z S

4-bit full adder 4-bit comparator 4-bit 2-multiplexer

1. (10%) Answer the following questions:

(a) Is A5h a valid hexadecimal constant?

(b) In real-address mode, convert the following segment-offset address to a linear address: 0CD1:02E0.

(c) Declare an uninitialized array of 50 unsigned doublewords name dArrary.

(d) Write a constant expression that divides 10 by 3 and returns the integer remainder.

(e) The CALL instruction pushed the offset of the CALL instruction on the stack.

2. (6%) What is the 8-bit binary and hexadecimal representations of the following signed decimal integers?

a. -8 b. -47

3. (6%) (a) What is -4.6E+15 in hexadecimal? (b) What does 420F0000 represent when interpreted as a real number?

4. (8%) (a) What is the truth table for the Boolean function XOR? (b) Implement XOR function with only logic gates AND, OR and NOT. (c) Use only NAND gates to implement XOR function.

5. (5%) Given a 8-bit register R7R6· · · R0, what are the boolean expressions for the Sign, Zero and Parity flags as defined in IA-32.

1

(2)

6. (10%) Convert the following assembly code into machine code as we did in the class. Draw the memory layout and the content after the program is loaded. Write down contents of the registers PC, IR, ACC, B and FLAG(NGEL) after executing each instruction.

.DATA CTR 004 TWO 002 .CODE

LDA CTR

L1 SUB TWO

JN END JMP L1 END HLT

7. (10%) Assume that the address of arrayA is 0, what is the content of the memory? Specify it as a byte string and represent each byte in hexadecimal. What is the value of size?

arrayA BYTE 10h, 20h, 30h, 40h

arrayB WORD 1234h, 5678h

size = ($ - arrayA)

stringA BYTE "Asm"

8. (5%) What is the result for the following example?

MOV EAX, 0 MOV ECX, 10 L1: MOV EAX, 3

MOV ECX, 5 L2: ADD EAX, 5

LOOP L2 LOOP L1

9. (15%) Write an MASM program to calculate and print the first seven values in the Fibonacci number sequence. The Fibonacci sequence F (i) is defined as F (1) = 1, F (2) = 1, F (n) = F (n − 1) + F (n − 2) for n ≥ 3. Your program should print a number per line.

10. (15%) Write a complete MASM procedure to convert the given string into a palindrome. A palindrome is a string which has the property of reading the same in either direction, for example, abccba. The input string is given at ESI and the length of characters of the string is specified by ECX. The output should be placed at the same array as the input. Note that your procedure should avoid possible side effects.

11. (10%) Design a binary multiplier that multiplies two 4-bit numbers.

2

參考文獻

相關文件

• Suppose the input graph contains at least one tour of the cities with a total distance at most B. – Then there is a computation path for

So we check derivative of f and g, the small one would correspond to graph (b) and the other to (c)(i.e.. Moreover, f is

May not be scanned, copied, or duplicated, or posted to a publicly accessible website, in whole or in part.. All

(18%) Determine whether the given series converges or diverges... For what values of x does the series

Choose the one alternative that best completes the statement or answers the question.?. 1) Which of the following is an illustration of the law of

Water is added to the flask and the total volume in the flask is read to be 126.4 ml.. One of the isotopes has an atomic weight of 62.9 amu and constitutes 69.1% of the copper

Let p be the probability that a healthy person gets the disease, r be the probability that an infected person recovers in each month.. Suppose there are 8

(Why do we usually condemn the person who produces a sexually explicit material to make money but not a person who does the same thing in the name of art?). • Do pornographic