Shop OBEX P1 Docs P2 Docs Learn Events
Simple Assembly Language Question — Parallax Forums

Simple Assembly Language Question

tom90tom90 Posts: 55
edited 2007-10-11 13:11 in Propeller 1
I am trying to learn assembly language by sending a control byte of 10010000 to an A/D chip.

I send:

mov outa, pin

to set the pin high for the first one.

How do I set the pin low for the next 0?
I know i can use XOR to toggle the output state, but this doesn't seem to be working very well.

in spin I would just say:
outa[noparse][[/noparse]Pin]:=0

Is there an assembly language equivalent to this?

Thanks
Tom

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-09 16:08
    OUTA and DIRA are 32-bit registers. In Spin, you can address single bits or groups of bits in these registers. In assembly, you can only access the whole register. You have to use instructions like OR, XOR, AND, ANDN to change single or multiple bits. Typically, you'd have a constant defined that contains all zero bits except for the bit corresponding to the I/O pin you want. If PIN is a constant whose value is the number of the I/O pin, the constant can be defined as the value |<PIN. This is just a one shifted left PIN bit positions. Here are several examples:
    pinMask    long  |< PIN                ' A 32 bit word of all zeros except for the bit for the I/O pin
    
                    or      dira,pinMask      ' Set I/O pin mode to output
    
                    andn dira,pinMask       ' Set I/O pin mode to input
    
                    or      outa,pinMask      ' Set the I/O pin to high
    
                    andn outa,pinMask      ' Set the I/O pin to low
    
                    xor    outa,pinMask      ' Toggle the I/O pin
    
                    test   pinMask,ina  wc  ' C flag true if I/O pin high
    
    

    Post Edited (Mike Green) : 10/9/2007 4:13:44 PM GMT
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-10-09 16:20
    I also cover this stuff in my 4 step assembly plan:

    http://forums.parallax.com/showthread.php?p=647408

    deSilva has also done an excellent tutorial on assembly that is well worth reading but I don't have the link to hand at the moment.

    Graham
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-09 18:37
    tom90 said...
    I am trying to learn assembly language by sending a control byte of 10010000 to an A/D chip.
    Interesting approach smile.gif
  • BradCBradC Posts: 2,601
    edited 2007-10-09 19:03
    I tried to learn it by standing on my head while flipping the pages of the Propeller reference manual with my toes.. I think his method is probably more effective.
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-09 19:34
    Well, the proof is in the pudding smile.gif
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-10-09 20:55
    @tom90: Most people try to learn assembly by turning an LED on and off. You are ambitious!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
  • tom90tom90 Posts: 55
    edited 2007-10-11 13:11
    Thanks for the help guys! I think i'm starting to get this to work (very slowly).
Sign In or Register to comment.