Recent posts

#1
OxygenBasic Examples / Re: Msgbox asm
Last post by Frank Brübach - Today at 07:01:23 PM
Hi Charles again..

How I can add correct two numbers in 64 Bit Mode in this msgbox example?  Thx in advance , Frank

' 64 bit x86
'
$ FileName "test64add2number.exe"
#include "$\inc\RTL64.inc"

byte val1
byte val2
int result
   
    val1=4
    val2=6 '

     '' mov eax,val1 
     '' mov eax,val2  ''multiply eax by ebx  "
     '' mul val1 'ebx 
     '' mov result,eax


'------------------ //
     mov rax,rdi
     add rax, val2 
     'add val1 'rax,
     mov rdi,val1
     mov result,rax
'------------------ //

zstring tit[]="64Bit OxygenBasic"
zstring msg[]="Hello dear Animal World! " + str(result)

'' oxygen 64 bit
''
sub  rsp,40h
mov  r9,  0       
lea  r8,  tit   
lea  rdx, msg   
mov  rcx, 0
call messagebox       
add  rsp, 40h
''
'' output: Hello dear Animal World! 24

#2
PowerBasic Adventures / Power Basic forum maybe going ...
Last post by Paul Yuen - Today at 06:10:22 PM
Hi
Please take a look at https://forum.powerbasic.com/forum/announcements-articles-and-support-faqs/frequently-asked-questions/833672-powerbasic-website-and-forums#post833672

PB forum may be going dark very soon, as there is no management response to members' queries about future
stake of the PB forum.
#3
OxygenBasic Examples / Re: Type question
Last post by Charles Pegge - Today at 04:42:28 PM
Hi Frank,

I could not make sense of your example but in any case, you will need to specify the allocated char count of the zstring

type aStruct
    a as long
    b[16] as zstring
end type

#4
Code to share / Re: sizeof example
Last post by Frank Brübach - Today at 03:53:52 PM
Here is a little sizeof example

Print SizeOf(Byte) ' returns 1

Type mybar
    a As Integer '4
    b as float '4
    c as long '4
    d As Double '8
    e as ulong '4
    f as short '2
    g as byte '1
End Type

dim myfoo as mybar
print SizeOf(myfoo) ' returns 32
 
#5
OxygenBasic Examples / Type question
Last post by Frank Brübach - Today at 03:24:03 PM
Hello Charles,

Can I add a value and a String with a Type in a function?

type aStruct
    a as long
    b as zstring
end type

function one_add(long a,b) as long
dim st as aStruct

st.a = 5
st.b = "Thor"
return a+b

end function

function two_add(long a,b) as long
dim st as aStruct

st.a = 5
st.b = "Thor"
return st.a+str(st.b)

end function

print "one_add: " + one_add(2,4) ' result 6
print "two_add: " + two_add(2,4) ' result 50 ' ???

#6
OxygenBasic Examples / Re: CByte
Last post by Charles Pegge - Yesterday at 05:44:54 PM
some signed byte values:

0x7f -->  127
0x80 --> -128
0x81 --> -127
...
0xfe --> -2
0xff --> -1

0x104 modulo 0xff --> 4
#7
The entire food pyramid on planet Earth is cruel, unfortunately.


Some more stories:

strange Humanoids Around the World: Ten Eyewitness Accounts

Preston Dennett
20 apr 2024



Twelve Amazing Humanoid Encounters

Preston Dennett
18 may 2024

#8
Code to share / Re: halProment 64 Bit Test
Last post by Frank Brübach - Yesterday at 02:19:29 PM
Finally the big step to 64 Bit architecture
Thanks Charles for His great rtl32.inc and rtl64.inc Files :-)

All examples you can find in *.rar folder below
If you have any questions please ask thx, frank

'' -- halProment Basic 64 bit test, 26-5-24, 29-05-24, by frank bruebch
'' -- you must compile this example with menu compile/quickrun produces an exe file
''

$ FileName "test64-2.exe"
#include "$\inc\pro64.inc" ''

Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Sys

byte val1
byte val2
int result 
   
    val1=4
    val2=6 '

    'mov eax,val1 
    mov eax,val2  ''multiply (or add) eax by ebx  "
    'mul val1 'ebx
    add eax,5  '' here add 5
    mov result,eax

