Programming Examples I

Example 1:

Write a program (instruction list) to put the number (4000) in a memory location, and the number (41) in another location. divide the first one by the second and put the result in a memory location.



Example 2:

Make a program to increase the counter by one with each pulse from the pulse generator SM0.4 (on rising edge) , and decrease another counter by the same pulse.


 steps of solution would be like this:

 1. put zero in memory location vw100.

 2. put (10) in the memory location vw110.

 3. with each rising edge from SM0.4 (every 30 sec), we increase memory location vw100 by one. and at the same time decrease  vw110  by one. the program will continue like that without any instruction to stop.

#please note that:
 MOVW => move word
 INCW => increment word
 DECW => decrement word