HLT HLT HLT HLT after RET

Bare metal programming in PureBasic, for experienced users
User avatar
oryaaaaa
Enthusiast
Enthusiast
Posts: 791
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

HLT HLT HLT HLT after RET

Post by oryaaaaa »

I made Nontallion ver8.72 this week. just technique is "HLT HLT HLT HLT after RET".

PB compiler option /commented

Code: Select all

RET
just add HLT HLT HLT HLT

Code: Select all

RET
HLT
HLT
HLT
HLT
and /REASM compiled.

on the Intel Haswell Skylake KabyLake cores
  • Improved Display quality
  • Improved Sound quality
  • Improved Process reliability
maybe... I think "Intel inside micro OP code don't run low energy optimize!"

Test Build utility

Code: Select all

file$=OpenFileRequester("PB", "*.pb", "*.pb", 0)
dir$ = GetPathPart(file$)
DeleteFile(dir$+"PureBasic.asm")

If file$ And FileSize(file$)>0
  Compiler = RunProgram(#PB_Compiler_Home+"\Compilers\pbcompiler", Chr(34)+file$+Chr(34)+" /MMX /UNICODE /commented", dir$, #PB_Program_Open | #PB_Program_Read); *** 3 
  dir$+"PureBasic.asm"
  
  ooos.i = 0
  Output$ = ""
  If Compiler
    While ProgramRunning(Compiler)
      If AvailableProgramOutput(Compiler)
        If ooos%2 = 1
          Output$ + ReadProgramString(Compiler) + Chr(13)
        Else
          Output$ + ReadProgramString(Compiler) + Space(2)          
        EndIf
        ooos + 1
      EndIf
    Wend
    Output$ + Chr(13) + Chr(13)
    Output$ + "Exitcode: " + Str(ProgramExitCode(Compiler))
    
    CloseProgram(Compiler) ; Close the connection to the program
  EndIf
Else
  MessageRequester("Error!", "There was an error creating the assembly code file.")
EndIf

Global NewList Buffer.s()

If ReadFile(2, dir$)
  While Eof(2)=0
    AddElement(Buffer())
    Buffer() = ReadString(2)
  Wend
  CloseFile(2)
EndIf

ForEach Buffer()
  If FindString(Buffer(), " RET")
    PreviousElement(Buffer())
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    NextElement(Buffer()) ; RET
    AddElement(Buffer()) : Buffer() = "HLT"
    AddElement(Buffer()) : Buffer() = "HLT"
    AddElement(Buffer()) : Buffer() = "HLT"
    AddElement(Buffer()) : Buffer() = "HLT"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
  EndIf
Next

; *** MOV to MOVNTI : disable CPU cache *** It is a bonus
;
; Global NS_Find_1.i, NS_Find_2.i, NS_Find_3.i, NS_Find_4.i, NS_Find_5.i
; ForEach Buffer()
;   NS_Find_1 = FindString(Buffer(), "MOV ")
;   If NS_Find_1
;     NS_Find_2 = FindString(Buffer(), "[PB_")
;     NS_Find_3 = FindString(Buffer(), ",")
;     If NS_Find_2>0 And NS_Find_3>0 And NS_Find_2<NS_Find_3
;       Buffer() = ReplaceString(Buffer(), "MOV", "MOVNTI")
;     EndIf 
;   EndIf
; Next
; 
; ForEach Buffer()
;   NS_Find_1 = FindString(Buffer(), "MOV ")
;   If NS_Find_1
;     NS_Find_2 = FindString(Buffer(), "[")
;     NS_Find_3 = FindString(Buffer(), ",")
;     NS_Find_5 = FindString(LCase(Buffer()), "qword")
;     If Not NS_Find_5
;       NS_Find_5 = FindString(LCase(Buffer()), "dword")
;     EndIf
;     NS_Find_4 = FindString(LCase(Buffer()), "a", NS_Find_3)
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "b", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "c", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "d", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "p", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "i", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "r8", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "r9", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "r10", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "r11", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "r12", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "r13", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "r14", NS_Find_3)
;     EndIf
;     If Not NS_Find_4
;       NS_Find_4 = FindString(LCase(Buffer()), "r15", NS_Find_3)
;     EndIf
;     If NS_Find_2>0 And NS_Find_3>0 And NS_Find_2<NS_Find_3 And NS_Find_5>0 And NS_Find_4>0
;       Buffer() = ReplaceString(Buffer(), "MOV", "MOVNTI")
;     EndIf 
;   EndIf
; Next

CreateFile(2, dir$)
ForEach Buffer()
  WriteStringN(2, Buffer())
Next
FlushFileBuffers(2)
CloseFile(2)

