Author Topic: assigning multiple outputs in assembler  (Read 2268 times)

0 Members and 1 Guest are viewing this topic.

Offline tiofilo75Topic starter

  • Contributor
  • Posts: 37
assigning multiple outputs in assembler
« on: July 24, 2012, 08:39:18 pm »
Hello everyone, I am a total newb with PIC and I am currently learning on my own with a book and what ever I can read from the net. My question is that I am currently trying to light up multiple LEDs with a 16f887 and when i am making the ports as inputs and outputs i tried to figure out if its possible to assign them in the same line. I tried putting a comma but I got a build fail. I have a feeling that you cant and that i am stuck with assigning each port individually.
 

Offline notsob

  • Frequent Contributor
  • **
  • Posts: 705
  • Country: au
Re: assigning multiple outputs in assembler
« Reply #1 on: July 24, 2012, 09:03:36 pm »
If you are using ASM try PIC tutorials at pcbheaven.com
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 12346
  • Country: us
Re: assigning multiple outputs in assembler
« Reply #2 on: July 24, 2012, 09:07:31 pm »
Usually each line of assembly converts to a single machine instruction, and typically a single machine instruction performs one small and simple function.

If you are using a macro assembler (most assemblers are) then it may be possible to use a pre-defined macro or to write a macro to achieve several steps in one macro instruction.

You may wish to look at the PIC datasheet for reference. It will explain all of the available instructions and what they do.
 

Offline tiofilo75Topic starter

  • Contributor
  • Posts: 37
Re: assigning multiple outputs in assembler
« Reply #3 on: July 24, 2012, 09:12:21 pm »
Thanks for the site, haven't looked at that one yet   :)
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2861
  • Country: au
Re: assigning multiple outputs in assembler
« Reply #4 on: July 24, 2012, 09:19:37 pm »
To set the port directions, you'll typically do something like this:

Code: [Select]
BANKSEL  TRISA       ;select the correct register bank for the TRIS register
MOVLW    b'00000011' ;set the bits (7..0) to be set as input or output (1 = input and 0 = output)
MOVWF    TRISA       ;send that byte to the actual TRIS register
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf