how can I put a timer in assembler x86?

0

Hello, someone to help me and tell me what interruption I can use in assembler to do the same thing as the c ++ sleep function, please.

    
asked by Rodrigo 16.12.2017 в 02:43
source

1 answer

0

was to investigate, and I found a function of the interception 15h, which makes wait for a number of microseconds, which is to choose, until the next instruction.

the function is 86h, as a microsecond is 1/1 000 000 of a second, more space is needed to arm a second are necessary records cx and dx, the amount in microseconds must be noted in the following form:

I wrote a small program to test the func 86h - >

model small; small .stack 100; 100 bytes for stack .data a db 'a'

b db 'b'

c db 'c'

d  db 'd'

  e  db 'e'

    f  db 'f'

      g  db 'g'

         h  db 'h'

            i  db 'i'

               j  db 'j'

                  k  db 'k'

                     l  db 'l'

                     dollar  db '$'   ;final de la cadena

.code start: mov ax, @ data mov ds, ax; connect ds with segment of the string

lea si, a  ;direccion del inicio de la cadena de caracteres para imprimir en el si

loop_msg:   ;imprimir un caracter de la cadena , esperar un segundo , imprimir proximo , hasta llegar al dollar
cmp [si],'$'   ; caracter de dollar ?
je exit  ;salir si es

mov al, [si]
mov ah, 0eh; bios function to print a character int 10h; bios interuption mov ah, 86h; the func that makes you wait mov cx, 000Fh; in this case a million micro seconds mov dx, 4240h int 15h
inc yes, increase the position and print the next letter jmp loop_msg
exit: mov ax, 4c00h
int 21h; return to DOS end start

I thank you for creating this article, on the contrary I would not know how to make the graphic animation effect on the screen and take advantage of the timer < 3 = D

    
answered by 02.01.2018 в 17:00