Assembler help
17 отговора
702 прегледа
Assembler help
Наложи ми се да напиша, една програмка на асемблер:
Някаква фигурка да се движи по екрана.
Та по този повод въпроса ми е дали има някакво прекъсване/фунuция, която да прекъсва изпълнението на програмта за определено време, нещо подобно на wait?
Мерси предварително!!!!!



Някаква фигурка да се движи по екрана.
Та по този повод въпроса ми е дали има някакво прекъсване/фунuция, която да прекъсва изпълнението на програмта за определено време, нещо подобно на wait?
Мерси предварително!!!!!
Re: Assembler help
честно казано, не намерих готова функция. затова пък мисля че е лесно да се организира цикъл, като се ползва системния таймер. Ето и функция за четене на системния таймер /BIOS/:
mov AH,0
int 1ah
Връща CX:DX - high/low от системния таймер. Той прекъсва с честота 18.206/секунда.
хелпа ми е доста стар, и покрива 286 ;-) ама си мисля че ще свърши работа.
мисля че ще се справиш и сам с цикъла, ако не, готов съм да заработя една бира.
чети и дишай по-леко
mov AH,0
int 1ah
Връща CX:DX - high/low от системния таймер. Той прекъсва с честота 18.206/секунда.
хелпа ми е доста стар, и покрива 286 ;-) ама си мисля че ще свърши работа.
мисля че ще се справиш и сам с цикъла, ако не, готов съм да заработя една бира.
чети и дишай по-леко
Re: Assembler help
Ima mnogo po-dobur variant, a imenno da vurjesh funkciata, koyato mesti kartinkata na prekusvaneto na taimera. Tova e prekusvane 1Ch. Moje i na 0Ch, no !Ch e po-dobriyat variant. To se izvikva okolo 18.2 puti v sekunda. Ako znaesh kak da prehvanesh prekusvaneto, ottam e lesno. A moje v prekusvaneto da pravish nyakakva promenliva TRUE, a v cikula, v koito mestish kartinkata, da ya chakash promenlivata da stane TRUE, i da ya pravish FALSE, sled kato izchertaesh kartinkata. A mojesh i da broish vremeto:
NumberOfTicks db 0
TimerInterruptRoutine proc far
inc cs:NumberOfTicks
iret
TimerInterruptRoutine endp
DrawPic proc
l1:
....... ;Draw picture
.......
........
l2: cmp cs:NumberOfTicks,17
jb l2
jmp l1;
ret
DrawProc endp
Tova shte risuva kartinkata priblizitelno vednuj v sekunda.
Ako imash nujda da ti napisha kak da prehvanesh prekusvaneto, pishi tuk, no vse pak purvo procheti v knigite ;-)))
NumberOfTicks db 0
TimerInterruptRoutine proc far
inc cs:NumberOfTicks
iret
TimerInterruptRoutine endp
DrawPic proc
l1:
....... ;Draw picture
.......
........
l2: cmp cs:NumberOfTicks,17
jb l2
jmp l1;
ret
DrawProc endp
Tova shte risuva kartinkata priblizitelno vednuj v sekunda.
Ako imash nujda da ti napisha kak da prehvanesh prekusvaneto, pishi tuk, no vse pak purvo procheti v knigite ;-)))
Редактирано от MishoM на
Re: Assembler help
ako si pod cist DOS (ne pod windows) varsi rabota slednoto:
MOV CX,XXXX
L1:
HLT
LOOP L1
zakasniava ti XXXX*55ms
mojes i da is prihvanes INT8 koeto e prekasvaneto na taimer0 i s period 55ms
mojes i d acetes ot adres 0:46C se namira edna DWORD deto se inc-va s period 55ms
za po kratki zakasnenia mojes da cetes i direktno taimer0 togava dojes da cepis okolo 1us
nai tocno e da polzvas instrukciata za PENTIUM
RDTSC
koieto v EDX:EAX ti vrasta 64bit cislo koeot se inc-va s cestotata na procesora! (s AMD procesor nemoje da se cete virtualen rejim t.e. ot DOS prozorec)
MOV CX,XXXX
L1:
HLT
LOOP L1
zakasniava ti XXXX*55ms
mojes i da is prihvanes INT8 koeto e prekasvaneto na taimer0 i s period 55ms
mojes i d acetes ot adres 0:46C se namira edna DWORD deto se inc-va s period 55ms
za po kratki zakasnenia mojes da cetes i direktno taimer0 togava dojes da cepis okolo 1us
nai tocno e da polzvas instrukciata za PENTIUM
RDTSC
koieto v EDX:EAX ti vrasta 64bit cislo koeot se inc-va s cestotata na procesora! (s AMD procesor nemoje da se cete virtualen rejim t.e. ot DOS prozorec)
Re: Assembler help
Получих едно доста забавно писмо от теб, в което съм обвинен в незаслужаване на бира... Интересно е че в постинга пише едно, в писмото друго. Много бих се радвал да си изясним позициите, за предпочитане в ICQ. Но ако държиш, може и във форума.
чети и дишай по-леко
чети и дишай по-леко
Re: Assembler help
Ако ти трябва просто за малко да спреш ползвай NOP - no operation и го организирай с LOOP в някакъв цикъл, примерно
MOV CX, 1000
Label:
NOP
LOOP Label
Целта оправдава средствата
MOV CX, 1000
Label:
NOP
LOOP Label
Целта оправдава средствата
Re: Assembler help
Opps... Kakto pravilno beshe kazano v edin ot po-kusnite postove, hardware-noto prekusvane na timer-a e 8. Taka che za da ne stane oburkvacia: 08h e hardwarenoto prekusvane na timera, to obiknoveno e prehvanato ot BIOS i v takuv sluchai izvikva potrebitelskoto prekusvane na timera, koeto e 1Ch.
Re: Assembler help
Pratih ti offline suobshtenie, ako se e zagubilo nyakude po putya moeto q e 44877792.
Re: Assembler help
Indianci!
Wsichki prekaswaniq koito se izpolzwat sa prehwanati ot nqkogo! I tam w "primera" deto prihwashtash 1C i prawish iret - "losho Sedlarow losho!" po podhodqshto mi se struwa i w duha na dobroto sistemno programirane e da naprawish jmp far cs:[oldvec] ili neshto ot sorta
Wsichki prekaswaniq koito se izpolzwat sa prehwanati ot nqkogo! I tam w "primera" deto prihwashtash 1C i prawish iret - "losho Sedlarow losho!" po podhodqshto mi se struwa i w duha na dobroto sistemno programirane e da naprawish jmp far cs:[oldvec] ili neshto ot sorta
Re: Assembler help
Мисля, че имаше някакъв таймер на прекъсване 21H функция 15H... трябва да проверя, и пак ще ти кажа (от толкова отдавна не съм писал за DOS
)
Re: Assembler help
Aha, ami ako po vreme na HLT-to se natisne klavish, mrydne mishka ili.... , a? :-)))
АААА! СЕТИХ СЕ!!!
Трябват ти INT 15H, функции 83H или 86H (по-скоро 86H):
INT 15h, 83h (131) Event Wait many
Modifies a byte in the user's memory after a specified time interval.
Control is transferred to the caller immediately after this service is
called.
On entry: AH 83h
AL Subservice
00h - Set interval
01h - Cancel set interval
ES:BX - Pointer to byte that will be posted
CX:DX - Microseconds until posting (long integer)
Returns: Carry Set if service not supported, else cleared
--------------------------------------------------------------------------
After this service is called, control is returned immediately to the
caller. This service does not work by delaying and then returning
control to the user, but returns control immediately; the user must
periodically look at the byte specified (pointed to by ES:BX) to
determine when the interval has elapsed.
Notes: The PC, PCjr, and the XT dated 11/08/82 do not
support this service. The AT dated 1/10/84 is only
able to set the interval; thus the value in AL is
not used.
The byte is posted by setting the high bit (bit 7).
To test the end of the interval, make sure the high
bit of the byte is clear before calling Subservice 0
(Set Interval).
The real-time clock is used to count the number of
microseconds.
The granularity of the time is 976 microseconds.
CX is the high-order word of the count. For example,
if CX is 98h and DX is 9680h, then a 10-second delay
would be specified.
--------------------------------------------------------------------------------
INT 15h, 86h (134) Wait XT-286, AT
Waits a specified number of microseconds before returning control to
the caller.
On entry: AH 86h
CX:DX Number of microseconds to elapse
Returns: Carry Set if error or wait in progress, else
cleared
--------------------------------------------------------------------------
Notes: This service is not available for the PC, PCjr, and
the XT.
The real-time clock is used to count the number of
microseconds.
The granularity of the time is 976 microseconds.
CX is the high-order word of the count. For example,
if CX is 98h and DX is 9680h, a 10-second delay
would be specified.
INT 15h, 83h (131) Event Wait many
Modifies a byte in the user's memory after a specified time interval.
Control is transferred to the caller immediately after this service is
called.
On entry: AH 83h
AL Subservice
00h - Set interval
01h - Cancel set interval
ES:BX - Pointer to byte that will be posted
CX:DX - Microseconds until posting (long integer)
Returns: Carry Set if service not supported, else cleared
--------------------------------------------------------------------------
After this service is called, control is returned immediately to the
caller. This service does not work by delaying and then returning
control to the user, but returns control immediately; the user must
periodically look at the byte specified (pointed to by ES:BX) to
determine when the interval has elapsed.
Notes: The PC, PCjr, and the XT dated 11/08/82 do not
support this service. The AT dated 1/10/84 is only
able to set the interval; thus the value in AL is
not used.
The byte is posted by setting the high bit (bit 7).
To test the end of the interval, make sure the high
bit of the byte is clear before calling Subservice 0
(Set Interval).
The real-time clock is used to count the number of
microseconds.
The granularity of the time is 976 microseconds.
CX is the high-order word of the count. For example,
if CX is 98h and DX is 9680h, then a 10-second delay
would be specified.
--------------------------------------------------------------------------------
INT 15h, 86h (134) Wait XT-286, AT
Waits a specified number of microseconds before returning control to
the caller.
On entry: AH 86h
CX:DX Number of microseconds to elapse
Returns: Carry Set if error or wait in progress, else
cleared
--------------------------------------------------------------------------
Notes: This service is not available for the PC, PCjr, and
the XT.
The real-time clock is used to count the number of
microseconds.
The granularity of the time is 976 microseconds.
CX is the high-order word of the count. For example,
if CX is 98h and DX is 9680h, a 10-second delay
would be specified.
Re: Assembler help
e pa togava....
sa maskiras ostanalit eprekasvania v kontrolera! ako e fatalno! :-)
sa maskiras ostanalit eprekasvania v kontrolera! ako e fatalno! :-)
Re: Assembler help
da ama LOOP se izaplniava na 8086 za 11takta na PENTIUM1 pak za 11takta na K5 za 1 za drugite AMD pak za 1