Question: Code has a logic error in the _asm part of the part //B of the code, please fix it! The output I provided shows the
Code has a logic error in the _asm part of the part //B of the code, please fix it! The output I provided shows the error, its around
AH = ? , AL =
#include
#include
int main()
{
char r1, r2;
short int r;
//A. Swap bytes in two general registers BL, BH
_asm
{
MOV BL, 'i'
MOV BH, 'I'
MOV r1, BL;
MOV r2, BH;
MOV r, BX;
}
std::cout
std::cout
//To Display Characters
printf("BH = %c, BL = %c ", r2, r1);
// Display the hexadecimal value of each character
printf("BH = 0x%x, BL=0x%x, BX=0x%x ", r2, r1, r);
// Swap bytes in two general registers BL, BH
_asm
{
XCHG BL, BH;
MOV r1, BL;
MOV r2, BH;
MOV r, BX;
}
std::cout
std::cout
// To display characters
printf("BH =%c, BL =%c ", r2, r1);
// Display the hexadecimal value of each character
printf("BH =0x%x, BL =0x%x, BX =0x%x ", r2, r1, r);
/*****************************************************************/
//B Swap bytes in two general registers AL, AH
_asm
{
MOV AL, 'j'
MOV AH, 'J'
MOV r1, AL;
MOV r2, AH;
MOV r, AX;
}
std::cout
std::cout
// To display characters
printf("AH = %c, AL = %c ", r2, r1);
// Display the hexadecimal value of each character
printf("AH =0x%x, AL =0x%x, AX =0x%x ", r2, r1, r);
// Swap bytes in two general registers AL, AH
_asm
{
XCHG AL, AH;
MOV r1, AL;
MOV r2, AH;
MOV r, AX;
}
std::cout
std::cout
Before swapping BH = 1, BL = i BH =0x49, BL = 0x69, BX After swapping BH = 0x69, BL -0x49 , BX= 0x6949 Before swapping AH -0x4a, AL = 0x6a, AX = 0x4a6 a After swapping IA11 = !, AL RII = 0x21, AL -0x0 AX= 0x2100 Press any key to continue // to displau characters
printf("AH =%c, AL =%c, ", r2, r1);
// Display the hexadecimal value of each character
printf("AH =0x%x, AL =0x%x, AX =0x%x ", r2, r1, r);
system("pause");
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
