flat assembler
Message board for the users of flat assembler.
Index
> DOS > how to make quality of sound better? |
Author |
|
revolution 16 Dec 2007, 10:45
Try to use a different register than sp for your counter loop. This won't improve the quality of sound but will reduce your headaches with stack problems when your code becomes larger.
|
|||
16 Dec 2007, 10:45 |
|
KIRK 16 Dec 2007, 13:09
I need to carry out only one task - to write a siren =)
|
|||
16 Dec 2007, 13:09 |
|
DOS386 16 Dec 2007, 13:20
Code: org $100 format binary as "COM" mov di,100 b1: call Beep inc di cmp di,255 jne b1 b2: call Beep dec di cmp di,100 jne b2 in al,$61 and al,11111100b out $61,al ; Shut up now !!! mov ax,$4C00 int $21 Beep: mov bx,di mov ax,$34DD mov dx,$0012 div bx ; Divident from DX:AX | Quotient in AX mov bx,ax in al,61h test al,3 jnz @f or al,3 out 61h,al mov al,$B6 out 43h,al @@: mov al,bl out 42h,al mov al,bh out 42h,al xor ax,ax mov es,ax mov eax,[es:$46C] @@: cmp eax,[es:$46C] jz @b ret Your code was desperately buggy and didn't work at all for me - starts the sound and then aborts using an illegal way while sound remains on Fixed the SP bug as well as the sound quality bug and many other bugs Next time, please comment your code - I have no clue what those various silly instructions in your code were supposed do _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
16 Dec 2007, 13:20 |
|
KIRK 16 Dec 2007, 14:22
hey, man, you has gone mad on bugs!
probably there was one bug, but it is no more! with comments and some changes Code: org $100 mov bp,100 ;initial value of minimal frequency mov sp,250 ;initial value of maximal frequency mov di,bp mov cx,1 ;initial value of step for changing frequency b1:call Beep ;increase frequency add di,cx cmp di,sp jb b1 b2:call Beep ;decrease frequency sub di,cx cmp di,bp ja b2 jmp b1 Beep: mov bx,di ;start playing of the sound mov ax,34DDh mov dx,0012h div bx mov bx,ax in al,61h test al,3 jnz @f or al,3 out 61h,al mov al,0B6h out 43h,al @@:mov al,bl out 42h,al mov al,bh out 42h,al xor ax,ax ;start anything for a small pause mov es,ax mov eax,[es:46Ch] @@:cmp eax,[es:46Ch] jnb @b xor ax,ax ;check keyboard input in al,60h test al,10000000b jnz Exit ;exit if any key was pressed in al,61h ;stop the sound and al,11111100b out 61h,al ret Exit: mov ax,4Ch int 21h |
|||
16 Dec 2007, 14:22 |
|
DOS386 18 Dec 2007, 18:52
> hey, man, you has gone mad on bugs!
NO. And you re-implemented at least 3 critical bugs I had fixed for you. But there is indeed no help against intentional bugs. |
|||
18 Dec 2007, 18:52 |
|
edfed 19 Dec 2007, 23:28
sp is used by call.
used to tell where to return. 1 very important rule, never use sp/esp as a register erf erf erf |
|||
19 Dec 2007, 23:28 |
|
System86 08 Jan 2008, 02:07
Quote:
Right. SP/ESP is actually used/modified by all of the following. So, don't use SP if you plan on using any of the following: *push *pop *pushf *popf *pusha *popa *call *ret *int *iret *enter *leave. Using any of these (if SP contains data) will overwrite random data somewhere in memory and will change the data in SP. Even worse, if a hardware interrupt occurs (RTC interrupt, user hitting the keyboard) the return value is saved on the stack, so somewhere in memory data is overwritten, with undefined results. The only way to avoid this is to cli before using SP, but then all I/O must be done with polling the hardware with in/out, since you lost DOS/BIOS (no INT or CALL). Basically, only change SP/ESP if you want to change the location of the stack. |
|||
08 Jan 2008, 02:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.