In SX Microcontrollers, SX/B Compiler and SX-Key Tool, ringlord wrote: All-- While I'm waiting on other developments, I decided to try to cut a little SX assember code. The last assember I used was either for the 8080 or Z80 instruction set. This was a long time ago. In any case, I was rather amazed at how the rudiments returned to me! All the code listed below does is blink and LED and call a subroutine for the pause. The environment is a PDB with one of [b]RobotWorkshop's[/b] SX48 modules, a USB SX-Key Rev. B and the SX-Key v3.3.0 IDE. If you have time to look at the code, I would appreciate comments. I would PARTICULARLY like to learn how to time instructions so I could write a good delay routine, instead of empirically figuring it out. Plus, I am sure the code could be shortened a bunch. I would really like to see how one might do that. (It would be neat if I knew how to make these little code segments look neat in a post like everyone else does, too.) Thanks! ; Program name: 01-16-10 SX48 First Assembly Code.SRC ; ; Author: Bill Chennault ; ; Date: 01/16/10 ; ; Description: This program blinks an LED and uses a subroutine for delay device sx48,oschs3 IRC_CAL IRC_SLOW reset start_point freq 50_000_000 org 0 ; place assembled code beginning at address 0 start_point Main mov !rb,#0 ; make port B pins all output mov rb,#0 ; make all port B pins high (turn LED on) call Delay ; pause mov rb,#1 ; make all port B pins low (turn LED off) call Delay ; delay jmp Main ; do this forever ; subroutine: Delay Delay mov $0f,#$ff ; set fr 0fh to ffh mov $10,#$ff ; set fr 10h to ffh mov $11,#$14 ; set fr 11h to 14h pause decsz $0f ; decrement fr 0fh; if 0, skip the next instruction jmp pause ; it wasn't 0, stay in the loop decsz $10 ; decrement fr 10h; if 0, skip the next instruction jmp pause ; it wasn't 0, stay in the loop decsz $11 ; decrement fr 101; if 0, skip the next instruction jmp pause ; it wasn't 0, stay in the loop ret jmp start_point [/quote] --Bill ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=418758 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2010 (http://www.dotNetBB.com)