Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Explain the following code line by line using comments. #include stdio.h #include //using std::cout; //using std::endl; char main(void) { char temp; char r1, r2; short

Explain the following code line by line using comments.

#include "stdio.h" #include //using std::cout; //using std::endl; char main(void) { char temp; char r1, r2; short int r; printf(" LAB_No_03_Data_Movement_between General_Purpose_Registers "); // Lab number and lab name here printf(" Module: Embedding and in-line assembly language module into a C program "); printf(" Md Arifuzzaman, ID# 23355869 "); // Student's name here printf(" CET3510-E205 "); // Student's Class here printf(" Submission date: February 6, 2019 "); // Date of the Student's program when submitted here printf(" Due date: February 13, 2019 "); // Date of the Student's program due date printf(" Example 3.1 SwapBytes.cpp "); // Student's file name for the program here printf(" file name: SwapBytes.cpp "); // Student's file name for the program here printf("----------------------------------------- "); _asm { MOV BL, 'a'; MOV BH, 'A'; MOV r1, BL; MOV r2, BH; MOV r, CX; } std::cout << "===================================" << std::endl; std::cout << "Before swapping data" << std::endl; printf("BH = %c, BL= %c, CX = %c%c ", r2, r1, r2, r1); printf("BH = 0x%x, BL = 0x%x, CX = 0x%x ", r2, r1, r); _asm { MOV temp, BH; MOV BH, BL; MOV BL, temp MOV r1, BL; MOV r2, BH; MOV r, CX; } std::cout << "===================================" << std::endl; std::cout << "After swapping data" << std::endl; printf("BH = %c, BL= %c, CX = %c%c ", r2, r1, r2, r1); printf("BH = 0x%x, BL = 0x%x, CX = 0x%x ", r2, r1, r); /******************************************************/ _asm { MOV AL, 'b'; MOV AH, 'B'; MOV r1, AL; MOV r2, AH; MOV r, DX; } std::cout << "===================================" << std::endl; std::cout << "Before swapping data" << std::endl; printf("AH = %c, AL= %c, DX = %c%c ", r2, r1, r2, r1); printf("AH = 0x%x, AL = 0x%x, DX = 0x%x ", r2, r1, r); _asm { MOV AL, 'b'; MOV AH, 'B'; MOV temp, AH; MOV AH, AL; MOV AL, temp; MOV r1, AL; MOV r2, AH; MOV r, DX; } std::cout << "===================================" << std::endl; std::cout << "After swapping data" << std::endl; printf("AH = %c, AL= %c, DX = %c%c ", r2, r1, r2, r1); printf("AH = 0x%x, AL = 0x%x, DX = 0x%x ", r2, r1, r); system("pause"); exit(0); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago

Question

Define capital structure.

Answered: 1 week ago