- {{
- *********************************
- * Assembly Language Simple *
- * Author: Steven Donald *
- * Date: 4/6/2010 *
- *********************************
- -----------------REVISION HISTORY-----------------
- v1.00 - Original Version
- }}
- CON
- _clkmode = xtal1 + pll16x
- _xinfreq = 5_000_000
- _RX = 31
- _TX = 30
- OBJ
- SPORT : "FullDuplexSerial"
- VAR
- 'Our block of memory for this example
- long TheResult
- long Iamdone
- PUB Start
- TheResult := 10
- Iamdone := -1
- SPORT.start(_RX, _TX, %0000, 19200)
- cognew(@MyAsm,@TheResult)
- SPORT.str(String("Assembly Example"))
- SPORT.tx(13)
- repeat
- while (Iamdone == -1)
- SPORT.str(String(" TheResult: "))
- SPORT.dec(TheResult)
- SPORT.tx(13)
- SPORT.str(String(" Iamdone: "))
- SPORT.dec(Iamdone)
- SPORT.tx(13)
- DAT
- ''__________
- ''Assembly: MyAsm
- ''
- '' 31 0
- '' +--------------------------------+
- '' $0000???? | TheResult |
- '' +--------------------------------+
- '' $0000???? | Iamdone |
- '' +--------------------------------+
- '' Pass the address of two contiguous 32 bit variables in Main Memory.
- '' TheResult - The 32 bit value to increment.
- '' Iamdone - A flag to say when we are done
- ORG 0
- MyAsm mov t1,par 'Grab the passed parameter (address of variable block)
- rdlong Val,t1 'Go to the hub and access main memory (RAM)
- 'Read the value at the first location passed (par)
- 'Changed this from add to sub, to subtract one from the value we read from main memory
- sub Val,#1
- wrlong Val,t1 'Go back to the hub and write the value back to main memory
- mov Val,#0 'Move a zero into Val
- add t1,#4 'Passed address gets incremented by 4 (to point to the next long)
- wrlong Val,t1 'Clear the 'IamDone flag
- cogid id 'get 'this' cogs id
- cogstop id 'use the id to stop the cog
- ' All this below this line is data that is also moved into the COG or reserved by the Propeller Tool
- ' --------------------------------------------------------------------------------------------------
- myblock long $01234567 'Just some data (that we'll use later)
- long $89ABCDEF
- long $AABBCCDD
- long $00112233
- long $44556677
- long $8899AABB
- t1 res 2 't1 is used to hold the pointer to main memory
- Val res 1 'Local variable Val
- id res 1 'id is used to stop the COG
OldAsm
Posted on April 9, 2010, 1:58 am UTC by Steve (about 1 year ago)Code (highlighted for Text)