Coroutines in Propeller Assembly Language

Similar documents
Workrite Sierra HX & HXL Assembly Instructions for 3-leg Electric Workcenters

HCI Examination Please answer in Swedish or English

Right Triangle Trigonometry

Connectors according to DIN / IEC

Contents TRIGONOMETRIC METHODS PROBABILITY DISTRIBUTIONS

10mm SHOWER PANEL SIZES 1000 & 1200 SIZES 500, 600, 700, 800 & 900 SIZES 1000 & 1200 OPTION 1 - PAGES 2-4 OPTION 2 - PAGES 2-5 OPTION 3 - PAGES 6-7

In any right-angle triangle the side opposite to the right angle is called the Label the Hypotenuse in each diagram above.

1 Measurement. What you will learn. World s largest cylindrical aquarium. Australian Curriculum Measurement and Geometry Using units of measurement

Apply the Pythagorean Theorem

St Ac Ex Sp TOPICS (Text and Practice Books) 4.1 Triangles and Squares Pythagoras' Theorem - -

Lesson 2 PRACTICE PROBLEMS Using Trigonometry in Any Triangle

Geometry. Trigonometry of Right Triangles. Slide 2 / 240. Slide 1 / 240. Slide 4 / 240. Slide 3 / 240. Slide 6 / 240.

Robot Control User Manual /0718-V01

Incremental Dependency Parsing

Apply the Law of Sines. You solved right triangles. You will solve triangles that have no right angle.

7.2 Assess Your Understanding

Chapter 5. Triangles and Vectors

Plant Growth Regulators in Spring Wheat. Anne Kirk, Craig Linde, and Pam de Rocquigny. Manitoba Agriculture

400 Series Flat Panel Monitor Arm Rotate Mount Double Pivot P/L

Hook-up Checklist for the Ranger PM7000 (EU)

McAfee Change Control and Application Control Installation Guide For use with epolicy Orchestrator and 4.6.0

6 TRIGONOMETRY TASK 6.1 TASK 6.2. hypotenuse. opposite. adjacent. opposite. hypotenuse 34. adjacent. opposite. a f

Strengthening Farming

BIRD PREDATION MANAGEMENT PLAN BLUEBERRIES

The Pythagorean Theorem and Its Converse Is That Right?

1. Attach beams to different parts of the playset.

Fino Installation Instructions

Data Compression. Reduce the size of data. Reduces time to retrieve and transmit data. Compression ratio = original data size/compressed data size

MATHEMATICAL PRACTICES In the Solve It, you used what you know about triangles to find missing lengths. Key Concept Law of Sines

INSTALLATION INSTRUCTIONS AND USER MANUAL FOR SLOAN EAF GOOSENECK SERIES FAUCETS

Hybrid Relief Valves

CC24-7 ELITE. Temperature Controller USER S MANUAL Legion Dr. Mason, MI USA April 2011 Ph. (517) Fax (517)

Instructions for Continued Airworthiness

AT200 INSTALLATION MANUAL

RoboGolf (aka RoboPutting) Robofest 2016 Game

XX COMMONWEALTH GAMES

First Aid in School Policy

Flow Divider / Combiner Cartridge Valves

TOOLBANK USA, INC Form 990 (2014) Page 2

Listening & Speaking. Grade 1. Supports. instructi GRADE. Develops oral and receptive language. 15- to 20-minute daily activities

INVESTIGATION 2. What s the Angle?

8.1 Right Triangle Trigonometry; Applications

Recall that the area of a triangle can be found using the sine of one of the angles.

Bicycle wheel and swivel chair

9444LQ 702V V PAGE 3

ATTEND (Analytical Tools To Evaluate Negotiation Difficulty)

McAfee Application Control 6.1.0

Lesson 12.1 Right Triangle Trigonometry

Announcements. CS 188: Artificial Intelligence Spring Today. P4: Ghostbusters. Exact Inference in DBNs. Dynamic Bayes Nets (DBNs)

Efficacy of Selected Insecticides Against Phormium Mealybugs on New. Zealand Flax, Phormium tenax.

TAX RETURN FILING INSTRUCTIONS

SAMPLE EVALUATION ONLY

5.5 The Law of Sines

MTH 112: Elementary Functions

I Information about Form 990 and its instructions is at Inspection

Data Compression. Reduces storage space and hence storage cost. Compression ratio = original data size /

