Question

Convert the following C code to assembler: a) unsigned char A, B, C; if (A >...

Convert the following C code to assembler:

a) unsigned char A, B, C;

if (A > B) C = A;

elseif (A == B) C = 0;

else C = B;

b) unsigned char A, B;

A = 228;

B = A/4;

c) unsigned char A, B;

A = 228;

B = A/5;

Homework Answers

Answer #1

Below is he solution:

A)

main:
push rbp
mov rbp, rsp
movzx eax, BYTE PTR [rbp-1]
cmp al, BYTE PTR [rbp-2]
jbe .L2
movzx eax, BYTE PTR [rbp-1]
mov BYTE PTR [rbp-3], al
jmp .L3
.L2:
movzx eax, BYTE PTR [rbp-1]
cmp al, BYTE PTR [rbp-2]
jne .L4
movzx eax, BYTE PTR [rbp-1]
mov BYTE PTR [rbp-3,0
jmp .L3
.L4:
movzx eax, BYTE PTR [rbp-1]
mov BYTE PTR [rbp-3], al
.L3:
mov eax,0
pop rbp
ret


B)

main:
push rbp
mov rbp, rsp
mov BYTE PTR [rbp-1], -28
movzx eax, BYTE PTR [rbp-1]
shr al,2
mov BYTE PTR [rbp-2],al
mov eax,0
pop rbp
ret

C)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Convert the following pseudo code routine into MIPS assembler language: - Set register $t0 =...
1. Convert the following pseudo code routine into MIPS assembler language: - Set register $t0 = 1 - In four separate instructions add 2, then 3, then 4, then 5 into register $t0 $t0 = $t0 + 2 + 3 + 4 + 5 - Copy the result from register $t0 into register $t1 2. Convert the following into MIPS assembler language: - Set register $t0 = 0 - Initialize the register $t1 = 10 - Use register $t2 as...
Design and code a Verilog module to convert a 4 digit unsigned BCD whole number into...
Design and code a Verilog module to convert a 4 digit unsigned BCD whole number into a 14 bit binary number.
Convert each of the below C code snippet to LEGv8 assembly code. Assume variable a, b,...
Convert each of the below C code snippet to LEGv8 assembly code. Assume variable a, b, and c is stored in registers X19, X20, and X21 respectively. Base address of d is stored in register X22. Comment your assembly code. (24 Points) a. if (a > b) d[a] = b + 8; else d[a] = b - 16; b. for (i=0;i<a; i++) a = d[i] + c; c. i = 0; while ( d[i] == b) if(( a - i...
Convert each of the below C code snippet to LEGv8 assembly code. Assume the variables a,...
Convert each of the below C code snippet to LEGv8 assembly code. Assume the variables a, b, and c are stored in registers X19, X20, and X21 respectively. Base address of d is stored in register X22. Comment your assembly code. a. if (a > b) d[a] = b + 8; else d[a] = b - 16; b. for (i=0;i 0) i++; a = d[i] + c; c. i = 0; while (d[i] == b) if ((a - i) >...
What is wrong with the following code segment, assumming it compiles correctly? char *a = "Hello";...
What is wrong with the following code segment, assumming it compiles correctly? char *a = "Hello"; char *b = " Mom"; while( *b != '\0' ) { *a = *b; a++; b++; }
I am to create three different versions of the following C program code below that implements...
I am to create three different versions of the following C program code below that implements the conversion of unsigned binary numbers into decimal (Base 2 to Base 10 conversion). Version 1: Complete the C program ”bin2dec ver1.c” that implements binary to decimal conversion. The maximum number of binary bits is 32. The program is made of the functions ”unsigned binary to decimal(const char *str)”and ”main”. The parameter ”str” passed to this function points to a C string comprising only...
1. Assuming unsigned binary representation, convert 10110 (B) to decimal. Show work. 2 . Assuming unsigned...
1. Assuming unsigned binary representation, convert 10110 (B) to decimal. Show work. 2 . Assuming unsigned binary representation, convert 12 (D) to binary. Show work. 4. Assuming 9-bit two’s complement representation and let x be binary representation of 94 (D) a. Find x. Show work. b. Show the effect of the ASL operation on x, and then convert the result back to decimal. c. Show the effect of the ASR operation on x, and then convert the result back to...
C CODE PLZ! Need all TO DO sections finished thanks #include <stdio.h> int main(int argc, char...
C CODE PLZ! Need all TO DO sections finished thanks #include <stdio.h> int main(int argc, char **argv) { const int BUF_LEN = 128; char str[BUF_LEN]; int i; char c; int is_binary; int d, n; /* Get the user to enter a string */ printf("Please enter a string made of 0s and 1s, finishing the entry by pressing Enter.\n"); for (i=0; i<BUF_LEN-1; i++) { scanf("%c", &c); if (c == '\n') { break; } str[i] = c; } str[i] = '\0'; /*...
Write one difference for items below a.     char versus Character b.     Source code versus Byte code c.    Complier error...
Write one difference for items below a.     char versus Character b.     Source code versus Byte code c.    Complier error versus Runtime error d.   char [ ] versus String [ ]
C programming question: Write a function char isValid (char c), return a with a char value...
C programming question: Write a function char isValid (char c), return a with a char value of 1 if it is a valid char, and return 0 if it is invalid. (DO NOT USE POINTER!) valid char are '1' '2' 3' '4' '5' 'A' 'B' 'C' for example: lower case is not valid '1' is valid 'A' is valid 'B' is valid 'ABC' is not valid 'D' is not valid '9' is not valid '1234' is not valid For Testing:...