Please convert the following to assembly language with comme

Please convert the following to assembly language with comments so I can learn:

Convert the following C code to assembler: unsigned int A, B, C; A = 500; B = 600; C = A + B;

Solution

DATA SEGMENT ;Initialize data sengment
A DW 500H ;Initialize A 500
B DW 600H ;Initialize B 600
RESULT DW ? ;Result
DATA ENDS ;Data segment ends here

CODE SEGMENT ;Code segment starts here
START: ;code will start from here
ASSUME CS:CODE , DS:DATA ;Code and data based on assumption
MOV AX,DATA ;Move data into accumulator x
MOV DS,AX ;Move data from accumulator regsister to data sengment
MOV AX,NUM1 ;Move A into accumulator register
MOV BX,NUM2 ;Move B into accumulator register
ADD AX,BX ;Add whatever is in these two registers
MOV RESULT,AX ;Now move the results from AX to result

MOV AH,4CH ;Code ends here
INT 21H   
CODE ENDS ;code segmnet ends here
END START ;start ends here.

Output: 1100H

Please convert the following to assembly language with comments so I can learn: Convert the following C code to assembler: unsigned int A, B, C; A = 500; B = 60

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site