Controlling time intervals in Assembly

  • Thread starter Thread starter Lucifer666
  • Start date Start date
  • Views Views 822
  • Replies Replies 0

Lucifer666

all the world needs is me
Member
Joined
Apr 22, 2011
Messages
1,626
Reaction score
1,011
Trophies
1
Location
The Fourth Dimension
XP
2,160
Country
United Kingdom
I have assembly code laid out in the following structure (I'll use pseudo commands for readability). Its function is to remain in a state for 0.5s then another state for 0.5s, repeatedly.

Code:
main:           //do things
                //do things
                //do things

                call ofs //ofs is a 0.5s time delay command
                //do things
                //do things
                //do things

                call ofs //ofs is a 0.5s time delay command
rjmp main

ofs:          //program time delay
              ret

I've re-written it, trying to preserve its functionality, but the result is a 0.5s delay after the first set of 'things' to do and then a 1.5s delay after the second set of things. Why does this happen? Code below:

Code:
main:           //do things
                //do things
                //do things

                call ofs //ofs is a 0.5s time delay command
                //do things
                //do things
                //do things


ofs:          //program time delay
              ret
rjmp main
 
Last edited by Lucifer666,

Site & Scene News

Popular threads in this forum