Starter. The Cosine Rule. What the Cosine Rule is and how to apply it to triangles. I can write down the Cosine Rule from memory.

ARIAKON OWNER S MANUAL READ AND UNDERSTAND ALL INSTRUCTIONS AND WARNINGS IN THIS MANUAL BEFORE USING THIS PAINTBALL MARKER.

A Measurement Framework for National Key Performance Measures

Chapter 31 Pythagoras theorem and trigonometry (2)

I Information about Form 990 and its instructions is at Inspection

UNIVERSITY OF MISSISSIPPI RESEARCH FOUNDATION FORM 990 TAX YEAR 2014

I Information about Form 990 and its instructions is at Inspection

. Top/Bottom Assembly - 2 Tilt Stand - 1

I Information about Form 990 and its instructions is at Inspection

LEHIGH VALLEY LEHIGH VALLEY CONNIE MACK BASEBALL

Ruth Foster, M.Ed. Author

I Information about Form 990 and its instructions is at Inspection

I Information about Form 990 and its instructions is at Inspection

HD CONDUIT MIN. 10% FALL CHAMBER MONITORING SYSTEM HD CONDUIT REFER NOTE 13 SECTION C-C DETAILS OF BENCHING

Return of Organization Exempt From Income Tax. Under section 501(c), 527, or 4947(a)(1) of the Internal Revenue Code (except private foundations)

Public Inspection Copy Return of Organization Exempt From Income Tax

Return of Organization Exempt From Income Tax

I Information about Form 990 and its instructions is at Inspection

CS 188: Artificial Intelligence Spring Announcements

Return of Organization Exempt From Income Tax

Grade 6. Mathematics. Student Booklet SPRING 2011 RELEASED ASSESSMENT QUESTIONS. Record your answers on the Multiple-Choice Answer Sheet.

VENTS SERIES DOMESTIC ELECTRIC FANS. User s Manual

Return of Organization Exempt From Income Tax. Under section 501(c), 527, or 4947(a)(1) of the Internal Revenue Code (except private foundations)

Data Compression. Lossless And Lossy Compression. Text Compression. Lossless And Lossy Compression. Lossless compression is essential.

Hot-Air Blowers 12 / / Hot-Air Blowers

I Information about Form 990 and its instructions is at Inspection

TeeJay Publishers Homework for Level C book Ch 11 - Position/Movement. Bill. Bob. Dan. Joy

I Information about Form 990 and its instructions is at Inspection

Congruence Axioms. Data Required for Solving Oblique Triangles. 1 of 8 8/6/ THE LAW OF SINES

RULES OF INDOOR HOCKEY

Name Class Date SAMPLE. Complete the missing numbers in the sequences below. 753, ,982. The area of the shape is approximately cm 2

PUBLIC DISCLOSURE COPY. Return of Organization Exempt From Income Tax

I Information about Form 990 and its instructions is at Inspection

APPNA SPRING MEETING CHICAGO, ILLINOIS RETAIL BAZAAR REGISTRATION MARRIOTT DOWNTOWN MAGNIFICENT MILE 540 NORTH MICHIGAN AVENUE

Rules of Indoor Hockey including explanations. Effective from 1 January 2011

Aquadue Duplo Page 1

Linking Your Accounts

pge 2 Owner's Mnul for Thern 4WS nd 4HS Series Power Winhes Two-Yer Limited Wrrnty Plese reord the following: Dte Purhsed: Model No.: Seril No.: This

IGF Research Project N Safer High Heels

ENCLOSED ARE THE ORIGINAL AND ONE COPY OF YOUR INCOME TAX RETURNS FOR THE PERIOD ENDED DECEMBER 31, 2015 FOR:

CS 253: Algorithms. LZW Data Compression

So Chic Dollhouse. Assembly Instructions Item #65078

6E Introducing rates 6F Ratios and rates and the unitary method 6G Solving rate problems (Extending) 6H Speed (Extending)

RULES OF INDOOR HOCKEY. from 1 May

Transcription:

www.prllxsemiondutor.om sles@prllxsemiondutor.om support@prllxsemiondutor.om phone: 916 632 4664 fx:916 624 8003 pplition Note oroutines in Propeller ssemly Lnguge strt: The multiore P8X32 does not require trditionl interrupts to mnge multiple proesses simultneously; yet multi-tsking in single ore is still hndy option. oroutines in Propeller ssemly lnguge n support pir of independent tsks in single ore (og) through the use of the JMPRET instrution. Introdution The P8X32 Propeller hs eight independent proessors, lled ogs, eh of whih n support multiple oopertive tsks. The simplest wy to implement multitsking in Propeller ssemly lnguge (PSM) for two tsks is to write the tsks s oroutines. oroutine Priniple Two progrms re sid to e oroutines when they tke turns exeuting in suh wy tht, when eh gets its turn, it resumes from the point where it left off. In the Propeller, oroutines tke turns oopertively, rther thn y mens of n interrupt, so eh must yield its turn to the other in plnned ping-pong fshion. Figure 1 illustrtes the priniple s flow hrt. Figure 1: oroutines Flowhrt Strt Flow of ontrol Result oroutine 1 oroutine 2... oroutines in Propeller ssemly Lnguge v1.0 1 of 5

Prllx Semiondutor Here, exeution ounes k nd forth etween oroutine 1 nd oroutine 2 in suh wy tht eh gets smll slie of time efore yielding to its omplement. The result is n interleved exeution tht n give the pperne tht eh is operting independently in rel time. oroutines re often employed in progrms tht do oth input nd output independently, suh s those tht perform full-duplex synhronous seril I/O, or tht monitor n enoder nd ontrol motor. Propeller oroutine Implementtion To understnd how oroutines work in the Propeller, it is neessry to hve feel for the Propeller s exeution sequene. Propeller instrutions re proessed in four steps: 1. Instrution feth 2. Write result of previous instrution 3. Soure opernd feth 4. estintion opernd feth This mens tht if the next instrution is the destintion of the urrent instrution s result, the old ontents of tht instrution slot will e red first efore the new vlue is written. Suh ehvior is wht mkes Propeller oroutine swithing oth simple nd fst. onsider the jmpret d,s instrution. This instrution trnsfers ontrol to ddress s nd stuffs the ddress of the instrution following the jmpret into the soure field of the instrution t ddress d. The ltter ddress most ommonly holds jmp instrution, so tht jmpret n e used to effet suroutine lls. In ft, the ll instrution is just jmpret in disguise. For exmple, this: '-------[ Min Progrm ]----------------------------------------- jmpret sur_ret,#sur 'll sur. '-------[ Suroutine ]------------------------------------------- sur 'Suroutine entry point. sur_ret jmp #0-0 'Return to ller. is extly equivlent to this: '-------[ Min Progrm ]----------------------------------------- ll #sur 'll sur. '-------[ Suroutine ]------------------------------------------- sur 'Suroutine entry point. sur_ret ret 'Return to ller. oroutines in Propeller ssemly Lnguge v1.0 2 of 5

Prllx Semiondutor Now, onsider wht would hppen in the sitution elow, where the trget of the ll nd the return sttement reside t the sme lotion. ll :nxt #swp swp swp_ret ret In this exmple, the following steps tke ple t the ll: 1. The proessor reds the instrution t swp (i.e. ret = jmp #ret_ddr). 2. The proessor stuffs the ddress of :nxt into the soure field of swp, repling ret_ddr. 3. The jmp #ret_ddr instrution exeutes. The next time ll issues to swp, exeution will trnsfer to :nxt, nd the ller s return ddress will get stuffed into swp s soure field. nd so it goes, k-nd-forth. This then is the essene of Propeller oroutine swithing. Progrm Exmple In this exmple progrm, two oroutines ontrol two seprte LEs, linking them t different rtes. (This progrm is designed to run on the Propeller emo ord [1] ut n e modified for other pltforms simply y hnging vlues in the ON setion s pproprite.) ON 'Spin setup ode _lkmode _xinfreq = xtl1 + pll16x = 5_000_000 PING_LE = 16 PONG_LE = 17 PU Strt ping_period := lkfreq * 11 / 16 pong_period := lkfreq * 13 / 16 'Set periods for oth LEs. ognew(@pingpong, 0) T 'PSM ode pingpong or dir,ping_msk 'Enle PING_LE output. or dir,pong_msk 'Enle PING_LE output. mov ping_time,nt 'Initilize timers. mov pong_time,ping_time '-------[ ping oroutine ]------------------------------------------------------- ping ll #swp 'Give the pong oroutine hne. 'Pong oroutine returns here. mov,nt 'Is it time to hnge stte? su,ping_time mp,ping_period w if_ jmp #ping ' No: Keep heking. dd ping_time,ping_period ' Yes: dd to get the next time. or out,ping_msk ' Turn LE on. oroutines in Propeller ssemly Lnguge v1.0 3 of 5

