Once all the preparations are done, the calculation loop in which we generate our forecast is fairly simple. First of all we increment the number of days value, which has a dual purpose--during the first iteration, it solves the problem of the day of birth not being included and advances the current date one day during the remaining iterations.
The second instruction copies the XMM4 register to XMM0, which will be used for most of our calculations, and multiplies it with the number of days in XMM2 by the execution of the third instruction--which actually calculates the (2*PI*t) part of the formula.
The fourth instruction completes the calculation of the value we need the sine of, by division of XMM0 by lengths of biorhythmic periods:
.calc_loop:
addps xmm2, xmm3 ; Increment the number of days by 1.0
movaps xmm0, xmm4 ; Set XMM0 to contain 2*PI values
mulps xmm0, xmm2 ; Actually do the 2*PI*t
divps xmm0, xmm1 ; And complete by (2*PI*t)/T
Now we need to calculate the sine for the resulting values, which is a bit problematic due to the algorithm we are going to use for sine computation and the relatively large numbers. The solution is simple--we need to normalize the values so they fit the (0.0, 2*PI) range. This is implemented by the adjust() procedure:
call adjust ; Adjust values for sine computations
Having adjusted the values in XMM0 (ignore the value of the fourth part of XMM0 as it is irrelevant), we may now compute sine for each of the first three single-precision float parts of the register:
call sin_taylor_series ; Compute sine for each value
We store computed sine values to a table pointed by the eax register (since the table is aligned on a 16-bytes boundary, we are safe to use the movaps instruction, which is slightly faster than its movups counterpart). Then, we advance the table pointer by 16 bytes, decrement ECX, and keep looping while ECX is not 0 with the loop instruction.
When ECX reaches 0, we simply terminate the process:
movaps [eax], xmm0 ; Store the result of current iteration
add eax, 16
loop .calc_loop
push 0
call [exitProcess]
The table, by the end of the loop, should contain the following values:
Date
|
Physical (P)
|
Emotional (S)
|
Intellectual (I)
|
Irrelevant
|
May 9th, 2017 | 0.5195959 | -0.9936507 | 0.2817759 | -NAN |
May 10th, 2017 | 0.2695642 | -0.9436772 | 0.4582935 | -NAN |
May 11th, 2017 | -8.68E-06 | -0.8462944 | 0.6182419 | -NAN |
May 12th, 2017 | -0.2698165 | -0.7062123 | 0.7558383 | -NAN |
May 13th, 2017 | -0.5194022 | -0.5301577 | 0.8659862 | -NAN |
May 14th, 2017 | -0.7308638 | -0.3262038 | 0.9450649 | -NAN |
May 15th, 2017 | -0.8879041 | -0.1039734 | 0.9898189 | -NAN |
May 16th, 2017 | -0.9790764 | 0.1120688 | 0.9988668 | -NAN |
May 17th, 2017 | -0.9976171 | 0.3301153 | 0.9718016 | -NAN |
May 18th, 2017 | -0.9420508 | 0.5320629 | 0.909602 | -NAN |
May 19th, 2017 | -0.8164254 | 0.7071083 | 0.8145165 | -NAN |
May 20th, 2017 | -0.6299361 | 0.8467072 | 0.6899831 | -NAN |
May 21st, 2017 | -0.3954292 | 0.9438615 | 0.5407095 | -NAN |
May 22nd, 2017 | -0.128768 | 0.9937283 | 0.3714834 | -NAN |
May 23rd, 2017 | 0.1362932 | 0.9936999 | 0.1892722 | -NAN |
May 24th, 2017 | 0.3983048 | 0.9438586 | -8.68E-06 | -NAN |
May 25th, 2017 | 0.6310154 | 0.8467024 | -0.18929 | -NAN |
May 26th, 2017 | 0.8170633 | 0.7069295 | -0.371727 | -NAN |
May 27th, 2017 | 0.9422372 | 0.5320554 | -0.5407244 | -NAN |
May 28th, 2017 | 0.9976647 | 0.3303373 | -0.6901718 | -NAN |