QB64 Phoenix Edition
BIOS com port - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: BIOS com port (/showthread.php?tid=1956)



BIOS com port - eoredson - 09-02-2023

This function works well in QB45 but in QB64 return com port addresses as 0 and I would like to know why!?

Code: (Select All)
Color 15
Print "Hex addresses for ports 0 to 7 from BIOS."
Color 14
Def Seg = 0
For x = 0 To 7
    z = &H400 + x * 2
    p = Peek(z)
    q = Peek(z + 1)
    a = q * &H100 + p
    Select Case x
        Case 0
            Print " COM" + Str$(x + 1); ": " + Hex$(a); " IRQ 4"
        Case 1
            Print " COM" + Str$(x + 1); ": " + Hex$(a); " IRQ 3"
        Case 2
            Print " COM" + Str$(x + 1); ": " + Hex$(a); " IRQ 4"
        Case 3
            Print " COM" + Str$(x + 1); ": " + Hex$(a); " IRQ 3"
        Case 4
            z = 0: If a = 0 Then a = &H378: z = -1
            Print " LPT" + Str$(x - 3); ": " + Hex$(a); " IRQ 7";
            If z Then Print " (no bios)" Else Print
        Case 5
            z = 0: If a = 0 Then a = &H278: z = -1
            Print " LPT" + Str$(x - 3); ": " + Hex$(a); " IRQ 7";
            If z Then Print " (no bios)" Else Print
        Case 6
            z = 0: If a = 0 Then a = &H3BC: z = -1
            Print " LPT" + Str$(x - 3); ": " + Hex$(a); " IRQ 5";
            If z Then Print " (no bios)" Else Print
    End Select
Next
Def Seg
Color 7
End
Erik.


RE: BIOS com port - mnrvovrfc - 09-02-2023

Someone had close to the same request as you:

https://qb64phoenix.com/forum/showthread.php?tid=1895


RE: BIOS com port - eoredson - 09-04-2023

That is an interesting link to a post concerning port calls where of course:

Inp(1016) and Out(1016) reads and writes to the com port where 1016 is 0x3f8

but I was wondering how to read the port address from BIOS instead of hard-coding the actual port address.

using Peek(x). Thanks, Erik.


RE: BIOS com port - mnrvovrfc - 09-04-2023

You should know better than this. PEEK and POKE, with DEF SEG made the most sense on 16-bit. On 32-bit that began to break down because M$ didn't even want anyone using QuickBASIC and QBasic to use ABSOLUTE nor CALL INTERRUPT. On 64-bit there is even less of a chance to use anything from BIOS. On newer systems BIOS is being left out entirely, cannot use it to boot an operating system anymore. On those newer systems BIOS might have to be emulated.

PEEK does nothing useful these days except for a few areas used far more often than the old COM ports. Such as CGA/EGA video memory.

In later BASIC dialects PEEK and POKE are used toward a memory block allocated by the user. Pure Basic does it like this. That is payware but cannot emulate BIOS and cannot replicate the old interrupts like #9, #13, the large &H21 and others categorized for "advanced" programming in 16-bit back in the day.

For DEG SEG = 0, probably QB64 recognizes the keyboard buffer, but almost nothing else. Cannot even get SCREEN 0 rows and columns anymore like that. How to do that from the terminal under $CONSOLE:ONLY? Cannot check the state of the shift keys like that, must use _KEYDOWN instead.

In QB64 could use C++ code to hook up via USB. (shrugs)

Should be able to do it although writing for devices sucks a lot. Have to know about interfaces and hardware specifications and stuff like that. The other day I downloaded the source code for the Linux kernel v6.1.41. That comes with a few thousand files which have to cover a lot of possibilities. I have only begun wading through the documentation which is not for people having no understanding about electronics, computer engineering and things of that nature.


RE: BIOS com port - eoredson - 09-04-2023

Alright - so it's not a problem with my code. It is only not supported because M$ ditched 16-bit for 32-bit.

What a Pita. Erik.


RE: BIOS com port - SpriggsySpriggs - 09-06-2023

So what information are you actually trying to get from the BIOS?


RE: BIOS com port - bplus - 09-07-2023

I think MS getting away from BIOS because it is hackable so Anti-virus software isn't going to like exe programs going into BIOS either.

Not good programming idea for future, maybe to get old programs working with QB64 without API?


RE: BIOS com port - eoredson - 09-08-2023

(09-06-2023, 11:18 AM)SpriggsySpriggs Wrote: So what information are you actually trying to get from the BIOS?

The com port addresses for Com1: to Com4:

I have given up on trying to find base ports for Com5: to Com8: although I have a Rocket Modem III 8-port modem card.

Erik.


RE: BIOS com port - SpriggsySpriggs - 09-08-2023

Perhaps QueryDosDevices()?


RE: BIOS com port - DSMan195276 - 09-08-2023

(09-08-2023, 04:06 AM)eoredson Wrote: The com port addresses for Com1: to Com4:
Unfortunately you have multiple problems here, the com port address would be useless for you as real in/out port access is not supported in QB64. A small number of the ports are emulated to allow old programs to work but that's it (COM ports aren't included in that).

As others have mentioned the BIOS memory is also emulated for some sections, and simply empty for the rest.

Ideally the solution here would be to rewrite the program to use the `OPEN` syntax for COM ports. That still works as it will go through Windows to talk to the port.