CS计算机代考程序代写 x86 cache assembly Comp 3350: Computer Organization & Assembly Language

Comp 3350: Computer Organization & Assembly Language
HW # 2: Theme: x86 Organization Basics
All main questions carry equal weight.
(Credit awarded to only those answers with work shown)
1. Name all eight 32-bit general-purpose registers. What is the general function of each of the registers? Which of these registers cannot be addressed in parts?
Ans:
• 32-bit general-purpose registers: EAX, EBX, ECX, EDX, EDI, ESI, EBP, ESP
• General-Purpose
EAX – accumulator
ECX – loop counter
ESI, EDI – index registers
EBP – extended frame pointer (stack) ESP – stack pointer
• All of these registers can be addressed in parts
4 points 6 points
6 points
2. What do the Sign Flag, Zero Flag, Auxiliary Carry Flag, and Parity Flag indicate when they are zero? What do the Overflow Flag and Carry Flag indicate when are zero? How do OF and CF differ?
Ans: 2 points * 6
• The Sign flag (SF) is zero when the result of an arithmetic or logical operation generates a positive result.
• The Zero flag (ZF) is zero when the result of an arithmetic or logical operation generates a nonzero
result.
• The Auxiliary Carry flag (AC) is zero when an arithmetic operation doesn’t cause a carry from bit 3 to
bit 4 in an 8-bit operand.
• The Parity flag (PF) is zero if the least-significant byte in the result contains an odd number of 1 bits. In
general, it is used for error checking when there is a possibility that data might be altered or corrupted.
• The Carry flag (CF) is set when the result of an unsigned arithmetic operation is too large to fit into the
destination.
• The Overflow flag (OF) is set when the result of a signed arithmetic operation is too large or too small
to fit into the destination.
4.5 points
• The difference is the CF is used for unsigned arithmetic operations while the OF is used for signed
arithmetic operations.
3. What do you understand by Cache memory and what are its benefits?
Ans: 8 points * 2
A cache is a high-speed memory that store the most recently used instructions and data. It reduces the amount of time spent reading and writing memory

4. What do you understand by Real-address mode, Protected mode, Multi-segment model? Discuss in detail
Ans: 5.5 points * 3 • Real-address mode:
o Real-address mode is also called 16-bit mode because addresses are constructed from 16-bit values. It implements the programming environment of an early Intel processor with a few extra features
o Only 1 MByte of memory can be addressed, from hexadecimal 00000 to FFFFF. The processor can run only one program at a time, but it can momentarily interrupt that program to process requests (called interrupts) from peripherals. Application programs are permitted to access any memory location, including addresses that are linked directly to system hardware.
• Protected mode
o Protected mode is the native state of the processor, in which all instructions and features are
available. Programs are given separate memory areas named segments, and the processor
prevents programs from referencing memory outside their assigned segments.
o Protected mode is the most robust and powerful, but it does restrict application programs from
directly accessing system hardware.
o The processor can run multiple programs at the same time. It assigns each process (running
program) a total of 4 GByte of memory. Each program can be assigned its own reserved memory area, and programs are prevented from accidentally accessing each other’s code and data. MS-Windows and Linux run in protected mode.
• Multi-segment model
o Each program has a local descriptor table (LDT) that holds descriptor for each segment used
by the program
5. In a 32-bit computer what are the maximum memory amounts that can be addressed in (a) real- addressed mode (b) protected mode?
Ans:
• The maximum memory amounts
(a) Real-addressed mode: 1MB 8 points (b) Protected mode: 4GB 8 points
6. Let us say your computer is running at 1.5 GHz. You come to know that the MOV instruction takes 4 clock periods on your computer. Express the time taken by the instruction in nanoseconds. Ans:
clock cycle duration = 1 / frequency = 1 / 1.5 GHz = 2/3 nanoseconds 8 points the time taken by the Sub instruction = clock cycle duration × #clock
= 2/3 nanoseconds × 4 = 8/3 nanoseconds 8 points