Prllx Semiondutor ping_on ll #swp 'Give the pong oroutine hne. 'Pong oroutine returns here. mov,nt 'Is it time gin to hnge stte? su,ping_time mp,ping_period w if_ jmp #ping_on dd ping_time,ping_period ' Yes: dd to get the next time. ndn out,ping_msk ' Turn LE off. jmp #ping 'Loop k '-------[ pong oroutine ]------------------------------------------------------- pong mov,nt 'Is it time to hnge stte? su,pong_time mp,pong_period w if_n dd pong_time,pong_period ' Yes: dd to get next time. if_n xor out,pong_msk ' Invert output pin. ll #swp 'Give the ping oroutine hne. jmp #pong 'Loop k '-------[ oroutine swpper ]----------------------------------------------------- swp swp_ret jmp #pong 'Initilize swp to point to pong. '-------[ vriles ]------------------------------------------------------------- ping_msk long 1 << PING_LE pong_msk long 1 << PONG_LE ping_period long 0-0 pong_period long 0-0 ping_time res 1 pong_time res 1 res 1 In this progrm, ping nd pong do the sme things with their respetive LEs. However, ping expliitly turns its LE on nd off, while pong simply toggles its LE. The ping oroutine, with two distint lls to swp, illustrtes tht exeution piks up from where it left off when the other oroutine returns. Here re ouple other points worth noting: 1. oth ping nd pong use the shred vrile. This is oky, so long s the vlue of shred vrile does not hve to spn ll to swp, euse the omplementry oroutine might loer it. 2. Never rely upon the sttes of the nd z flgs ross lls to swp. Without extremely reful progrmming, the omplementry oroutine will lmost ertinly loer them. If it should e neessry to retin the zero nd/or rry flg stte(s) ross ll to swp, use the flg sve nd restore instrutions illustrted elow. (The $ s in restore_z nd restore_ refer to the urrent instrution ddress.) 'Sve Z nd in their restore instrutions: sve_z muxnz restore_z,#1 'Sve NZ it in restore_z, it 0. ll #swp 'Swp to lternte oroutine. restore_z test $,#0-0 wz 'Test to restore Z flg. oroutines in Propeller ssemly Lnguge v1.0 4 of 5

Prllx Semiondutor sve_ mux restore_,#1 'Sve it in restore_, it 0. ll #swp 'Swp to lternte oroutine. restore_ test $,#0-0 w 'Test to restore flg. 'Sve Z nd in n externl long: sve_z muxnz flgs,#%10 'Sve NZ it in flgs, it 1. sve_ mux flgs,#%01 'Sve it in flgs, it 0. ll #swp 'Swp to lternte oroutine. restore_z test flgs,#%10 wz 'Restore Z from flgs, it 1. restore_ test flgs,#%01 w 'Restore from flgs, it 0. 'or restore_z shr flgs,#1 wz,w,nr 'Restore Z nd from flgs, its 1 nd 0. 'its 31..2 of flgs must e zero. flgs long 0 Resoures ownlod the oroutine exmple ode from www.prllxsemiondutor.om/n014. Referenes 1. Propeller emo ord; Prllx #32100, www.prllx.om Revision History Version 1.0: originl doument. Prllx, In., d Prllx Semiondutor, mkes no wrrnty, representtion or gurntee regrding the suitility of its produts for ny prtiulr purpose, nor does Prllx, In., d Prllx Semiondutor, ssume ny liility rising out of the pplition or use of ny produt, nd speifilly dislims ny nd ll liility, inluding without limittion onsequentil or inidentl dmges even if Prllx, In., d Prllx Semiondutor, hs een dvised of the possiility of suh dmges. Reprodution of this doument in whole or in prt is prohiited without the prior written onsent of Prllx, In., d Prllx Semiondutor. opyright 2011 Prllx, In. d Prllx Semiondutor. ll rights re reserved. Propeller nd Prllx Semiondutor re trdemrks of Prllx, In. oroutines in Propeller ssemly Lnguge v1.0 5 of 5