ClearList(Buffer())
file$ = dir$
dir$ = GetPathPart(file$)

Compiler = RunProgram(#PB_Compiler_Home+"\Compilers\pbcompiler", Chr(34)+file$+Chr(34)+" /MMX /UNICODE /REASM /EXE "+Chr(34)+"Z:\TestBuild"+Str(Random(999999))+".exe"+Chr(34), dir$, #PB_Program_Open | #PB_Program_Read)
  If Compiler
    While ProgramRunning(Compiler)
      If AvailableProgramOutput(Compiler)
        Output2$ + ReadProgramString(Compiler) + Chr(13)
      EndIf
    Wend
    Output2$ + Chr(13) + Chr(13)
    Output2$ + "Exitcode: " + Str(ProgramExitCode(Compiler))
    
    CloseProgram(Compiler)
  EndIf

  MessageRequester("Output", Output$)
  MessageRequester("Output", Output2$) 
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: HLT HLT HLT HLT after RET

Post by djes »

I think we need a fiable program to evaluate the advantages.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: HLT HLT HLT HLT after RET

Post by chi »

I'm curious... Do you have a small demo to see/hear the improvement?
Et cetera is my worst enemy
User avatar
oryaaaaa
Enthusiast
Enthusiast
Posts: 791
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Re: HLT HLT HLT HLT after RET

Post by oryaaaaa »

check condition
You can't feel the effect unless you are a city along the coast.
You can’t feel in the supply area of nuclear power generation.
You can't check the effect unless you get nervous.

PB Example : Gadget.pb
It makes parts easier to see sharp.

I use this technique at Nontallion 8.72, Affeine 3.25 and All core any cures 21.4.
It is a sound player for ASIO output with the most correct sound.
Bug head 8.60, All core any cures 20.8, Affeine 3.19, Windows x64 AVX2, Installer & Zip [August2017 08/24 AM1]
x64 SSE 4.1 limited version included "Bug head 8.60, Affeine 3.19, All core any cures 20.8", Zip only
x64 AVX 2.0 Hi-legacy version included "Nontallion 8.72, Affeine 3.25, All core any cures 21.4", Zip & Installer
http://oryaaaaa.world.coocan.jp/bughead/

It is a story that the register stability is deteriorated from excessive pursuit of power saving and it is affected at the part involving DA conversion.
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: HLT HLT HLT HLT after RET

Post by Fig »

I Wonder if this is japanese sens of humour or if it's an automatic translation... Anyway, my city is on a coast so.... It makes me nervous :wink:
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: HLT HLT HLT HLT after RET

Post by Little John »

oryaaaaa wrote:I made Nontallion ver8.72 this week. just technique is "HLT HLT HLT HLT after RET".

PB compiler option /commented

Code: Select all

RET
just add HLT HLT HLT HLT

Code: Select all

RET
HLT
HLT
HLT
HLT
and /REASM compiled.
oryaaaaa wrote:check condition
You can't feel the effect unless you are a city along the coast.
You can’t feel in the supply area of nuclear power generation.
You can't check the effect unless you get nervous.
Ahhh, I see. Now everything is as clear as mud. :mrgreen:
Thorium
Addict
Addict
Posts: 1271
Joined: Sat Aug 15, 2009 6:59 pm

Re: HLT HLT HLT HLT after RET

Post by Thorium »

oryaaaaa is known for his controversial codes for quality improvement of sound and such.

Either he is a genius and understands something about how the universe works, that i and many just don't.
Or it's just plain nonsense.
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: HLT HLT HLT HLT after RET

Post by Bisonte »

Thorium wrote:oryaaaaa is known for his controversial codes for quality improvement of sound and such.

Either he is a genius and understands something about how the universe works, that i and many just don't.
Or it's just plain nonsense.
Or the google translator is the greatest rubbish thing to translate from JAP to ENG...
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
Thorium
Addict
Addict
Posts: 1271
Joined: Sat Aug 15, 2009 6:59 pm

Re: HLT HLT HLT HLT after RET

Post by Thorium »

Bisonte wrote: Or the google translator is the greatest rubbish thing to translate from JAP to ENG...
I don't think so.
We had some discussion prior to this one. He is serious.
There are even some theoretical possibilties to some of his claims. But it's mostly esoteric.

This discussion was interessting: www.purebasic.fr/english/viewtopic.php?f=12&t=64997
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: HLT HLT HLT HLT after RET

Post by Dude »

oryaaaaa wrote:You can't feel the effect unless you are a city along the coast.
You can’t feel in the supply area of nuclear power generation.
You can't check the effect unless you get nervous.
Okay, now I'm convinced. This says it all.
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: HLT HLT HLT HLT after RET

Post by walbus »

Snake Oil
Post Reply