Compare commits

..

3 commits
dev ... main

Author SHA1 Message Date
kake26
56fc5e1e15 Update 'LICENSE'
Fixing license values
2022-11-18 22:50:33 +00:00
kake26
cd12c5ee5b Update 'README.md' 2022-08-31 03:58:07 +02:00
kake26
3a327c7195 Update 'README.md'
Updating readme with some info
2022-08-31 03:56:57 +02:00
5 changed files with 3 additions and 153 deletions

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) <year> <copyright holders> Copyright (c) 2022 Paul Malcher
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -1,7 +1,7 @@
# vmbc # vmbc
A bytecode compiler and VM. Based on very old code thats been dusted off. I'm not sure exactly what I will use this for just yet, but it is interesting to dabble with this again. A bytecode compiler and VM. Based on very old code thats been dusted off.
# Notes # Notes
This program is written in PureBasic and will require it to be compiled from source. Currently, this is more of a proof of concept type thing and I'll figure out how to make this even better. I'm not sure what its current encarnation will be used for however, that remains to be seen for now. This program is written in PureBasic and will require it to be compiled from source. Currently, this is more of a proof of concept type thing and I'll figure out how to make this even better. I'm not sure what its current encarnation will be used for however, that remains to be seen for now. Please note there are two branches for this the main one and then dev. You will need to specifically checkout dev if you want to play around with the code.

BIN
test.byc

Binary file not shown.

90
vm.pb
View file

@ -1,90 +0,0 @@
; vm
Structure opi
code.l
args.s
EndStructure
; In theory this is a byte code interpreter
; Also mad science and may not work
Procedure writeblock (fid, *opco.opi)
; used by compile to write compiled code to file
WriteByte(fid, *opco\code)
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)
; should not need to be explained
*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 = "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)
EndSelect
;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 = vm

60
vm2.pb
View file

@ -1,60 +0,0 @@
; vm
Structure opi
code.l
args.s
dat.s
EndStructure
; In theory this is a byte code interpreter
; Also mad science and may not work
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, MemorySize(@*opco\args))
WriteLong(fid, Len(*opco\dat))
WriteData(fid, @*opco\dat, MemorySize(@*opco\dat))
EndProcedure
Procedure readblock (fid, *opci.opi)
; should not need to be explained
*opci\code = ReadByte(fid)
*opci\args = Space(ReadLong(fid))
ReadData(fid, @*opci\args, MemorySize(@*opci\args))
*opci\dat = Space(ReadLong(fid))
ReadData(fid, @*opci\dat, MemorySize(@*opci\dat))
EndProcedure
;for demo purposes we hard wire the code
opcobj.opi\code = $01
opcobj.opi\args = "Hi world"
opcobj.opi\dat = "Bye world!"
; now write bytecode to file
OpenFile(0,"test.byc")
writeblock(0, opcobj)
CloseFile(0)
; now read
OpenFile(1,"test.byc")
readblock(1, opcoobj.opi)
CloseFile(1)
;run
Select opcoobj\code
Case $01 : MessageRequester("ouput",opcoobj\dat)
EndSelect
; IDE Options = PureBasic 6.00 LTS (Linux - x64)
; CursorPosition = 35
; Folding = -
; EnableXP