I am doing a tutorial on Assembly language and dont really understand the full functions of the program. I do not understand how the program work, so I tried to write some comment and search some code from the datasheet what does the code mean.
Question:
1. Can you tell me if my understanding of the code is correct or wrong written in the comment of the code?
2.Can you tell me if each line are correct or wrong?
The code is
http://oi49.tinypic.com/nv7250.jpgAnd the flowachart is
http://oi45.tinypic.com/bx278.jpgorg 0 ;2. force the program to start at init?
init: clrf TRISD ;3.when you are using clrf, this initialize the variable? and make TRISD an output port?
;4.it is a variable or a memory location that we create in the RAM?
;5.A memory location take place in a register?
movlw 0x55 ;6.This move the binary 0101 0101 into the w register?
movwf LATD ; 7.this move the binary 0101 0101 previously stored in w into LATD?
;8.LATD is the register that contain the information for the output LED?
bsf TRISB,0 ;bsf= Bit Set f in the datasheet, this mean it set the TRISB , TRISB=1, the TRIS control the output port of B to be either input or output, so a 1=input?
-9.I dont understand the code put a value of 0x55 into LATD then clrf the LATD
statel: clrf LATD ;10.-I dont understand the code put a value of 0x55 into LATD then clrf the LATD, it is like a kind of test then?
btfsc PORTB,0 ;11.btfsc= Bit Test f, Skip if Clear in the datasheet, so when it is high it keep on going 2 place backward and if the output go low it goes on btsff PORTB,0
; 12.So this line mean btfsc wait for the PORTB input? And what does the number 0 mean?
Bra $-2
btfss PORTB,0 ;btfss=Bit Test f, Skip if Set, this is similar to the btfsc but it wait to be high to skip the function bra?
bra $-2
state2: movlw 0xaa ;13.set the LED on 1010 1010?
movwf LATD ;14.LEDS 7,5,3,1 are on, they are on because the LATD tell them to be on? The LATD is the memory for the LED on or off
btfsc PORTB,0
bra $-2
btfss PORTB,0
bra $-2
bra statel ;15.what does statel mean?
end
-16.TRISB, LATD and state1 are fixed name? Can I change their name?
-17.We can change the labels name but the opcode and operant are fixed.?
-18.the “BIT-ORIENTED FILE REGISTER OPERATIONS” are if else function, input function?
For example btfss and btfsc can be used as if and else
-19. in the code bra-£2. $-2 make the file go 2 place backward, what does the bra mean?