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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s