sábado, 3 de febrero de 2018





Convert the following C code to ASM for the ARM Cortex M4
-------------------------------------


void main ()
{
if (R1 ==R2)
  {
  R3 = R4 - R5;
  }
else if (R1>R2)
  {
  R3 =R4 + R5;
}
}



__main
  MOV r1,#2
  MOV r2,#1
  MOV r3,#1
  MOV r4,#1
  MOV r5,#1
COM
  CMP R1, R2    ;R1-R2 and set the flag
  SUBEQ R3, R4, R5  ; SUB if R1 = R2 it means that Z flag is 1
  ADDGT R3, R4, R5  ; ADD if R1 > R2 it means that C flag is 1
  B COM  ;JUMP to COM address

  END








No hay comentarios.:

Publicar un comentario

BTFSS INSTRUCTION  IN ASSEMBLER FOR PIC18F In this sample, we show that how to use a switch input to make an action. Remember that I...