0

I want to know how i can do delay (Timer) on assembler 16 bit on PC. Thank You for helping, Norm.

OS: Windows

CODE:

 delay:
     inc bx
     cmp bx,WORD ptr[time]
     je delay2
     jmp delay
 delay2:
     inc dx
     cmp dx,WORD ptr[time2]
     je delay3
     jmp delay
     mov bx,0
 delay3:
     inc cx
     cmp cx,WORD ptr[time3]
     je Finish_delay
     jmp delay

its not work good i need less complicated code

starblue
  • 55,348
  • 14
  • 97
  • 151
Norm
  • 1
  • 1
  • Did you just make a new account and ask *exactly* the same question as you did 10 minutes ago? With no more information? BOOO. http://stackoverflow.com/questions/3016438 – Carl Norum Jun 10 '10 at 17:07
  • 1
    We need a lot more information if you want an answer - what architecture? What OS or environment? What code do you have already and what about it doesn't work? – Carl Norum Jun 10 '10 at 17:09
  • 1
    edit your post to add the code. The unformatted mess in the comment is useless. – Carl Norum Jun 10 '10 at 17:13
  • Check [here](http://stackoverflow.com/questions/1858640/how-can-i-create-a-sleep-function-in-16bit-masm-assembly-x86) (*How can I create a sleep function in 16bit MASM Assembly x86?*). – Tarantula Jun 10 '10 at 19:33

1 Answers1

0

Why don't you insert special NO-OP instructions? Or you can calculate a delay by inserting a branch instruction that is always mispredicted a certain number of times and multiplying that with the branch penalty of your architecture. That can be accurate +- 1 cycle.

dean
  • 235
  • 1
  • 2
  • 8