zstring tit[]="HalProment Basic 64 bit"
zstring msg[]="Hello dear Animal World! " + str(result)

'' halProment Basic 64 bit
''

sub  rsp,40h
mov  r9,  0     
lea  r8,  tit 
lea  rdx, msg 
mov  rcx, 0
call messagebox     
add  rsp, 40h
''
''
'' output: Hello dear Animal World! 11 (add) ' 24 (multiply)
''

#ifdef mode64bit
#print "Producing 64-bit code output"
print "Producing 64-bit code output"
#else
#print "Producing 32-bit code output"
#endif

'' result: "Producing 64-bit code output" ' all ok :-)


PS you can Download the latest Update under GitHub too
#9
Code to share / Re: Window GUI (SDK) hello ani...
Last post by Frank Brübach - Yesterday at 02:14:12 PM
Window winapi GUI (SDK)

  ' -- windows gui test, halProment, 19-05-2024 --
  '
  take diverprom
 
  '--------------------------------------------------------------------
  Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as pro
  '====================================================================

  WndClass wc
  MSG      wm

  sys hwnd, wwd, wht, wtx, wty, tax
  with wc
  .style = CS_HREDRAW or CS_VREDRAW
  .lpfnWndProc = @WndProc
  .cbClsExtra =0
  .cbWndExtra =0   
  .hInstance =inst
  .hIcon=LoadIcon 0, IDI_APPLICATION
  .hCursor=LoadCursor 0,IDC_ARROW
  .hbrBackground = GetStockObject WHITE_BRUSH
  .lpszMenuName = null
  .lpszClassName = strptr "Demo"
  end with
  sys r=RegisterClass (@wc)
 
  Wwd = 520 : Wht = 400
  Tax = GetSystemMetrics SM_CXSCREEN
  Wtx = (Tax - Wwd) /2
  Tax = GetSystemMetrics SM_CYSCREEN
  Wty = (Tax - Wht) /2
  '
  hwnd = CreateWindowEx 0,wc.lpszClassName,"HalProment Basic",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
  if not hwnd
    mbox "Unable to create window"
    exit function
  end if
  '
  ShowWindow hwnd,SW_SHOW
  UpdateWindow hwnd
  '
  sys bRet
  '
  do while bRet := GetMessage (@wm, 0, 0, 0)
    if bRet = -1 then
      'show an error message
    else
      TranslateMessage @wm
      DispatchMessage @wm
    end if
  wend
  end Function

  dim as rect crect

  '------------------------------------------------------------------
  function WndProc (pro hWnd, wMsg, wParam, lparam ) as pro callback
  '==================================================================

    static as pro hdc
    static as pstring txt
    static as PaintStruct Paintst
 
    '==========
    select wMsg
    '==========
       
      '--------------
      case WM_CREATE
      '=============
      GetClientRect hWnd,cRect

      '-------------- 
      case WM_DESTROY
      '===============
         
      PostQuitMessage 0
       
      '------------
      case WM_PAINT
      '============

      GetClientRect  hWnd, cRect
      hDC=BeginPaint hWnd, Paintst
      SetBkColor  hdc,black 'yellow
      SetTextColor hdc,green 'red
      DrawText hDC,"Hello Animal World!",-1,cRect,%DT_SINGLELINE or %DT_CENTER or %DT_VCENTER
      EndPaint hWnd,Paintst
      function = 1
 
      '-------------- 
      case WM_KEYDOWN
      '==============

      '============           
      Select wParam
      '============

    Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0      'ESCAPE

      End Select

      '--------       
      case else
      '========
         
        function=DefWindowProc hWnd,wMsg,wParam,lParam
       
    end select

  end function

'  WinMain inst,0,cmdline,SW_NORMAL  '' both lines are working
  WinMain 1,0,1,SW_NORMAL
#10
Code to share / Re: Array examples reducing St...
Last post by Frank Brübach - Yesterday at 02:11:02 PM
Array examples how to reduce a String Text

' array reducing for a string
'
pindex 0

Dim txt() as zstring = "Hello World " + Chr(0)
dim i as integer
 
For i = 0 to Len(txt)-2 ''Len(txt)-1 if pindex is not active
   
    p? txt(i) + Chr(txt(i))
Next

' output: hello world ello world llo world lo world o world
' output: world orld rld ld d