Give binary and hexadecimal encodings for the following instructions: Problem 4:
ID: 3745834 • Letter: G
Question
Give binary and hexadecimal encodings for the following instructions:
Problem 4: Easy-to-follow Assembly Instructions The conversion of a mnemonic instruction to its binary representation is called assembly. This tedious process is generally delegated to a computer program for a variety of reasons. The first is that it alleviates the need to keep track of all the various bit encodings for each type of instruction. A second reason is that frequently the precise encoding of an instruction cannot be determined in a single pass This is particularly true when referencing labels. In the following exercises, you will get a taste of what the task of translating from assembly to machine language is like. Give binary and hexadecimal encodings for the following instructions: Hex Binary A. B. C. D. E. F. EOR R4, R3, R11 AND R10, R9, R7 ADC R1, R0, #599785472 MOV R9, R10 MVN R3, #6144 ORR R9, R2, #171Explanation / Answer
Manually its very time taking process to covert a assemble language to binary no as well as binary to hexadecimal.
So we first create two program that generally convert any text to binary and binary to hexadecimal respectively
The code for text to binary-
int main(void)
{
char txt[101];
char *bi;
int txtln, biln;
scanf("%100[^ ]s", txt);
txtln = strlen(txt);
biln = txtln * 9; // 8 binary digits + 1 space separator
bi = malloc(biln + 1); // + 1 null terminator
if(bi == NULL)
exit(1);
txtTobi(txt, txtln, bi, biln);
printf(" %s ", bi);
free(bi);
return 0;
}
The code for binary to hex-
void txttobi(char *txt, int txtln, char *bi, int biln)
{
char *hex = malloc(9);
if(hex == NULL)
exit(1);
while(*txt)
{
decitobi(*txt, hex);
while(*hex)
*bi++ = *hex++;
*bi++ = ' ';
++txt;
hex -= 8;
}
*bi = '';
bi -= biln;
printf(" %s ", hex);
free(hex);
}
Our answer is bellow-
EOR R4,R3,R11 01000101 01001111 01010010 00100000 01010010 00110100 00101100 01010010 00110011 00101100 01010010 00110001 00110001 45 AND R10,R9,R7 01000001 01001110 01000100 00100000 01010010 00110001 00110000 00101100 01010010 00111001 00101100 01010010 00110111 41 ADC R1,R0,#599785472 01000001 01000100 01000011 00100000 01010010 00110001 00101100 01010010 00110000 00101100 00100011 00110101 00111001 00111001 00110111 00111000 00110101 00110100 00110111 00110010 41 MOV R9,R10 01001101 01001111 01010110 00100000 01010010 00111001 00101100 01010010 00110001 00110000 4d MVN R3,#6144 01001101 01010110 01001110 00100000 01010010 00110011 00101100 00100011 00110110 00110001 00110100 00110100 4d ORR R9,R2,#171 01001111 01010010 01010010 00100000 01010010 00111001 00101100 01010010 00110010 00101100 00100011 00110001 00110111 00110001 4fRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.