News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Recent posts

#71
Showcase / Re: MediaPlayer
Last post by greenozon - August 31, 2024, 05:03:40 PM
Will it render modern videos encoed by H.265, AV1, or more newwer one?
#72
MASM64 SDK / Re: cmd_tail
Last post by jj2007 - August 31, 2024, 03:28:21 PM
Quote from: sinsi on August 31, 2024, 09:06:53 AMUse ADD and SUB when optimizing for speed. Use INC and DEC when optimizing for size or
when no penalty is expected.

We've tested that several times in the Lab. No difference.
#73
MASM64 SDK / Re: cmd_tail
Last post by sinsi - August 31, 2024, 10:31:39 AM
Quote from: NoCforMe on August 31, 2024, 09:15:17 AMSo what I wrote was true ...
Not sure about the percentage, but yes - for a particular series of CPU (early P4s I think).
#74
MASM64 SDK / Re: cmd_tail
Last post by NoCforMe - August 31, 2024, 09:15:17 AM
So what I wrote was true ...
#75
MASM64 SDK / Re: cmd_tail
Last post by sinsi - August 31, 2024, 09:06:53 AM
Quote from: Rockphorr on August 30, 2024, 01:34:40 AMWhy uses add instead inc ?

Long ago, a guru told us to
Quote16.2 INC and DEC
The INC and DEC instructions do not modify the carry flag but they do modify the other
arithmetic flags. Writing to only part of the flags register costs an extra µop on some CPUs.
It can cause a partial flags stalls on some older Intel processors if a subsequent instruction
reads the carry flag or all the flag bits. On all processors, it can cause a false dependence
on the carry flag from a previous instruction.
Use ADD and SUB when optimizing for speed. Use INC and DEC when optimizing for size or
when no penalty is expected.
#76
Windows Projects / Re: Hyper (precision) numeric ...
Last post by jack - August 31, 2024, 07:17:02 AM
hello i Z !
I would be interested in testing you HyperLib but there several reasons that prevent that
1: prohibitive licence
2: closed source
3: binary distribution only, and worst, it comes as an installer
#77
MASM64 SDK / Re: cmd_tail
Last post by NoCforMe - August 31, 2024, 04:57:24 AM
Because it'll make it 0.00001% faster?
#78
Showcase / Re: MediaPlayer
Last post by jj2007 - August 30, 2024, 07:31:53 AM
Quote from: fearless on August 30, 2024, 12:27:08 AMunfortunately the Microsoft Media Foundation doesn't seem to support .ogg files.

I vaguely remember that I had to install a codec pack to make them run.
#79
Windows Projects / Hyper - Divide using multiplic...
Last post by i Z ! - August 30, 2024, 07:29:57 AM
Found a relatively quick way to divide. It's approximate, but close enough  :smiley:

VB
Option Explicit Off
Imports HyperLib

'!!! For this code to work, because of the numeric methods used, "Skip integer overflow checks" option must be checked in the Advanced compile settings

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Hyper.displayMode = Hyper.displayModeType.inDecimalBase2_64
        Hyper.maxDigitsInString = 7 'display range

        ' input some random numbers for a and d ->
        Dim a As New Hyper(-251, -253)    'assign 3 * 8 bytes for a, with its least exponent (2^64)^(-253)                 
        a(-252) = -79786875757656175
        a(-253) = 79978687575765619 '
        a(-251) = 7978687575765619

        Dim d As New Hyper(-444, -444) 'reserve 8 bytes for the divisor
        d(-444) = 1 + (2 ^ 53)
        d(-5) = 1 + 2 ^ 44 'mantissa automatically gets extended when assigning values at exponents out of current range; now the size of "d" is ((444-5) * 8) bytes

        Debug.WriteLine("")

        Dim rdiv As Hyper = QuickDivide(a, d)

        Debug.WriteLine("=================== result:")
        Debug.WriteLine(rdiv)

        rdiv *= d

        Debug.WriteLine("=================== check:")
        Debug.WriteLine(rdiv)

    End Sub



    Private Function QuickDivide(dividend As Hyper, d As Hyper) As Hyper
        Return dividend * ReciprocalVal(d)
    End Function
    Private Function ReciprocalVal(d As Hyper) As Hyper

        precision% = 1444 'number of 64-bit digits to extract. Must be larger than exponent range
        precision2% = 222 'may be zero

        Dim r As New Hyper(precision, 0) ' New Hyper(0, 0)
        Dim bp, r1 As Hyper

        hiExp% = d.FindHighExponent
        lowExp% = d.FindLowExponent
        lowVal& = d(lowExp)
        If lowVal And 1 = 0 Then
            Debug.WriteLine("even nr")
            'if the least significant bit is 0, then we can help ourselves with dividing/multiplying the dividend, and then the result, by 2^n.

            d(lowExp - 1) = 1
            lowVal = 1
            lowExp -= 1
        End If
        mq& = GetMagicNr(lowVal)
        pos% = lowExp '
        d.Round(-pos)
        d.PartSize = 0
        bp = New Hyper("1")
        pos1% = 0

mainloop:
        ' get the sequence which, when multiplied by divisor, nullifies itself

        r1 = New Hyper(pos1, pos1)
        r1(pos1) = bp(pos1) * mq

        r(pos1) = r1(pos1)
        bp -= d * r1
        bp.Negate()

        pos1 += 1

        If pos1 > precision Then GoTo nx
        'reciprocal values of large numbers tend to repeat at very large intervals, so we'll be satisfied with our precision                

        GoTo mainloop

nx:
        r1 = r * d

        hi% = r1.FindHighExponent
        r.Divide(r1(hi), precision2)
        r.PartSize = hi + r1.PartSize + r.PartSize + lowExp  '.PartSize           
        d.PartSize = -lowExp

        Debug.WriteLine("--=-=-=-=- recip*d:")
        Debug.WriteLine(r * d) 'should output close to 1
        Debug.WriteLine(r)
        Debug.WriteLine("--=-=-=-=-")

        Return r
    End Function

    Private Function GetMagicNr&(a&)

        ' Magic number or "reciprocal integer" - GET THE 64-BIT NUMBER WHICH, when multiplied by the lowest digit, gives 1 as the remainder of 2^64              
        ' Only for odd numbers.

        bt& = 1 'bit tester
        d& = a 'bit mask

        r& = 0 : i& = 0 : r0& = 0

        For i = 0 To 63

            If bt And r Then GoTo skip

            r += d
            r0 = r0 Or bt
skip:
            bt <<= 1 : d <<= 1
        Next

        Return r0
    End Function

End Class

Also posted on github


P.S.: I recently noticed that full decimal representation has bugs, I removed the default property from it. Who needs it anyway :)
#80
The Campus / Re: Creating a Game Using MASM...
Last post by NoCforMe - August 30, 2024, 07:01:42 AM
To the OP: I can help you with graphics not using the Irvine library, which apparently is not the best tool in the toolbox ...