Ex 4 Report Embedded (2140245)
Ex 4 Report Embedded (2140245)
Ministry of Education
KINGABDULAZIZUNIVERSITY
Faculty of Engineering at Rabigh
Electrical Engineering Department
قسم الهندسة
الكهربائية
Number : 4
Course Code EEN 415
ID No: 2140245
Objective:
1- To study the meaning and function of the assembler codes BNZ , DECF, INCF , EQU
,LOOPING , in addition to previous codes
2- To deals with microcontroller flags
Procedure:
1. Initialize registers and constants.
2. Set microcontroller flags for loop conditions.
3. Use assembler instructions for control flow.
4. Implement and execute loops with flag manipulation.
5. Run and verify correct loop execution and flag behavior.
Test Plan:
1- Verify WREG is cleared at the start:
Ensure the code begins by clearing WREG with MOVLW 0x00, and confirm this through
simulation.
2
Source Code:
processor 18F458
include <p18F458.inc>
org 0x000
COUNT EQU 0x25
MOVLW D'10'
MOVWF COUNT
MOVLW d'0'
MOVWF TRISB
AGAIN ADDLW 3
DECF COUNT, F ; Decrement COUNT
BNZ AGAIN ; Loop until COUNT is zero
MOVWF PORTB; Store result in PORTB
END
3
Screen shots:
4
5
Conclusion:
The experiment demonstrated the use of assembler codes such as BNZ, DECF, INCF, EQU,
and LOOP, along with microcontroller flags, successfully controlling loops. The counter
operated from 0 to 70 in the inner loop and 0 to 10 in the outer loop, achieving the intended
functionality.