PB compiler option /commented
Code: Select all
RET
Code: Select all
RET
HLT
HLT
HLT
HLT
on the Intel Haswell Skylake KabyLake cores
- Improved Display quality
- Improved Sound quality
- Improved Process reliability
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$)