SmileeTiger
Programmer
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, esosM1Array
cmp bx, 35d
je M2
call M1Sound
jmp MusicCheck
M2:
call M2Sound
MusicCheck:
mov bx, esosM2Array
cmp bx, 35d
je FixMusicPos
sti
int 80h
iret
FixMusicPos: ;Setting the music pos back to 0
mov bx,0h
mov esosM2Array,bx
mov esosM1Array,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, esosM1Array
cmp bx, 35d
je M2
call M1Sound
jmp MusicCheck
M2:
call M2Sound
MusicCheck:
mov bx, esosM2Array
cmp bx, 35d
je FixMusicPos
sti
int 01ch
iret
FixMusicPos: ;Setting the music pos back to 0
mov bx,0h
mov esosM2Array,bx
mov esosM1Array,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?
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, esosM1Array
cmp bx, 35d
je M2
call M1Sound
jmp MusicCheck
M2:
call M2Sound
MusicCheck:
mov bx, esosM2Array
cmp bx, 35d
je FixMusicPos
sti
int 80h
iret
FixMusicPos: ;Setting the music pos back to 0
mov bx,0h
mov esosM2Array,bx
mov esosM1Array,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, esosM1Array
cmp bx, 35d
je M2
call M1Sound
jmp MusicCheck
M2:
call M2Sound
MusicCheck:
mov bx, esosM2Array
cmp bx, 35d
je FixMusicPos
sti
int 01ch
iret
FixMusicPos: ;Setting the music pos back to 0
mov bx,0h
mov esosM2Array,bx
mov esosM1Array,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?