Tuesday, March 29, 2016

Addition and subtraction of numbers



1. Program for addition of two immediate numbers.


;<Addition of two 8-bit immediate numbers>
jmp start
;code
start: mvi a, 05H
mvi b, 04H
add b
hlt
view raw add_basic.asm hosted with ❤ by GitHub

Screen shot after executing the program. See the accumulator content.



2. Program for subtraction of two immediate numbers.


;<8085 program for subtraction of two 8-bit
; immediate numbers>
jmp start
;code
start: mvi a, 05H
mvi b, 04H
sub b
hlt
view raw sub_basic.asm hosted with ❤ by GitHub

Screen shot after executing the program. See the accumulator content.

Screen shot after executing the program. See the accumulator content. The result is in 2's compliment form.
3. Program for addition of two numbers stored at memory locations 6001H and 6002H and storing the result at 6003H.


;<Additon of two 8-bit numbers stored
;at memory location 6001H and 6002H.
;The result will be stored at 6003H >
jmp start
;code
start: lda 6001H
mov b,a
lda 6002H
add b
sta 6003H
hlt
Screen shot after executing the program. see the content of memory locations 6001H, 6002H and 6003H




4. Program for subtraction of two numbers stored at memory locations 6001H and 6002H and storing the result at 6003H.


;<Subtraction of two 8-bit numbers stored
;at memory location 6001H and 6002H.
;The result will be stored at 6003H >
jmp start
;code
start: lda 6001H
mov b,a
lda 6002H
sub b
sta 6003H
hlt
Screen shot after executing the program. see the content of memory locations 6001H, 6002H and 6003H. Content of 6002H is greater than content of 6001H.



Screen shot after executing the program. see the content of memory locations 6001H, 6002H and 6003H. Content of 6002H is smaller than content of 6001H so the result is in 2's compliment form.





No comments:

Post a Comment