Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What do these mean

Status
Not open for further replies.

Mr.K

New Member
I don't know anything bout assembly can someone tell me what each one of these mean?

1.bsf status,5
movlw B'00011000
movew trisa

2.Movlw 00
movewf trisb
bcf status 5

3.Clrf porta
movf porta,0
movwf portb
end

4. incf counter
andlw 07
movwf control

5.Bcf portb,3
btfss porta, 3
bsf portb, 3
 
if these are the intial conditions can u tell me what has changed being that each line above is independant from the next
delay =2fh
w=55h
status=0fh
control=3fh
trisa=a5
porta=ffh
counter=aah
trisb=00
portb=aah
 
Last edited:
At least three of the lines are wrong, and two of them are written very poorly, using 5 as a bit reference to STATUS rather than the actual bit name - I would need to read the datasheet to find out what it's supposd to do.

A number of the registers in the question aren't even mention in the code samples.

This isn't a homework service, you need to do your own work if you expect to pass the course, read the datasheets and learn.
 
Some explanations:

1.bsf status,5 Set bit 5 in the STATUS register. You will have to find out what bit 5 “is or does”
movlw B'00011000 move the binary number (called a Literal) into the working register (called w) In other words “set bits three and four.”
movew trisa move the value in the tris register (the register that determines if each of the bits on an input/output port will be an input or an output) into the working register (w)

2.Movlw 00 move zero into the working register. In other words clear or zero the working register. This is how the values for a program are created. This instruction means to get a value "out of thin air" and load (put) it into the working register. This is how you create a number. From here you can transfer (put) or (load) the number (called a Literal) into another register (or file).
movewf trisb move (actually COPY) the value in w to the TRIS register (also called FILE)
bcf status 5 clear bit 5 of the STATUS register

3.Clrf porta Clear or ZERO the (input/output) port (PORTA)
movf porta,0 moves the data in port A in and output of port A and also leaves a copy in the w register.
movwf portb move (copy) the contents of w and send it to the in/out port Port B
end tells the assembler that this is the end of the program you have created.

4. incf counter increment a register or file that you have called “COUNTER” You need to put ,0 or ,1 like this: incf counter,0 incf counter,1 to let the assembler know where to put the result. If it is incf counter,0 the result is in COUNTER file and also in W If it is incf counter,1 the result is in COUNTER file but not in W

andlw 07 perform a LOGIC “AND” with the value 7 and the value presently in the w register. Leave the result in w
movwf control Move (copy) the value in w to the register (or file) you have called CONTROL.

5.Bcf portb,3 clear bit 3 of PORT B.
btfss porta, 3 test bit 3 of PORTA and if it is SET (1), skip (move over or jump over) the next instruction in your program. If bit 3 is not SET, go to the next instruction in the program.
bsf portb, 3 SET bit 3 of PORT B.


<snip: spam link deleted>
 
Last edited by a moderator:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top