QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: NOVARSEG on November 17, 2020, 08:26:38 pm

Title: Will this work?
Post by: NOVARSEG on November 17, 2020, 08:26:38 pm
Can QB64 compile this?

**** Quick Basic source code

CALL  trythis   ' a label in assembler
****

****the assembler code  (example A86 assembler)

trythis:
RETF
****

****Quick Basic source code
PRINT "we made it back!!"
end
****
A86 will produce an object file from the assembler code.  Does QB64 support "CALL label " where the label is in assembler code.
Title: Re: Will this work?
Post by: SMcNeill on November 17, 2020, 09:06:05 pm
Nope.
Title: Re: Will this work?
Post by: _vince on November 19, 2020, 07:20:10 pm
If you're interested, freebasic's got it all:  https://www.freebasic.net/wiki/KeyPgAsm (https://www.freebasic.net/wiki/KeyPgAsm)
Title: Re: Will this work?
Post by: NOVARSEG on November 19, 2020, 07:35:10 pm
OK thanks
It looks like inline ASM.

I think the CPU must be in virtual mode (VM) to apply the real mode x86 instruction rules so are real mode x86  ASM in  freebasic a problem?
Title: Re: Will this work?
Post by: NOVARSEG on November 19, 2020, 07:49:03 pm
I can see problems arising since the DS selector value must be derived from  freebasic at compile time?

If DS selector value is known then just a matter of using say EAX for memory addressing so a real mode x86  address needs to be converted to a protected mode address. I guess?
Title: Re: Will this work?
Post by: _vince on November 19, 2020, 08:17:59 pm
There is no real mode with freebasic.  Even freebasic for DOS runs in 32 bit protected mode requiring at least a 386
Title: Re: Will this work?
Post by: Cobalt on November 19, 2020, 11:08:21 pm
Most the time, anymore, stuff like that is simply emulated or workarounds cause modern OSes don't want to allow you to access low level actions like that anymore.
Title: Re: Will this work?
Post by: NOVARSEG on November 20, 2020, 02:14:33 am
Cobalt
yep because the OS makers don't want others to control the machine.
Title: Re: Will this work?
Post by: NOVARSEG on November 20, 2020, 02:19:58 am
Vince

That's Ok as long as the ASM code addresses are protected mode ones

32 bit registers and 32 bit addressing can be done in 16 bit assembler like A86 with the 66h and 67h opcode prefixes. I've done that. Tricky though.