Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer int

Status
Not open for further replies.

SmileeTiger

Programmer
Mar 13, 2000
200
US
Hi,

I am trying to get the timer interrupt to work with some music I wrote. Bacically I can get this to work when I use a keyboard int (int 80h) but I cannot get it to work with the timer int (1c). Below you will find my code with the keyboard int (80h).

main proc
;This section sets up es to point to the .data section and ds to point to the display
mov ax, @data
mov es,ax ; Moves the ax val to the extra segment
call setup
mov cx,0fh
lop:
call SoundDelay
call SoundDelay
call SoundDelay
loop lop
call endint
mov ax,4C00h
int 21h
main endp

Music proc
mov bx, es:posM1Array
cmp bx, 35d
je M2
call M1Sound
jmp MusicCheck
M2:
call M2Sound

MusicCheck:
mov bx, es:posM2Array
cmp bx, 35d
je FixMusicPos
sti
int 80h
iret
FixMusicPos: ;Setting the music pos back to 0
mov bx,0h
mov es:posM2Array,bx
mov es:posM1Array,bx
sti
int 80h
iret
Music endp

setup proc
mov ax,0h
mov ds,ax
mov si,024h
mov di,0200h
mov ax,[si]
mov [di],ax
mov ax,[si+2]
mov [di+2],ax
cli
mov ax, offset music
mov [si],ax
mov ax,cs
mov [si+2],ax
sti
ret
setup endp

endint proc
cli
mov ax,0
mov ds,ax
mov si,024h
mov di,0200h
mov ax,[di]
mov [si],ax
mov ax,[di+2]
mov [si+2], ax
sti
ret
endint endp

end main

This works flawlessly however when I try to use the timer int it simply crashes.
Below is my time int code:

main proc
;This section sets up es to point to the .data section and ds to point to the display
mov ax, @data
mov es,ax ; Moves the ax val to the extra segment
call setup
mov cx,0fh
lop:
call SoundDelay
call SoundDelay
call SoundDelay
loop lop
call endint
mov ax,4C00h
int 21h
main endp

Music proc
mov bx, es:posM1Array
cmp bx, 35d
je M2
call M1Sound
jmp MusicCheck
M2:
call M2Sound

MusicCheck:
mov bx, es:posM2Array
cmp bx, 35d
je FixMusicPos
sti
int 01ch
iret
FixMusicPos: ;Setting the music pos back to 0
mov bx,0h
mov es:posM2Array,bx
mov es:posM1Array,bx
sti
int 01ch
iret
Music endp

setup proc
mov ax,0h
mov ds,ax
mov si,020h
mov di,070h
mov ax,[si]
mov [di],ax
mov ax,[si+2]
mov [di+2],ax
cli
mov ax, offset music
mov [si],ax
mov ax,cs
mov [si+2],ax
sti
ret
setup endp

endint proc
cli
mov ax,0
mov ds,ax
mov si,020h
mov di,070h
mov ax,[di]
mov [si],ax
mov ax,[di+2]
mov [si+2], ax
sti
ret
endint endp

end main


I strongly suspect that the problem is in this section:
mov si,020h
mov di,070h

anyone have any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top