Program to find the average of 10 numbers


 4: Program to find the average of 10 numbers:

mov dptr,#9000h ;Load 9000h into dptr register
clr a ;Clear a register
mov 0f0h,a ;move data from a to b
mov r1,#05h ;move 05 to r1 register
up: movx a,@dptr ; ;move data from external memory location to a
add a,0f0h ;add a and b
mov 0f0h,a ;move the result to b
dec r1 ;decrement r1
inc dptr ;increment dptr
cjne r1,#00h,up ;compare r1 with 0, if not equal, jump to label up
mov a,0f0h ;move data from b to a
mov 0f0h,#05h ;move 05h to b
div ab ;divide a by b
mov dptr,#09005h ; Load 9005h into dptr register
movx @dptr,a ;move data from a to external memory location
mov a,0f0h ;move data from b to a
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
here:sjmp here
end

Web Statistics