Hi Theo,
Below is the example interface for PB. I wanted to keep the strings as generic as possible, so source code and file specs are passed to Oxygen in zstrings/asciiz. Oxygen then returns a pointer to a buffer containing the result string. O2_len() returns the length of this string. This method will work on any platform, since it does not assume a BSTR. This inferface can be wrapped to make it look simpler but this example shows the raw details which are not too burdensome.
I agree about new codes being frequently developed. We could provide a soft-coding for all the extension instructions - a small datafile that would allow new instructions to be added. The 'grammar' of the recent extensions is simpler than that of the base instruction set, so that would be quite easy, and may help to improve the performance of the assembler.
My top priority at the moment is to continue refining the test program - about 1200 checks so far - then it will be safe to beef up the program.
' OxygenTestPB.bas
' Oxygen Assembler 'Asmosphere' project
' Charles E V Pegge
' 19 April 2008
'PB interface
MACRO zstring=ASCIIZ
DECLARE FUNCTION o2_asm LIB "oxygen.dll" ALIAS "o2_asm" (zstring) AS STRING ' assemble
DECLARE FUNCTION o2_link LIB "oxygen.dll" ALIAS "o2_link" (zstring) AS STRING ' o2 link **
DECLARE FUNCTION o2_view LIB "oxygen.dll" ALIAS "o2_view" (zstring) AS STRING ' o2 coding
DECLARE FUNCTION o2_asm_file LIB "oxygen.dll" ALIAS "o2_asm_file" (zstring) AS STRING ' assemble from file
DECLARE FUNCTION o2_view_file LIB "oxygen.dll" ALIAS "o2_view_file" (zstring) AS STRING ' o2 coding from file
DECLARE FUNCTION o2_error LIB "oxygen.dll" ALIAS "o2_error" () AS STRING ' error message if any
DECLARE FUNCTION o2_len LIB "oxygen.dll" ALIAS "o2_len" () AS LONG ' length of returned string
' ** o2_link is automatically called by o2_asm when the assembly is successful.
FUNCTION PBMAIN()
DIM p AS BYTE PTR
DIM src AS STRING
DIM cod AS STRING
DIM lst AS STRING
DIM erm AS STRING
DIM r AS LONG
DIM i AS LONG
src="inc eax"+$CR+"ret" ' minimal source code
lst=LEFT$(o2_view((src)),o2_len()) ' view assembled code
cod=LEFT$(o2_asm((src)),o2_len()) ' compile code string
erm=LEFT$(o2_error(),o2_len()) ' check for any error
IF erm="" THEN
i=41
p=STRPTR(cod) ' get pointer to code string
! mov eax,i ' pass a parameter
! call p ' execute code ' call the code
! mov r,eax ' store the result
END IF
MSGBOX "Result:"+STR$(r)+$CR+$CR+lst
FUNCTION=0
END FUNCTION