Search This Blog

Friday, August 5, 2011

In a semester student has to take 4 courses. The marks of student out off say 30 are stored in RAM location 30h. Find average marks and output it in port1.




MOV R1, #04 ; R1 NUMBER OF COURSES FOR COUNTING
MOV B, #O4 ; B AGAIN NUMBER OF COURSES FOR DIVISION
MOV R0, #30H ; RAM STARTING ADDRESS
MOV A, #0 ;
LOOP: ADD A, @R0 ; WHERE @R0 REFERS TO DATA AT LOCATION 30H
INC R0 ;
DJNZ R1, LOOP ; REPEAT ADDITION UNTIL R1 = 0
DIV AB ; CAUSE ONLY DIVISION OPERATION AVAILABLE
MOV P1, A ; IGNORE REMAINDER AND OUTPUT PORT 1 THE AVERAGE

END ; END OF PROGRAM


2 comments: