/Users/farid11/Downloads/Simple_Register_Reading/simple_counter2.asm
 1 ;---------------------
 2 ; Title: Program_name
 3 ;---------------------
 4 
 5 ;Program Detail:
 6 ;---------------------
 7 ; Purpose: What does it do?
 8 ; Inputs: What are the inputs to the program?
 9 ; Outputs: What are the output of the Program?
10 ; Date: date and time
11 ; Compiler: Simulator Version ????
12 ; Author: name of the author
13 ; Versions:
14 ;           V1 - What is the version numer and what is the change for each version?
15 ;           V2 - What is the version numer and what is the change for each version?
16 
17 ;---------------------
18 ; File Dependencies: these are the listing and header files you need to run the
19 ;   program
20 ;---------------------
21 List P=18F452 f=inhx32
22 #include <p18F452.inc>
23 
24 ;---------------------
25 ; Initialization
26 ;---------------------
27 
28 ; Program Inputs
29 INPUT1  EQU 0x12        ;The value of INPUT1
30 INPUT2  EQU 0x02        ;The value of INPUT2
31 
32 ; Program Constants
33 INPUT1_REG  EQU 0X20        ;The register where INPUT1 is stored
34 INPUT2_REG  EQU 0X20        ;The register where INPUT2 is stored
35 RESULT      EQU 0x30        ;The register where RESULT is stored
36 
37 ;---------------------
38 ; Main Program
39 ;---------------------
40 
41     ORG 0X20                ;Start program listing from Reg. 0x20 in the memory
42 BEGIN2
43     CLRF    RESULT          ;Make sure the RESULT is cleared
44 
45     MOVLW   INPUT1          ;Move INPUT values in the right register
46     MOVWF   INPUT1_REG      ;Not really doing anything useful!
47 
48     MOVLW   INPUT2
49     MOVWF   INPUT2_REG
50 
51     MOVLW   INPUT1          ;Add INPUT1+INPUT2->RESULT
52     MOVWF   RESULT
53     MOVLW   INPUT2
54     ADDWF   RESULT,F
55 
56     BNZ     FINISH          ;If the result is NOT zero goto finish!
57     CLRF    INPUT1_REG      ;Else, clear INPUT registers
58     CLRF    INPUT2_REG
59 
60 FINISH
61     GOTO    FINISH          ; Stop here!
62 
63     END                     ; End of the program
64 
65 
66 
67