Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

delay u asembleru

[es] :: Asembler :: delay u asembleru

[ Pregleda: 4234 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

programer15
tunguzija

Član broj: 279634
Poruke: 153
31.223.131.*



+8 Profil

icon delay u asembleru04.10.2011. u 14:59 - pre 151 meseci
imam problem, kako da dobijem pauzu od 100ms? Radim neki program u nasm
Code:
mov si,part01
call print
mov si,part02
call print
mov si,part1
call print
mov si,part2
call print
mov si,part3
call print
mov si,part4
call print
mov si,part5
call print
mov si,part6
call print
mov si,part7
call print
mov si,part8
call print
mov si,part9
call print
mov si,part10
call print
mov si,part11
call print
mov si,part12
call print
mov si,part13
call print
mov si,part14
call print
mov si,part15
call print
mov si,part16
call print
mov si,part17
call print

pa mi treba npr prvo da se ispise part01, pa saceka 100ms pa part02 pa sve tako redom!!!
 
Odgovor na temu

Ivan Dimkovic

Administrator
Član broj: 13
Poruke: 16683
...kabel-badenwuerttemberg.de.



+7169 Profil

icon Re: delay u asembleru04.10.2011. u 15:22 - pre 151 meseci
Odgovor zavisi od operativnog sistema...

Ako je u pitanju Windows, pozovi "Sleep()" Win32 API gde je DWORD parametar broj milisekundi. Kernel ce onda suspendovati izvrsenje niti koja je pozvala Sleep() dok ne istekne zadato vreme.

Za linux, opet - imas razne sleep API-je - http://tldp.org/HOWTO/IO-Port-Programming-4.html.

Ako je u pitanju DOS... moraces sam da implementiras rutinu za spavanje, koja ce vrlo-verovatno biti busy wait (koji ce trositi CPU cikluse). Za proveru vremena mozes koristiti interapt 1A - http://www.htl-steyr.ac.at/~mo...rdware/interrupts/inte2do0.htm


DigiCortex (ex. SpikeFun) - Cortical Neural Network Simulator:
http://www.digicortex.net/node/1 Videos: http://www.digicortex.net/node/17 Gallery: http://www.digicortex.net/node/25
PowerMonkey - Redyce CPU Power Waste and gain performance! - https://github.com/psyq321/PowerMonkey
 
Odgovor na temu

Miroslav Ćurčić
ex mVeliki
Novi Sad

Član broj: 19034
Poruke: 1118
*.adsl.eunet.rs.



+19 Profil

icon Re: delay u asembleru05.10.2011. u 16:21 - pre 151 meseci
Koliko znam asembler nema "sleep" instrukciju, pa ćeš je morati sam isprogramirati.

Ako pišeš program za konkretan procesor onda mu znaš frekvenciju i broj taktova po instrukciji i možeš napraviti petlju (ili petlju u petlji) koja će raditi neki uzaludan posao, a sve to da potraje tačno 100ms.

Mislim da ti je bolja ideja da za ovo iskoristiš interapt kojeg vežeš na tajmer podešen na 100ms.
"The quieter you become, the more you are able to hear."
Blog | PowerCMS
 
Odgovor na temu

programer15
tunguzija

Član broj: 279634
Poruke: 153
31.223.131.*



+8 Profil

icon Re: delay u asembleru13.10.2011. u 16:00 - pre 151 meseci
evo ga:

Code:
pause:
    pusha
    cmp ax, 0
    je .time_up            

    mov cx, 0
    mov [.counter_var], cx        

    mov bx, ax
    mov ax, 0
    mov al, 2            
    mul bx                
    mov [.orig_req_delay], ax

    mov ah, 0
    int 1Ah                    

    mov [.tick_count], dx    

.checkloop:
    mov ah,0
    int 1Ah                

    cmp [.tick_count], dx    

    jne .up_date                        
    jmp .checkloop            

.time_up:
    popa
    ret

.up_date:
    mov ax, [.counter_var]        ;
    inc ax
    mov [.counter_var], ax

    cmp ax, [.orig_req_delay]    
    jge .time_up            

    mov [.tick_count], dx    

    jmp .checkloop            


    .orig_req_delay        dw    0
    .counter_var        dw    0
    .tick_count    dw    0
 
Odgovor na temu

[es] :: Asembler :: delay u asembleru

[ Pregleda: 4234 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.