Question

Convert the following C code to PIC24 assembly instructions: uint16 j, k, p, q; if (...

Convert the following C code to PIC24 assembly instructions:

uint16 j, k, p, q;

if ( (j < p) && (k >= p) ) {

q = q + 4;

}

else {

q = q + 8;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C program to Assembly Code Conversion

C CODE: test.c

#include<stdio.h>

#include<inttypes.h>

main()

{

uint16_t j,k,p,q;

if((j<p)&&(k>=q))

{

q=q+4;

}

else

{

q=q+8;

}

}

ASSEMBLY CODE:

  .file "test.c"

  .text

  .globl main

  .type main,@function

main:

.LFB0:

  .cfi_startproc

  pushq %rbp

  .cfi_def_cfa_offset 16

  .cfi_offset 6,-16

  movq %rsp,%rbp

  .cfi_def_cfa_register 6

  movzwl -2(%rbp), %eax

  cmpw -4(%rbp), %ax

  jnb .L2

  movzwl -6(%rbp), %eax

  cmpw -8(%rbp), %ax

  jb .L2

  addw $4, -8(%rbp)

  jmp .L4

.L2:

  addw $8,-8(%rbp)

.L4:

  popq %rbp

  .cfi_def_cfa 7, 8

  ret

  .cfi_endproc

.LFE0:

.size main, .-main

.ident "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-11)"

.section .note.GNU-stack,"",@progbits

Add a comment
Know the answer?
Add Answer to:
Convert the following C code to PIC24 assembly instructions: uint16 j, k, p, q; if (...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT