Author Topic: QB64 x86 Error, Unknown Opcode (92)  (Read 3424 times)

0 Members and 1 Guest are viewing this topic.

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
QB64 x86 Error, Unknown Opcode (92)
« on: February 28, 2020, 04:05:08 am »
I am using the ABSOLUTE function to execute machine code that has been placed in an array.

QB64 is reporting this runtime error:
x86 Error, Unknown Opcode (92)

Opcode 92 is one of the instructions in my machine code array.
The mnemonic for this opcode is:

XCHG    DX,AX

Why would QB64 report that the opcode for this instruction is unknown?


Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #1 on: February 28, 2020, 04:08:25 am »
Because the x86 emulation is really half-assed, and basically has had just enough work done on it to allow some standard mouse routines from the QB era to work.

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #2 on: February 28, 2020, 04:18:28 am »
Thank you Luke.
I will try to find a work around.

FellippeHeitor

  • Guest
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #3 on: February 28, 2020, 04:23:43 am »
Yeah, no low level in the basic side. You’d need to dive into c for that.

What did you intend to do with machine code?

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #4 on: February 28, 2020, 01:31:24 pm »
The opcode 92 is contained in the source code for the QBWrite text editor, version 2.7.

This can be obtained by downloading the file obw.zip from this page:

https://qb45.org/files.php?cat=10&p=8

FellippeHeitor

  • Guest
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #5 on: February 28, 2020, 01:40:39 pm »
But what’s the machine code call supposed to do? Maybe qb64 already does it without the low level call.

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #6 on: February 28, 2020, 01:42:14 pm »
Here is the qbwrite 2.7 source code that contains not only the 92 opcode, but the 91 and 93 opcodes as well.
The opcodes used are part of the program's mouse routine.

Code: QB64: [Select]
  1. DEFINT A-Z
  2. DIM SHARED a(9)
  3. DEF SEG = VARSEG(a(0))
  4. FOR i = 0 TO 17
  5.     READ r
  6.     POKE VARPTR(a(0)) + i, r
  7. '---------------------------- Machine Code -----------------------------------
  8. DATA &HB8,&H00,&H00:
  9. DATA &H55:
  10. DATA &H8B,&HEC:
  11. DATA &HCD,&H33:
  12. DATA &H92:
  13. DATA &H8B,&H5E,&H06:
  14. DATA &H89,&H07:
  15. DATA &H5D:
  16. DATA &HCA,&H02,&H00:
  17. '-------------------------------------------------------------------------------
  18.  
  19. SUB Mouse (cx, dx, bx)
  20.        
  21.     POKE VARPTR(a(4)), &H92 'Swap code,Get CX setup
  22.     CALL ABSOLUTE(cx, VARPTR(a(0))) 'Run Code
  23.     cx = (cx / 8) + 1 'Adjust 25x80
  24.     POKE VARPTR(a(4)), &H91 'Swap code,Get DX setup
  25.     CALL ABSOLUTE(dx, VARPTR(a(0))) 'Run Code
  26.     dx = (dx / 8) + 1 'Adjust 25x80
  27.     POKE VARPTR(a(4)), &H93 'Swap code,Get BX setup
  28.     CALL ABSOLUTE(bx, VARPTR(a(0))) 'Run Code
  29.  
  30.  
  31. SUB MousePointer (SW)
  32.        
  33.     POKE VARPTR(a(0)) + 1, SW 'Swap code,Set AX = (SW)
  34.     CALL ABSOLUTE(c, VARPTR(a(0))) 'Run Code
  35.  
  36.  

« Last Edit: February 28, 2020, 01:45:46 pm by EricE »

FellippeHeitor

  • Guest
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #7 on: February 28, 2020, 01:45:53 pm »
Adapt your code to use the new mouse features. http://www.qb64.org/wiki/Keyword_Reference_-_By_usage#Mouse_Input:

All functions are prefixed with _MOUSE.

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #8 on: February 28, 2020, 06:13:32 pm »
Here are the subroutines using QB64's mouse features.

Code: QB64: [Select]
  1. SUB Mouse (cx, dx, bx)
  2.  
  3.     mi = _MOUSEINPUT
  4.     cx = _MOUSEY ' Qbwrite's horizontal column number
  5.     dx = _MOUSEX ' Qbwrite's vertical row number
  6.  
  7.     bx = 0
  8.     IF _MOUSEBUTTON(1) THEN bx = bx OR &H1 ' Left mouse button
  9.     IF _MOUSEBUTTON(2) THEN bx = bx OR &H2 ' Right mouse button
  10.     IF _MOUSEBUTTON(3) THEN bx = bx OR &H4 ' Center or scroll button
  11.  
  12.  
  13.  
  14. SUB MousePointer (SW)
  15.  
  16.  
  17.     SELECT CASE SW
  18.         CASE 0 ' Initialize mouse
  19.             ' In QB64 nothing to do
  20.         CASE 1 ' Show mouse cursor
  21.             _MOUSESHOW
  22.         CASE 2 ' Hide mouse cursor
  23.             _MOUSEHIDE
  24.         CASE 3 ' Get mouse position
  25.             ' Done in Mouse subroutine
  26.     END SELECT

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #9 on: February 28, 2020, 11:44:46 pm »
Waiting for the _MOUSEINPUT function to return zero

Code: QB64: [Select]

might not be required in the above code.

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: QB64 x86 Error, Unknown Opcode (92)
« Reply #10 on: February 29, 2020, 01:44:46 am »
The mouse machine code is explained in detail in this file:
qmouse.zip by Robert Wolf
which is available for download from the web page:
https://qb45.org/files.php?cat=10&p=8

This is only to understand the operation of the original code, as it will not run in QB64 due to some opcodes not being emulated.