Update to recent 2022 version, adjusted for newer compiler version

This commit is contained in:
kake26 2022-08-30 17:33:39 -05:00
parent 5ff8534b96
commit 93555b6307
3 changed files with 103 additions and 8 deletions

51
vm.pb
View file

@ -12,8 +12,9 @@ EndStructure
Procedure writeblock (fid, *opco.opi)
; used by compile to write compiled code to file
WriteByte(fid, *opco\code)
WriteLong(fid, Len(*opco\args))
WriteData(fid, @*opco\args, Len(*opco\args))
WriteLong(fid, MemorySize(@*opco\args));Len(*opco\args))
WriteData(fid, @*opco\args, MemorySize(@*opco\args));Len(*opco\args)*2) using memorysize to make it work over a decade later because unicode
EndProcedure
Procedure readblock (fid, *opci.opi)
@ -21,35 +22,69 @@ Procedure readblock (fid, *opci.opi)
*opci\code = ReadByte(fid)
*opci\args = Space(ReadLong(fid))
ReadData(fid, @*opci\args, Len(*opci\args))
EndProcedure
;for demo purposes we hard wire the code
opcobj.opi\code = $01
opcobj.opi\args = "Hi world"
opcobj.opi\args = "Bacon ipsum dolor amet beef kevin turducken pork loin, jerky short loin sirloin alcatra doner."
; now write bytecode to file
OpenFile(0,"test.byc")
Debug("Before write " + Loc(0))
writeblock(0, opcobj)
Debug("After write " + Loc(0))
opcobjj.opi\code = $02
opcobjj.opi\args = "Hamburger pork chop pork, t-bone buffalo shank biltong fatback ham. Tail pork porchetta cupim, tenderloin jowl bacon bresaola alcatra strip steak andouille short ribs flank spare ribs chislic."
writeblock(0, opcobjj)
Debug("After write 2 " + Loc(0))
CloseFile(0)
; now read
OpenFile(1,"test.byc")
Debug("Before read " + Loc(1))
readblock(1, opcoobj.opi)
Debug("After read " + Loc(1))
readblock(1, opcoobjj.opi)
Debug("After read2 " + Loc(1))
CloseFile(1)
;run
Select opcoobj\code
Case $01 : MessageRequester("ouput",opcoobj\args)
Case $01 : MessageRequester("ouput",opcoobj\args)
EndSelect
; IDE Options = PureBasic 4.61 (Windows - x86)
; CursorPosition = 3
;Debug(opcoobjj\args)
Select opcoobjj\code
Case $02: MessageRequester("ouput",opcoobjj\args)
Default
MessageRequester("ouput",opcoobjj\args)
EndSelect
; IDE Options = PureBasic 6.00 LTS (Linux - x64)
; CursorPosition = 42
; FirstLine = 11
; Folding = -
; EnableXP
; Executable = ..\Desktop\vm.exe
; Executable = vm