Reading a Variable in Assembly
Joms
Posts: 279
I am not very good at Assembly and have been trying to figure out the command to read a variable in assembly. Basically what I am trying to do is run Terry Hitt's original video overlay 4 times, each in its own cog. I am attempting to save the object only once, but when I call upon it each time, specifiy the pin numbers used for the video.
This is how the current version works:
This is what I am attempting to do, but every method I try, it does not like. I assume I just have a formatter wrong.
The pin1,pin2,pin3 are variables I declared earlier in the program up in the spin. Is this possible to do? What am I doing wrong?
Thanks in advance...
This is how the current version works:
DAT ORG OverlayAsm MOV _screenAddr,par ' Get address of screen memory MOV _syncPinMask,#1 ' Sync is on pin P0 MOV _videoPinMask,#2 ' Output is on pin P1 MOV _genPinMask,#4 ' Output is on pin P2
This is what I am attempting to do, but every method I try, it does not like. I assume I just have a formatter wrong.
DAT ORG OverlayAsm MOV _screenAddr,par ' Get address of screen memory MOV _syncPinMask,pin1 ' Sync is on pin P0 MOV _videoPinMask,pin2 ' Output is on pin P1 MOV _genPinMask,pin3 ' Output is on pin P2
The pin1,pin2,pin3 are variables I declared earlier in the program up in the spin. Is this possible to do? What am I doing wrong?
Thanks in advance...
Comments
I think I understand that too. Thanks for the explanation so that I know what is going on for next time.
I am going to give this a try...
I have made one channel work by switching the pins to numbers 1,2,8 (P0,P1,P3), to access pins P3,P4,P5, would I just use numbers 8,16,32? Or am I missing something here?
the pins can be accessed in three registers OUTA, INA and PINA. Each bit from 0 to 31 corresponds to one pin. When writing a constant to access one of the pins you can use several notations, binary, hexadecimal or an algebraic expression:
For the 10th PIN it means bit 9 (it starts counting at 0) :
Decimal : 512
Binary %00000000_00000000_00000010_00000000
Hex : $00_00_02_00
Algebraic (it means 1 shifted left to the 10th place or 2^9) : 1<<9
But that is true for every constant.
The powers of 2 are: 1, 2, 4, 8, 16, 32,64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288 and so on , so 8 corresponds to P4 (2^4)
Edit: Always the same the 10th pin is bit 9. What was I thinking again ? sorry
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit some of my articles at Propeller Wiki:
MATH on the propeller propeller.wikispaces.com/MATH
pPropQL: propeller.wikispaces.com/pPropQL
pPropQL020: propeller.wikispaces.com/pPropQL020
OMU for the pPropQL/020 propeller.wikispaces.com/OMU
Post Edited (Ale) : 10/1/2009 5:05:51 PM GMT
Both the pins and the bits start counting at 0 (the first pin is not P1, it is P0) so P10 means bit 10.
With a calculator you can see that 1024 is not $200, it's··$400
This gives:
P0 - bit 0
Decimal: 1
Binary: %00000000_00000000_00000000_00000001
Hex: $00_00_00_01
Algebraic : 1 (no shift at all)
Bitwise decode: |< 0
P1 - bit 1
Decimal: 2
Binary: %00000000_00000000_00000000_00000010
Hex: $00_00_00_02
Algebraic : 1 << 1 (shift one to the left)
Bitwise decode: |< 1
P2 - bit 2
Decimal: 4
Binary: %00000000_00000000_00000000_00000100
Hex: $00_00_00_04
Algebraic : 1 << 2
Bitwise decode: |< 1
P3 - bit 3
Decimal: 8
Binary: %00000000_00000000_00000000_00001000
Hex: $00_00_00_08
Algebraic : 1 << 3
Bitwise decode: |< 3
P4 - bit 4
Decimal: 16
Binary: %00000000_00000000_00000000_00010000
Hex: $00_00_00_10
Algebraic : 1 << 4
Bitwise decode: |< 4
P5 - bit 5
Decimal: 32
Binary: %00000000_00000000_00000000_00100000
Hex: $00_00_00_20
Algebraic : 1 << 5
Bitwise decode: |< 5
P6 - bit 6
Decimal: 64
Binary: %00000000_00000000_00000000_01000000
Hex: $00_00_00_40
Algebraic : 1 << 6
Bitwise decode: |< 6
P7 - bit 7
Decimal: 128
Binary: %00000000_00000000_00000000_10000000
Hex: $00_00_00_80
Algebraic : 1 << 7
Bitwise decode: |< 7
P8 - bit 8
Decimal: 256
Binary: %00000000_00000000_00000001_00000000
Hex: $00_00_01_00
Algebraic : 1 << 8
Bitwise decode: |< 8
P9 - bit 9
Decimal: 512
Binary: %00000000_00000000_00000010_00000000
Hex: $00_00_02_00
Algebraic : 1 << 9
Bitwise decode: |< 9
P10 - bit 10
Decimal: 1024
Binary: %00000000_00000000_00000100_00000000
Hex: $00_00_04_00
Algebraic : 1 << 10
Bitwise decode: |< 10
and so on
Post Edited (nohab) : 10/1/2009 9:50:09 AM GMT
If that is true, then I must have something else wrong. I am attempting to get the video overlay object to run 4 times, each time using the next 3 consecutive pins.
Video overlay 1 - P0,P1,P2 (1,2,4)
Video overlay 2 - P3,P4,P5 (8,16,32)
Video overlay 3 - P6,P7,P8 (64,128,256)
Video overlay 4 - P9,P10,P11 (512,1024,2048)
I have also tried subtracting one from each of those numbers, (0,1,3,7,15...etc). I have also tried just using overlay 1 on pins 3,4,5 and had no luck. Because of this, I am thinking that I have a pin number problem and not a variable address problem...Does that sound right?
Can someone look at my program I have attached and see if I am making an obviouse mistake?
I don't see an obvious problem with your attached program. I've only looked at it cursorily, particularly at the changes you made in the overlay module. You won't be able to get it to run with 4 overlays because you need two cogs for the main program and the serial I/O routine, one cog for the heartbeat, and one for the timer. That's 4. Each overlay will need one or two cogs. That should work for up to 3 overlays as long as you don't try to draw lines in two or more overlays at a time.
Post Edited (Mike Green) : 10/1/2009 5:03:47 PM GMT
Even with the second new video overlays disable (commented out), i can not make the second one function. When I move my wires from P0,P1,P2 to P3,P4,P5 I can see that the video gets a little darker which shows me it is working, just no test displayed.
I must have a variable wrong somewhere, or a variable address which is preventing me from storing or displaying any overlay for the second channel.
---EDIT---
I did actually get it to work up to the three channels like Mike said would work.· I am not going to argue with you Mike, but could you explain why I need the LineTo routine if i am not drawing?· For simple text I don't see why I need more then one cog...· Am I wrong on that?
Thanks for clarifying, I am just trying to actually get a full grasp on this...
Post Edited (Joms) : 10/1/2009 6:28:08 PM GMT