In file included from qbx.cpp:2208:It is looking for a literal string, terminated in quotes, not a variable (according to people on Stack Overflow). Even if we try with an actual string, terminated in quotes, we get this:
..\\temp\\main.txt: In function 'void QBMAIN(void*)':
..\\temp\\main.txt:7:5: error: expected string-literal before '(' token
asm((char*)(__STRING_ASMSTRING)->chr);
^
compilation terminated due to -Wfatal-errors.
In file included from qbx.cpp:2208:I don't see how we'd be able to use this function/sub in QB64 unless Dav, or SMcNeil have an idea.
..\\temp\\main.txt: In function 'void QBMAIN(void*)':
..\\temp\\main.txt:7:5: error: expected string-literal before '(' token
asm((char*)(qbs_add(qbs_add(func_chr( 34 ),qbs_new_txt_len("movl, %ebx, %eax",16)),func_chr( 34 )))->chr);
^
compilation terminated due to -Wfatal-errors.
I'm kind of thinking that it won't work due to the nature of QB64's translation into C.Thats exactly what i was thinking after i looked in to the compile logs like you have.
I think it might be possible with a wrapper that converts the qb64 string into a cstringNow that I think about it, RhoSigma made a library that can be found here:https://www.qb64.org/forum/index.php?topic=809.0 (https://www.qb64.org/forum/index.php?topic=809.0)
hi guys
but if do you like to play with ASM (MASM/TASM?) I think you must follow the QB style like showed by TheBob in his programsCode: QB64: [Select]
DEFINT A-Z
DECLARE SUB mouse (ax, mb, mx, my)
DIM SHARED m(7) AS LONG
m(0) = &H8BE58955
m(1) = &H48B0C76
m(2) = &H768B33CD
m(3) = &H8B1C890A
m(4) = &HC890876
m(5) = &H8906768B
m(6) = &H8CA5D14
SCREEN 12
mouse 0, mb, mx, my 'reset mouse driver
mouse 1, mb, mx, my 'show mouse cursor
DO
'get mouse state
mouse 3, mb, mx, my
'print mouse coordinates
LOCATE 1, 1: PRINT mb, mx, my
LOOP UNTIL INP(&H60) = 1
SYSTEM
SUB mouse (ax, mb, mx, my)
DEF SEG = VARSEG(m(0))
CALL absolute(ax, mb, mx, my, VARPTR(m(0)))
END SUB
This has little to do with assembly, this is the old VGA ports method of setting the palette. Here is equivalent QB64 code:Code: QB64: [Select]
or in cabsmous.bas that you find in the example of QB64 packageHere, instead of DATA statements they use POKE...VARPTR, so much text. At least they used an integer array for storageCode: QB64: [Select].
'Mouse utilities for text mode. Written by TFM 9/11/94 'Uses INT 33 to use a Microsoft Compatable mouse driver 'Written in basic calling an assembly language routine. 'Works in normal basic CALL initmouse CALL showmouse CALL getxymouse 'Store current positon in globals 'This isn't needed coz pressmouse(1) 'Already does it, but it is an example 'Display position, stored in global variables PRINT "*"; PRINT " "; SUB getxymouse mousex = (cx / 8) + 1 mousey = (dx / 8) + 1 button = bx mousebutton1 = 0: mousebutton2 = 0 mousebutton1 = 1: mousebutton2 = 0 mousebutton1 = 0: mousebutton2 = 1 mousebutton1 = 1: mousebutton2 = 1 PRINT "Sorry no mouse found" SUB hidemouse mousevisible = 0 PRINT "Sorry no mouse found" PRINT "Sorry no mouse found" CALL getxymouse inbox = 1 inbox = 0 PRINT "Sorry no mouse found" inboxpress1 = 1 inboxpress1 = 0 PRINT "Sorry no mouse found" inboxpress2 = 1 inboxpress2 = 0 PRINT "Sorry no mouse found" inboxrelease1 = 1 inboxrelease1 = 0 PRINT "Sorry no mouse found" inboxrelease2 = 1 inboxrelease2 = 0 PRINT "Sorry no mouse found" SUB initmouse mousepassed = 1 mousepassed = 0 n1 = 0: n2 = 0: n3 = 0: n4 = 0 m1 = m1 - 255 n1 = n1 + 1 m2 = m2 - 255 n2 = n2 + 1 m3 = m3 - 255 n3 = n3 + 1 m4 = m4 - 255 n4 = n4 + 1 mousex = newx mousey = newy PRINT "Illegal mouse position!!!"; PRINT "Sorry no mouse found" mousex = (cx / 8) + 1 mousey = (dx / 8) + 1 PRINT "Sorry no mouse found" mousex = (cx / 8) + 1 mousey = (dx / 8) + 1 PRINT "Sorry no mouse found" SUB showmouse mousevisible = 1 PRINT "Sorry no mouse found" PRINT "Sorry no mouse found"
My new philosophy is to let QB64 be what the community want it to be. Even if we end up with 1000s of commands that barely get used by the majority, it is better than QB64 not being used at all. And if someone implements something incredibly stupid/unnecessary (such as a _HELLOWORLD command) the beauty of a repository is that it can always be rolled back later. Because of this philosophy, you won't see me standing in the way of any changes.
No more support for old ways to access to low level of machine, expecially if it exhumes 16 bit structures.
void myfun(double *x)
{
asm (
"fldpi \n"
"movq %[x], %%rax \n"
"fstpl (%%rax) \n"
:[x]"=m"(x)
:
:
);
}
double myfun2(void)
{
double x;
asm (
"fldpi \n"
"leaq %[x], %%rax \n"
"fstpl (%%rax) \n"
:[x]"=m"(x)
:
:
);
return x;
}
' cinclude.h needs to be in QB64 folder
DECLARE CUSTOMTYPE LIBRARY ".\cinclude"
SUB myfun (x AS DOUBLE)
FUNCTION myfun2# ()
END DECLARE
DIM x AS DOUBLE
DIM y AS DOUBLE
CALL myfun(y)
PRINT y
x = myfun2
PRINT x