1. Write an alp to perform 8-bit and 16-bit addition, subtraction, multiplication and division
Answers
You are given some denominations of coins in an array (int denom[])and infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called?
Step-by-step explanation:
(a) Addition of 16 bit numbers using 8 bit operation – It is a lengthy method and requires more memory as compared to 16 bit operation.
Algorithm-
Load the lower part of first number in B register
Load the lower part of second number in A (accumulator)
Add both the numbers and store
Load the higher part of first number in B register
Load the higher part of second number in A (accumulator)
Add both the numbers with carry from the lower bytes (if any) and store at the next location
Program –
Explanation –
LDA 2050 stores the value at 2050 in A (accumulator)
MOV B, A stores the value of A into B register
LDA 2052 stores the value at 2052 in A
ADD B add the contents of B and A and store in A
STA 3050 stores the result in memory location 3050
LDA 2051 stores the value at 2051 in A
MOV B, A stores the value of A into B register
LDA 2053 stores the value at 2053 in A
ADC B add the contents of B, A and carry from the lower bit addition and store in A
STA 3051 stores the result in memory location 3051
HLT stops execution
(b) Addition of 16 bit numbers using 16 bit operation – It is a very short method and less memory is also required as compared to 8 bit operation