My third Attempt At ASM
Last night I wrote a Spin program to Decode and Send Sony IR Signals.. I got it all working and decided to see if I could write it in PASM.
I'm a novice in ASM period but with a lot of reading and more reading my first program was a simple binary counter to LED's
My second program sent data to a 74hc595 Serial to Parallel Latch.
My Third Program decodes a sony remote and displays Key Value and Device. I was hoping that someone with more experience than me can read over this program and show me some code optimization techniques.
Currently this program works!!
Thanks in Advance for any help,
Eric
I'm a novice in ASM period but with a lot of reading and more reading my first program was a simple binary counter to LED's
My second program sent data to a 74hc595 Serial to Parallel Latch.
My Third Program decodes a sony remote and displays Key Value and Device. I was hoping that someone with more experience than me can read over this program and show me some code optimization techniques.
Currently this program works!!
Thanks in Advance for any help,
Eric
Con
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
Var
Long P
Long O
Obj
Debug : "TV_Text"
Pub Main|Temp,Index
P:=16
Debug.start(12)
CogNew (@Entry,@P)
Repeat
Debug.Out(1)
Debug.Bin(O,20)
Debug.Out(13)
Debug.Str(String("Value="))
Debug.Dec(O & %1111111)
Debug.Str(String(" ",13) )
Debug.Str(String("Device="))
Debug.Dec(O>>7 & %11111)
'WaitCnt (Cnt+1_000_000)
Dat
Entry ORG 0
Mov Temp1, Par
Mov PAddr, Temp1
Add Temp1, #4
Mov OAddr, Temp1
Add Temp1, #4
Mov DAddr, Temp1
RdLong Pin, PAddr
RdLong PinMode,PAddr
mov Pin, #1 wz ' Configure DataPin
shl Pin, PinMode
muxz dira, Pin ' Set Pin as Input
Mov CTRA, #0
Mov CTRA, CntrModeIn ' Logic !A
Movs CTRA, PinMode ' Input Pin Number
Mov Frqa, #1 ' PHSA + 1
Loop
Call #Pulse ' Get Input Pulse From Pin
CMP Duration,PStart WC ' Is pulse a Start Pulse??
IF_AE Call #Start ' If Yes Then Start Reading
JMP #Loop ' If No then Wait for good Start Pulse
Start
Mov Sample,Reset ' Grab 20 Pulses
:Loop
Call #Pulse ' If Pulse is Between Low and High
CMP Duration,PLowBit WC ' Set Bit = #0
IF_AE CMP Duration,PHighBit WC
IF_B or Data,#0
IF_B JMP #:Skip
CMP Duration,PHighBit WC ' If Pulse is Between High and Start
IF_AE CMP Duration,PStart WC ' Set Bit = #1
IF_B or Data,#1
:SKIP
Shl Data,#1 ' Shift Into Data Register
DJNZ Sample,#:Loop ' Repeat until all 20 bits are accumulated
Rev Data,#11 ' Put bits in proper order
WRLong Data,OAddr ' Send to Spin
Start_Ret Ret
PULSE WaitPNE Pin,Pin ' Grab Pulse on Input PIN
Mov PHSA,#0
WaitPEQ Pin,Pin
WaitPNE Pin,Pin
Mov Duration,PHSA 'Accumulate PHSA
PULSE_RET RET
Pin Long 0
PinMode Long 0
PAddr Long 0
OAddr Long 0 'Back to Spin Address
DAddr Long 0
CNTRModeOut Long (%00100 << 26 ) | (%001 << 23) | (0 << 9) 'NCO
FmodeOut Long %1_1111_0010_0001_0010_1101 '38KHZ
CNTRModeIn Long (%10101 << 26 ) | (%010 << 23) | (0 << 9) 'Logic !A
Temp1 Long 0
Duration Long 0
PStart Long 190_000
PLowBit Long 50_000
PHighBit Long 90_000
Sample Long 0
Reset Long 20
Data Long 0

Comments
Thanks,
Eric
PS I'm not sure if you remember instructing me on the SX... Two motor controller... I've decided to move my ASM efforts to the Propeller. Your help back a few months helped a great deal
Looks like you are doing great.
Graham