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
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++; }
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 [ ]
Convert the following code using variables rather than signals. Comment on the differences of a code...
Convert the following code using variables rather than signals. Comment on the differences of a code that uses only signals to a code which makes use of variables. entity converter is port( sign_mag : in std_logic_vector(3 downto 0) ; twos_comp : out std_logic_vector(3 downto 0) ); end converter; architecture converter_arch of converter is signal neg : std_logic_vector(3 downto 0); begin process(sign_mag) begin if (sign_mag <= 1000) then twos_comp<=sign_mag; else neg <=('1' & not sign_mag(2 downto 0))+1; twos_comp<=neg; end if;
would someone kindly convert the following C code to java? thanks so much # include <stdio.h>...
would someone kindly convert the following C code to java? thanks so much # include <stdio.h> int main(void) { int changeOwed; int check; char invisibleChar; int count = 0; int numQ=0, numD=0, numN=0, numP=0; do{ printf("How much change is owed (in cents)?\n"); check = scanf("%d", &changeOwed); // returns 1 if the input is a number and returns 0 otherwise //Get's rid of any extra invisible characters if the input is a char/String do{ scanf("%c",&invisibleChar); }while(invisibleChar != '\n'); }while(check == 0...
3. What will be the value of w after the following section of code executes: int...
3. What will be the value of w after the following section of code executes: int w = 4, q = 3; if (q > 5)       if (w == 7)           w == 3;       else            if (w > 3)               w = 1;            else               w = 0; A.0            B.1              C.2          D.3 4. What will be the value of b after the following section of code executes: int a = 4, b = 0; if (a...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT