Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a simple C language code using MPLABX IDE that explains an operation then

ID: 3709317 • Letter: W

Question

Write a simple C language code using MPLABX IDE that explains an operation then rewrite the same Code but using assembler code language and explain how the codes work. Write a simple C language code using MPLABX IDE that explains an operation then rewrite the same Code but using assembler code language and explain how the codes work. Write a simple C language code using MPLABX IDE that explains an operation then rewrite the same Code but using assembler code language and explain how the codes work.

Explanation / Answer

Let's find a sample code in C ans Assembly to find sum of two numbers.

CODE IN C

======================

#include<stdlib.h>
#include<stdio.h>

int main() {
int a, b;
printf("ENTER FIRST NUMBER TO ADD : ");
scanf("%d", &a);
  
printf("ENTER SECOND NUMBER TO ADD : ");
scanf("%d", &b);
  
int result = a + b;
printf("RESULT OF ADDITION IS : %d", result);
}

CODE IN ASSEMBLY LANGUAGE

===============================

DATA SEGMENT
NUM1 DB ? ; Stores first number
NUM2 DB ? ; stores second number
RESULT DB ? ; stores the addition
MSG1 DB 10,13,"ENTER FIRST NUMBER TO ADD : $"
MSG2 DB 10,13,"ENTER SECOND NUMBER TO ADD : $"
MSG3 DB 10,13,"RESULT OF ADDITION IS : $"
ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1 ; display the MSG1
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM1,AL ; load the first number
LEA DX,MSG2 ; display the MSG2
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM2,AL ; load the second number
ADD AL,NUM1 ; obtain the result by adding NUM1 to AL(which contains NUM2)
MOV RESULT,AL ; move the result to RESULT
MOV AH,0
AAA
ADD AH,30H
ADD AL,30H
MOV BX,AX
LEA DX,MSG3
MOV AH,9
INT 21H
MOV AH,2
MOV DL,BH
INT 21H
MOV AH,2
MOV DL,BL
INT 21H
MOV AH,4CH
INT 21H
ENDS
END START

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote