Question

In: Electrical Engineering

In assembly 1.What is the effect of the following instructions executing on a modern x86 64-bit...

In assembly

1.What is the effect of the following instructions executing on a modern x86 64-bit system (describe what happens and the final contents of the registers involved)? Can you obtain the same end result using only two instructions, and no other registers?

PUSH RAX

PUSH RBX

PUSH RCX

XOR RAX,RAX

XOR RBX,RBX

XOR RCX,RCX

POP RAX

POP RAX

POP RBX

2. What is the purpose of a segment register in protected mode memory addressing?

3. For a 32-bit Pentium4 descriptor that contains a base address of 01000000H, a limit of 0FFFFH, and G=0, what starting and ending locations are addressed by it? (also see Segmentation and Pagination Diagrams in BlackBoard, Other Reference Materials).

4. If DS=0105H in protected mode, which descriptor entry, table, and RPL are selected? (also see Segmentation and Pagination Diagrams in BlackBoard, Other Reference Materials).

5. What is the purpose of the TLB located within the Pentium class microprocessor?

Solutions

Expert Solution

Sol 1.

Lets analyze the instructions step by step
"PUSH RAX" => it will push or copy the 64 bit contents of AX register to top of stack memory

"PUSH RBX" => it will push the contents of BX register to the new stack top

"PUSH RCX" => it will push the contents of CX register to the new stack top

Now, the stack has the 64 bit values of CX, BX and AX in order from top to bottom.

The XOR function is used here to clear the contents of the registers used. When we XOR a binary number with itself, the result is always 0.

So, the next three instructions will set registers AX, BX and CX to 0.

The "POP" instruction will extract the 64 bit value from top of the stack memory and move it to the following register. After POP instruction, the Stack Pointer will move to the next 64 bit value.

"POP RAX" this instruction will take the contents of top of stack memory (CX) and move it to AX register.

"POP RAX" this will now take the next value from stack (BX) and move it to AX register.

"POP RBX" this will move the next value in stack (AX) and move it to BX register.

Now, the contents of AX register are stored in BX and

the contents of BX register in AX.

Essentially, the program swaps the values of AX and BX registers and clears the value of CX register

This program in assembly can be reduced to two instrcutions :

XCHG RAX,RBX ; exchange 64 bit values of AX and BX registers

XOR RCX,RCX ; clear CX register to 0


Related Solutions

Assembly Language Define a 64-bit constant signed integer in Flash. Then, Write a subroutine count_1s that...
Assembly Language Define a 64-bit constant signed integer in Flash. Then, Write a subroutine count_1s that would count the number of 1s in a byte. The subroutine will receive the input parameter in A and return the result back in A. Use this subroutine to write a program that would count the number of 1s inside the 64-bit constant signed integer. Define a variable that would hold the total count of 1s. (Application of Shift/Rotate instructions) (No specific Architecture)
Hello, I am very new to 64-bit ARM assembly and would like the code to this...
Hello, I am very new to 64-bit ARM assembly and would like the code to this following question: The Fibonacci Sequence is a series of integers. The first two numbers in the sequence are both 1; after that, each number is the sum of the preceding two numbers. 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... For example, 1+1=2, 1+2=3, 2+3=5, 3+5=8, etc. The nth Fibonacci number is the nth number in this sequence, so...
explain why a computer needs to use memory (registers, stacks, heaps) when executing assembly language instructions...
explain why a computer needs to use memory (registers, stacks, heaps) when executing assembly language instructions using the computer's architecture?
What are the pseudo instructions commonly used in the MCS-51 assembly language? What effect does each...
What are the pseudo instructions commonly used in the MCS-51 assembly language? What effect does each directive have? 6. Provided data area from 1000H to 10FFH in external RAM, transfer the data to the area starting at 2500H in external RAM. Please write the program. 11. The crystal oscillator frequency of system is 12MHz. Write the delay subroutine with delay time of 50ms.
Change the following C++ functions to Assembly x86: int problem1_ ( ) { int numberArray [3]...
Change the following C++ functions to Assembly x86: int problem1_ ( ) { int numberArray [3] = {1, -2, 15 }; int result = 0, index = 0; int numElements = 3; while (index < numElements) { if ( index >= 1 && numberArray[index] > 3 ) { result += numberArray[index] ; } else { result -= 3; } index++; } return result; } int problem2_ ( ) { int a, modulo int answer = 0, b = 3; for...
Change the following C++ functions to Assembly x86: int problem1_ ( ) { int numberArray [3]...
Change the following C++ functions to Assembly x86: int problem1_ ( ) { int numberArray [3] = {1, -2, 15 }; int result = 0, index = 0; int numElements = 3; while (index < numElements) { if ( index >= 1 && numberArray[index] > 3 ) { result += numberArray[index] ; } else { result -= 3; } index++; } return result; } int problem2_ ( ) { int a, modulo int answer = 0, b = 3; for...
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
Assume that we are executing the following code on a 32-bit machine using two’s complement arithmetic...
Assume that we are executing the following code on a 32-bit machine using two’s complement arithmetic for signed integers. Which of the following will be printed when the following code is executed (circle those printed, and show work; e.g., how the values are stored): #include <stdio.h> int main() { char x = 0xF;                // x = ________ char y = -1;                 // y = ________ unsigned char z = 0xFF;      // z = 11111111        if (x<z)     printf("performed unsigned compare,...
Translate these two LEGv8 assembly instructions to 32-bit binary machine code. Give your answer in hexadecimal....
Translate these two LEGv8 assembly instructions to 32-bit binary machine code. Give your answer in hexadecimal. CBZ X19, exit ADD X10, X19, X20 exit:
Please use assembly language x86 Visual Studio Write a program to add the following word size...
Please use assembly language x86 Visual Studio Write a program to add the following word size numbers:15F2, 9E89, 8342, 99FF, 7130 using adc instruction and a loop. The result must be in DX, AX. Show the result in debug window.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT