can anyone explain me, why does this effect take place:
Posted on 2003-01-23 01:52:41 by longer
nice signal - but what the hell should that be? what are these 3 parameters to the right? some sourcecode? how should it look correctly? else nobody will be able to help you...
Posted on 2003-01-23 13:13:55 by hartyl
Its called sawtooth, because your variables overflow/underflow when decrease minimum (underflow) or increase maximum (overflow), so it wraps around.
Posted on 2003-01-23 15:28:29 by comrade
The signal is neither a sawtooth, nor a periodic signal at all. Only one impulse, which decreases in time from 65535 to zero. The program calculates and stores it in memory as it really shoud be, but there's problem with a diagram of it, as you can see.
I just take the amplitude at some points, divide it by 65535 and multiply by 200 (height of the diagram in pixels).
Posted on 2003-01-23 23:19:19 by longer
Which opcodes do you use to multiply and divide?

It would appear that you may be doing a signed division and you're getting the proper result only when the signal is less than 32767 giving you a final result below 100.

Raymond
Posted on 2003-01-24 22:26:25 by Raymond
The DC area of your window is not the same as the window size... decrease your scalling number to something like 150 for your 200 pixel window.

My guess is your still rolling over in available DC space.
Posted on 2003-01-26 11:05:47 by NaN
Thanks for your reply, NaN, but I don't think that there's something wrong with DC.
It is more likely that there's something wrong with signed operations.
I use FPU to scale numbers:


fild [X]
fld [Amplitude]
fild word [eax]
fdiv st0,st1
fmul st0,st2
fist dword [edx]

mov eax,200
sub eax,dword [edx]
mov dword [edx],eax
add dword [edx],15
cmp dword [edx],216
jl _Cont

sub dword [edx],200

_Cont:

, where eax points to the number itself, X is a scaling number
Posted on 2003-01-26 12:54:48 by longer
I don't see how "sub dword ,200" would be needed, unless you want the graph to wrap around? Maybe, "mov dword ,215" is a better choice. With your code it is possible to have values not in range 15 thru 215.
	fild	[X]

fld [Amplitude]
fild word [eax]
fdiv st0, st1
fmul st0, st2
fist dword [edx]

mov eax, 200
sub eax, dword [edx]
jns _1
xor eax, eax
_1: add eax, 15
cmp eax, 216
jl _Cont

mov eax, 215

_Cont:
mov dword [edx], eax
Posted on 2003-01-26 13:43:59 by bitRAKE
Sometimes, assumptions are right.

Since you don't really need the full precision of the signal for your graph, I would suggest that you shift it right 1 bit before loading that integer to the FPU. It would then be loaded as a positive number.

You then have a choice of "fadd st,st(0)" to restore the full number (without the last bit) or adjust your scaling factor for your graph.

Another choice you would have is to load that signal as a DWORD to the FPU. It would always be positive in the range you are using.

Raymond
Posted on 2003-01-27 00:01:50 by Raymond
Sorry, I've forgotten to say that the part of code I posted works fine.
2 bitRAKE:
Thanks for your suggestion, but, the code you posted just cut off the upper coordinates, while I need them to be shifted back by 200 pixels: sub dword ,200. ;)
2 Raymond:
Your advice are very helpful. Now everything works with dword loading. Thank you! :alright:
Posted on 2003-01-27 01:31:26 by longer