Calling opcode string discussion
#14
On the Asm function question, I think you create labels then peek between the two CODEPTRs to get the binary.
You can start with something really simple to check you have a viable system

Code:
MyFun:
! mov eax,12345 'integer return value
! ret
EndMyFun:

'TESTING IN SITU:
DIM p as DWORD
DIM result as LONG
p=CODEPTR(MyFun)
DECLARE FUNCTION ReturnSome() AS LONG
CALL DWORD p USING ReturnSome() TO result '12345
using parameters: (adding 2 longs)
Code:
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 as long
dim y as long
dim r as long
dim p as dword
x=121
y=2
p=codeptr(MyFun)
DECLARE FUNCTION add2longs(BYVAL x as long, BYVAL y as long) AS long
call dword p using add2longs(x,y) to r '123

I hope this demonstrates the basics adequately . This is not tested PB code. I have not used PB for a very long time!

My colleague Roland Stowasser did a nuber of Dialog demos. They are all in OxygenBasic.zip in the demos\WinDynDialogs folder.

Here is one called DDTequiv.o2bas

Code:
'http://www.garybeene.com/power/pb-tutor-controls-imgbuttonx.htm

'This short example creates a complete application with a single imgbuttonx control.
'When clicked, the imgbuttonx control responds with a message.
'This tutorial page discusses most of the statements used,
'however the DDT, Controls, Messages, and Callback tutorials provide
'background information that may be helpful in understanding the example.
/*
   #Compile Exe
   #Resource "pb-test.pbr"
   Global hDlg As Dword
   Function PBMain() As Long
      Dialog New Pixels, 0, "ImgButtonX Test",300,300,200,200, _
                                      %WS_SysMenu, 0 To hDlg
      Control Add ImgButtonX, hDlg, 100,"cowgirl", 50,50,100,100
      Dialog Show Modal hDlg Call DlgProc
   End Function

   CallBack Function DlgProc() As Long
      If Cb.Msg = %WM_Command And Cb.Ctl = 100 And _
                        Cb.CtlMsg = %BN_Clicked Then
         MsgBox "Pushed!"
      End If
   End Function
*/

'====================================================================
' Simple modal dialog as main.
'====================================================================

$ filename "DDTequiv.exe"
'uses rtl32
'uses rtl64

'% review

uses dialogs
  
#define IDD_DLG1 1000
#define IDC_BTN1 1001

==============================================

'MAIN CODE
=============================================

'dim nCmdline as asciiz ptr, hInstance as sys
'&nCmdline = GetCommandLine
'hInstance = GetModuleHandle(NULL)


function DialogProc( sys hDlg, uint uMsg, sys wParam, lParam ) as int callback
  float pixelX, pixelY

  sys Button=GetDlgItem(hDlg, IDC_BTN1)
        
  select case uMsg

    case WM_INITDIALOG
       RECT rc = {0, 0, 4, 8}
       MapDialogRect (hDlg, @rc)
       PixelX = rc.right/4
       pixelY = rc.bottom/8
        

       int width=65*pixelX
       int height =65*pixelY
       sys hBmp=LoadImage(hDlg,"mask2.bmp",IMAGE_BITMAP, width,height, LR_LOADFROMFILE )
       SendMessage (Button, BM_SETIMAGE, IMAGE_BITMAP, hBmp)

      return true

    case WM_COMMAND
      select case loword(wParam)
        case 1001
           mbox "Pushed!"
          
        case IDCANCEL
           EndDialog( hDlg, null )
      end select
    
    case WM_CLOSE
      EndDialog( hDlg, null )
              
  end select

  return 0
end function

sub winmain()

  Dialog( 10,10,130,130, "ImgButton Test",
          WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU or DS_CENTER or DS_SETFONT,
          8,"MS Sans Serif" )
  CONTROL "IDC_BTN",IDC_BTN1,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP or BS_BITMAP or WS_DLGFRAME,32,32,65,65

  CreateModalDialog( null, @DialogProc, 0 )
end sub

winmain()

Quote: what is this JIT binaries ? Does JIT means Just in Time ?

Programs can be run directly from source code in memory without producing a binary. Instead, the compiled image is assigned to allocated memory and executed directly. Just in Time Smile. Saves a lot of EXE clutter for small to medium sized programs.
https://github.com/Charles-Pegge/OxygenBasic
https://forum.it-berater.org/index.php
Reply


Messages In This Thread
RE: Calling opcode string discussion - by Charles Pegge - 02-05-2025, 09:40 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)