[PDF] 1) Write a program that displays the sum of two numbers Apply the




Loading...







[PDF] 8085 program to add two 8 bit numbers - BDU OMS

Problem – Write an assembly language program to add two 8 bit numbers stored at address 2050 and address 2051 in 8085 microprocessor The starting address of 

[PDF] 1 Write Assembly Language Program to add two numbers (8 bit and

Write Assembly Language Program to divide two numbers (8 bit and 16 bit) 5 Write Assembly Language Program to find out sum of five 16 bit numbers 6 Write 

[PDF] Your turn Change the program so it adds only two numbers

QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 11 BR main sum: WORD 0x0000 num1: BLOCK 2 num2: BLOCK 2

[PDF] Chapter 3 Assembly Language Fundamentals

Know how to formulate assembly language instructions, using valid syntax ADD Add two values SUB Subtract one value from another

[PDF] 8085 program to add two 8 bit numbers

3 oct 2018 · Problem – Write an assembly language program to add two 8 bit numbers stored at address 2050 and address 2051 in 8085 microprocessor

[PDF] To perform addition of two 8 bit numbers using 8085 ALGORITHM

RESULT: Thus the program to add two 8-bit numbers was executed Aim: Write an assembly language program in 8085 microprocessor to generate Fibonacci 

[PDF] Chapter 2 Instructions: Assembly Language - UCSD ECE

In the case of add, this implies only two operands can be added at a time To calculate additions of more than 2 numbers, we would need multiple instructions

[PDF] 1 EXPERIMENT - 1: ADDITION & SUBTRACTION 11 OBJECTIVE

Write an assembly language program to add and subtract the two 16-bit numbers using the program logic given in 1 3 (Use immediate and direct addressing 

[PDF] Another Example of an Assembly Language Program Add the odd

ldx #array ; initialize pointer ldy #0 ; initialize sum to 0 loop: ldab 0,x ; get number brclr 0,x,$01,skip ; skip if even aby ; odd - add to sum

[PDF] 1) Write a program that displays the sum of two numbers Apply the

Apply the Software Development Method? 1- Problem Calculate the sum of two numbers 2- Analysis Problem Input num1, num2 Problem 

[PDF] 1) Write a program that displays the sum of two numbers Apply the 20379_3chapter3_appendix2.pdf

1) Write a program that displays the sum of two numbers. Apply the Software

Development Method?

1- Problem

Calculate the sum of two numbers

2- Analysis

Problem Input num1, num2 Problem Output sum ( sum = num1 + num2)

3- Design / Algorithm

1. Get number 1 2. Get number 2 3. Calculate the sum 4. Display the sum of two numbers

4. Implementation

#include int main(void) { int num1, num2; /* input: the two numbers */ int sum; /* get the two numbers from the user */ printf("Enter Number 1 > "); scanf("%d", &num1); printf("Enter Number 2 > "); scanf("%d", &num2); or or sum = num1+ num2; printf("The sum of two numbers is %d \n",sum); return (0); }

5. Testing 6. Maintenance

num1 (int) num2 (int) sum (int)

7 10 17

printf("%d + %d = %d\n",num1,num2,num1+num2); sum = num1+ num2; printf("%d + %d = %d\n",num1,num2,sum);

Memory: main()

2) Function with 1 Argument

Write a function that displays the sum of two numbers? Note:- we need to declare the function if we write it after the main function #include void display(int sum) { printf("The sum of two numbers is %d\n",sum); } int main(void) { int num1, num2; /* input: the two numbers */ int sum; /* get the two numbers from the user */ printf("Enter Number 1 > "); scanf("%d",&num1); printf("Enter Number 2 > "); scanf("%d",&num2); sum = num1+ num2; /* call the function that print the value of sum */ display(sum); return (0); } #include void display(int sum); /* function declaration */ int main(void) { int num1, num2; /* input: the two numbers */ int sum; /* get the two numbers from the user */ printf("Enter Number 1 > "); scanf("%d", &num1); printf("Enter Number 2 > "); scanf("%d", &num2); sum = num1+ num2; /* call the function that print the value of sum */ display(sum); return (0); } void display(int sum) { printf("The sum of two numbers is %d \n ",sum); } num1 (int) num2 (int) sum (int)

10 20 30

sum (int) 30

Memory: main() Memory: display()

3) Function with Argument & Return Value

Write a function that calculates the sum of two numbers? #include int fun_sum(int num1, int num2) { int sum; or sum = num1 + num2; return (sum); } int main(void) { int num1, num2; /* input: the two numbers */ int sum; /* get the two numbers from the user */ printf("Enter Number 1 > "); scanf("%d", &num1); printf("Enter Number 2 > "); scanf("%d", &num2); /* call the function that calculate the sum of two numbers */ sum = fun_sum(num1,num2); printf("sum = %d\n",sum); return (0); } num1 (int) num2 (int) sum (int)

10 20 30

num1 (int) num2 (int) sum (int)

10 20 30

return(num1+num2);

Memory: main()

Memory: fun_sum()

4) Function with Argument & Return Value

Write two functions. One to calculate the sum of two numbers and the other to display the result (the sum)? #include int fun_sum(int num1, int num2) { or return(num1+num2); } void display_result (int result) {

printf(" %d\n",result);

} int main(void) { int num1, num2; /* input: the two numbers */ int sum; /* get the two numbers from the user */ printf("Enter Number 1 > "); scanf("%d", &num1); printf("Enter Number 2 > "); scanf("%d", &num2); /* call the function that calculate the sum of two numbers */ sum = fun_sum(num1,num2); printf("sum = "); display_result(sum); return (0); } num1 (int) num2 (int) sum (int)

20 30 50

num1 (int) num2 (int)

20 30

sum (int) 50
int sum; sum = num1 + num2; return (sum);

Memory: main() Memory: fun_sum()

Memory: display_result()

5) Function w/o Argument but Return a Value

Write a function that asks the user to enter two numbers then calculate the sum? #include int fun_sum(void) { int num1, num2; /* input: the two numbers */ int sum; /* get the two numbers from the user */ printf("Enter Number 1 > "); scanf("%d", &num1); printf("Enter Number 2 > "); scanf("%d", &num2); or sum = num1 + num2; return (sum); } int main(void) { int sum; /* call the function that gets num1 and num2 then calculate the sum */ sum = fun_sum(); printf("The sum is %d\n",sum); return (0); } num1 (int) num2 (int) sum (int)

40 50 90

sum (int) 90
return (num1 + num2);

Memory: main() Memory: fun_sum()