Author Topic: Convert REAL4 to HALF  (Read 176 times)

AW

  • Member
  • *****
  • Posts: 1483
  • Let's Make ASM Great Again!
Convert REAL4 to HALF
« on: September 13, 2018, 01:01:37 AM »
As a follow up of this, I present here 2 methods of converting 1 REAL4 to 1 HALF, the VCVTPS2PH method and the no-VCVTPS2PH method.
The first one is the best but may not work on all computers.
I compare if the result obtained from both methods yields the same result. It does  :biggrin: (in this case)

Code: [Select]
HALF values are equal

BTW, I have not figured out yet know how to print a HALF (without converting it back of course). Anyone?

Siekmanski

  • Member
  • *****
  • Posts: 1646
Re: Convert REAL4 to HALF
« Reply #1 on: September 13, 2018, 01:44:54 AM »
HALF values are equal  :t
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 8735
  • Assembler is fun ;-)
    • MasmBasic
Re: Convert REAL4 to HALF
« Reply #2 on: September 13, 2018, 01:55:37 AM »
On my Core i5-2450M, vcvtps2ph xmm1, xmm0 is an illegal instruction.

AW

  • Member
  • *****
  • Posts: 1483
  • Let's Make ASM Great Again!
Re: Convert REAL4 to HALF
« Reply #3 on: September 13, 2018, 02:48:16 AM »
On my Core i5-2450M, vcvtps2ph xmm1, xmm0 is an illegal instruction.

You need an Ivy Bridge or later.

FORTRANS

  • Member
  • *****
  • Posts: 1016
Re: Convert REAL4 to HALF
« Reply #4 on: September 13, 2018, 03:47:31 AM »
Hi,

   Intel Core i3 4005U.

HALF values are equal

Steve N.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5762
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Convert REAL4 to HALF
« Reply #5 on: September 13, 2018, 04:29:38 PM »
Haswell E/EP

HALF values are equal
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

daydreamer

  • Member
  • ****
  • Posts: 531
  • reach for the stars
Re: Convert REAL4 to HALF
« Reply #6 on: September 15, 2018, 12:15:07 AM »
As a follow up of this, I present here 2 methods of converting 1 REAL4 to 1 HALF, the VCVTPS2PH method and the no-VCVTPS2PH method.
The first one is the best but may not work on all computers.
I compare if the result obtained from both methods yields the same result. It does  :biggrin: (in this case)

BTW, I have not figured out yet know how to print a HALF (without converting it back of course). Anyone?
doesnt work
I Think its more interesting to be able to store twice the amount meshes in a demo
isnt it actually what you get from importing 3d files,double values in ascii->half's much smaller?

Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*

AW

  • Member
  • *****
  • Posts: 1483
  • Let's Make ASM Great Again!
Re: Convert REAL4 to HALF
« Reply #7 on: September 15, 2018, 12:37:49 AM »
Now, I will not use the modern instructions, some people still has pre- Ivy Bridge computers, and will print the HALF by converting it back and consider 4 significant digits (it has 3/4 significant digits), by luck in this case the 4th digit is still valid.

Code: [Select]
REAL4 Value=1.234567
HALF Value=1.234

@daydream
All depends on what you have in mind

Siekmanski

  • Member
  • *****
  • Posts: 1646
Re: Convert REAL4 to HALF
« Reply #8 on: September 15, 2018, 01:05:05 AM »
Nice  :biggrin:

Daydreamer, to compress vertex data, use "vertex subdivision" and convert the data to half floats  ( the files will be incredible small ).
Creative coders use backward thinking techniques as a strategy.

daydreamer

  • Member
  • ****
  • Posts: 531
  • reach for the stars
Re: Convert REAL4 to HALF
« Reply #9 on: September 15, 2018, 04:10:08 AM »
Now, I will not use the modern instructions, some people still has pre- Ivy Bridge computers, and will print the HALF by converting it back and consider 4 significant digits (it has 3/4 significant digits), by luck in this case the 4th digit is still valid.

Code: [Select]
REAL4 Value=1.234567
HALF Value=1.234

@daydream
All depends on what you have in mind
Would be nice to add aircraft meshes and other meshes as small  together in my project with procedural terrain making
Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*