anscheinend habe ich ein interessanten Bug in PB gefunden oder mein Prozessor weiß langsam nicht mehr wie es Bytecode ausführen soll wobei ich das 2. eher ausschließen kann
Code: Alles auswählen
;/
;/ Offset für Alle Librarys muss so berechnet werden. Urprogramm+Library(+Library)
;/ wobei sämtliche Funktion aus den Librarys in ihren Offsets mit berückscihtigt werden.
;/ Ein Beispiel:
;/ Library XYZ: Startet am offset 54.
;/ Dann muss die erste Funktion den Offset 54 haben.
;/ Die 2. Library hat dann den Offset LibraryXYZ+Funktion1
;/ und so weiter.
Structure sLibrary ;/ Library Pool aller verfügbaren Librarys
libAutor.s ; Autor der Library
libName.s ; Name der Library
libStart.l ; Startoffset der Library
libStopp.l ; Stoppoffset der Library
libSize.l ; Die größe der Library. NUR DIREKTER BYTECODE
libLibrary.l ; Pointer zum LibraryCode
EndStructure
Structure sLibFunktion ;/ Funktionpool aller Funktionen in den Librarys
fnkName.s ; Name der Funktion
fnkCall.l ; Offset der Funktion
fnkSize.l ; Funktiongröße. Wichtig für das Offset berechnen.
fnkOwn.l ; Zu welcher Lib diese Funktion gehört
EndStructure
Global WorkFile.l
Global DisAsmPtr.l
Global DisAsmPos.l
NewList LibraryPool.sLibrary()
NewList FunctionPool.sLibFunktion()
Procedure ReadLibrary(strLibName.s)
DefType.l LibHandle, ptrLibrary, ptrOrginal
DefType.l LibHeadStart, LibHeadStopp
LibHandle = ReadFile(#PB_Any, strLibName)
If LibHandle <> 0
ptrLibrary = AllocateMemory(Lof())
ReadData(ptrLibrary, Lof())
CloseFile(LibHandle)
If PeekS(ptrLibrary) = "FireBasicLib"
ptrOrginal = ptrLibrary
ptrLibrary+(Len(PeekS(ptrLibrary))+1)
AddElement(LibraryPool())
LibraryPool()\libName = PeekS(ptrLibrary): ptrLibrary + (Len(PeekS(ptrLibrary))+1)
LibraryPool()\libAutor = PeekS(ptrLibrary): ptrLibrary + (Len(PeekS(ptrLibrary))+1)
LibraryPool()\libStart = PeekL(ptrLibrary): ptrLibrary + 4
LibraryPool()\libStopp = PeekL(ptrLibrary): ptrLibrary + 4
LibraryPool()\libSize = LibraryPool()\libStopp - LibraryPool()\libStart
LibraryPool()\libLibrary = AllocateMemory(LibraryPool()\libSize)
CopyMemory(ptrOrginal + LibraryPool()\libStart, LibraryPool()\libLibrary, LibraryPool()\libSize)
LibHeadStart = PeekL(ptrLibrary)+ptrOrginal: ptrLibrary + 4
LibHeadStopp = PeekL(ptrLibrary)+ptrOrginal: ptrLibrary + 4
Repeat
AddElement(FunctionPool())
FunctionPool()\fnkName = PeekS(LibHeadStart): LibHeadStart + (Len(PeekS(LibHeadStart))+1)
FunctionPool()\fnkCall = PeekL(LibHeadStart): LibHeadStart + 4
FunctionPool()\fnkOwn = ListIndex(LibraryPool())
Until LibHeadStart => LibHeadStopp
EndIf
EndIf
EndProcedure
WorkFile = ReadFile(#PB_Any, "WorkFile.txt")
While Eof(WorkFile) = #False
UseFile(WorkFile)
ReadLibrary(ReadString())
Debug "Added " + LibraryPool()\libName
Wend
CloseFile(WorkFile)
Debug "--------------------------"
WorkFile = CreateFile(#PB_Any, "Out.asm")
ForEach LibraryPool()
Debug "Processing " + LibraryPool()\libName
WriteStringN(" ; Library: " + LibraryPool()\libName)
DisAsmPtr = LibraryPool()\libLibrary
Repeat
DisAsmPos = DisAsmPtr
DisAsmPtr = DisASMCommand(DisAsmPtr)
If FindString(GetDisASMString(), "db 66h", 1)
WriteStringN(Right(GetDisASMString(), Len(GetDisASMString())-FindString(GetDisASMString(), "db 66h", 1)))
Debug Right(GetDisASMString(), Len(GetDisASMString())-FindString(GetDisASMString(), Chr(13), 1))
;Debug Asc(Mid(GetDisASMString(), Len("db 66h")+1, 1))
Debug Len(GetDisASMString()) - FindString(GetDisASMString(), Chr(13), 1)
Debug Len(GetDisASMString())
Debug FindString(GetDisASMString(), Chr(13), 1)
Else
WriteStringN(GetDisASMString())
EndIf
Until DisAsmPtr >= (LibraryPool()\libSize+LibraryPool()\libLibrary)
Next
CloseFile(WorkFile)Code: Alles auswählen
Debug Len(GetDisASMString()) - FindString(GetDisASMString(), Chr(13), 1)
Debug Len(GetDisASMString())
Debug FindString(GetDisASMString(), Chr(13), 1)