Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define fbc -x rbsc.exe
- #inclib "Compiler-DLL"
- #include "../include/opcode.bi"
- Extern "windows-ms"
- Declare Function BuildBinary(sSource as String, iFileSz as integer, pDestination as Opcode ptr) as integer
- End Extern
- Dim as String sSourceFile = lCase(Command)
- Dim as String sOutputFile
- var sExtension = Right(sSourceFile, 4)
- if (sExtension = ".rbs") orElse (sExtension = ".txt") then
- sOutPutFile = left(sSourceFile, Len(sSourceFile)-3)+"rbc" ' Change extension to .rbc
- else
- sOutPutFile = sSourceFile+".rbc"
- end if
- if Open (sSourceFile for binary access read as #1) Then
- Print "Error opening source file!"
- System
- End If
- If Open (sOutputFile for binary access write as #2) then
- Print "Error opening output file!"
- System
- End If
- ' Read source into memory
- Dim as string sSrcBuff
- Dim as integer iFileSz
- iFileSz = LOF(1) ' Get file length
- sSrcBuff = Space(iFileSz) ' Read file into string buffer
- Get #1,, sSrcBuff
- Close #1
- ' Call compiler to build source
- Dim Shared as Opcode Bytecode(65535)
- var iTotalInstructions = BuildBinary(sSrcBuff, iFileSz, @Bytecode(0))
- Color 7
- 'Write binary to file
- var pBytecode = @Bytecode(0).Opcode
- Put #2, 1, *pBytecode, iTotalInstructions * (sizeof(Opcode) / 2)
- Close #2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement