02-05-2025, 05:27 PM
(This post was last modified: 02-05-2025, 05:35 PM by Charles Pegge.)
This code is written and tested in OxygenBasic. I don't normally capitalize but as a demo, this makes the keywords obvious. It could be used for generating any opcode strings. I will add it to the \tools folder. You can see the differences with PowerBasic, For instance '@' instead of CODEPTR.
I should add that you can work with floats, and potentially API calls depending on how Bob maps them into the system. The calls are usually from a table of absolute addresses.
Oxygen comes with 2 mini IDES:
Oxide is considered rather primitive, but it is a demo and could be useful for anyone to expand.
Peroxide is really bare-metal but with very strong keyword search. It is my personal tool for managing Oxygen code
But for simple programming Notepad does the job, particularly for JIT where you just click on any .o2bas source file to run.
Pierre has expertise on IDEs. Is it UltraEdit?
I should add that you can work with floats, and potentially API calls depending on how Bob maps them into the system. The calls are usually from a table of absolute addresses.
Oxygen comes with 2 mini IDES:
Oxide is considered rather primitive, but it is a demo and could be useful for anyone to expand.
Peroxide is really bare-metal but with very strong keyword search. It is my personal tool for managing Oxygen code
But for simple programming Notepad does the job, particularly for JIT where you just click on any .o2bas source file to run.
Pierre has expertise on IDEs. Is it UltraEdit?
Code:
'05/02/2025
USES CONSOLE
'
GOTO TESTING
MyFun:
mov eax,[esp+8] 'x
add eax,[esp+4] 'y
ret 8
' dump 8 bytes of params and then return
EndMyFun:
TESTING:
========
DIM x,y AS LONG
x=121
y=2
DECLARE FUNCTION PTR add2longs(BYVAL x AS LONG, BYVAL y AS LONG) AS LONG
@add2longs=@MyFun 'link addresses
'TEST THE FUNCTION:
PRINT "test result: " add2longs(x,y) CR CR '123 ok
'
'CAPTURE BINARY STRING
'
DIM le AS LONG = @EndMyFun-@MyFun
DIM bins AS STRING = SPACE(le)
COPY STRPTR(bins), @MyFun,le
PRINT le CR '11 bytes
PRINT CR
'
'CHECK CAPTURED OPCODES
'
INDEXBASE 1
DIM i AS LONG
DIM byte PTR bt : @bt=STRPTR(bins)
FOR i=1 TO le
PRINT HEX(bt[i],2) " "
NEXT
PRINT CR CR
'result 8B 44 24 08 03 44 24 04 C2 08 00
'
'SAVE THE BIN STRING TO FILE
'
PRINT "Enter FileName to Save: "
STRING s=INPUT()
s=LTRIM(RTRIM(S))
IF s
PUTFILE(s,bins)
PRINT "ok"
WAIT
ENDIF
https://github.com/Charles-Pegge/OxygenBasic
https://forum.it-berater.org/index.php
https://forum.it-berater.org/index.php