Unknown opcode skipped: 66, not 8086 instruction - not supported yet
Asked Answered
S

1

2

I'm using emu8086. I've a question which tasked me to display what we see on seven segment displays after converting from its hexa inputs. I should input my data in hexa, if it matches the hexa input of the seven segment table, it displays the decimal number, eg. 3FH = 0, 06H = 1. I'm using array to implement this program. Below is the working source program:

ORG 100H     

MOV AL,[1840H]   ;input in this memory location
MOV CL,0AH       ; initialize length counter
   
AGAIN:  CMP AL,MSG+BX     ; compare to check if the data matches
        JE RESULT         ; jump to RESULT if data matched
        INC BX            ; increase decimal output by 1 if data not matched
LOOP AGAIN

MOV [1841H],0FFH          ; display FF if no data matched the array

HLT

MSG DB 3FH, 06H, 5BH, 4FH,66H, 6DH,7DH,07H,7FH,6FH        ; my array with hexa inputs

RESULT: MOV [1841H],BL                 ; display data if matched

I had this program working. But I've tried something which I switch my array MSG DB 3FH... to a position after ORG 100H and before MOV AL,[1840H], running the program will give an error message

"Unknown opcode skipped: 66, not 8086 instruction - not supported yet".

I can't find the reason why.

Anyone would have any idea what's the reason and can I fix anything to make my program work if I were to keep the array between ORG 100H and MOV AL,[1840H] ?

Sherbet answered 1/10, 2014 at 16:6 Comment(5)
You are using an illegal opcode instruction for chip setTranscontinental
#5210335Transcontinental
@Transcontinental will i be able to do anything to make it work? I've tried changing the 66H to other hexa numbers from 60H to 6FH, some of them contains instructions, but the program won't work the way I want it despite there are no message popping out, those which does not contain instructions pops out the "Unknown opcode skipped..." message, isn't 60H-6FH doesn't have any instructions defined, why would some of them have it, some don't?Sherbet
Huh? Try to debug a little move to see what line it stops at so that we may narrow down what line causes the error. Also if you can step through the code while looking at the registers.Transcontinental
@Transcontinental It stops at the 66H opcode where the emulator displays "DB 66H". It seems that in my case, I can't use my array for instruction execution, instead I'm using the array as a counter to count up the decimal number to be displayed.Sherbet
P
6

By moving the data array MSG in front of the first instruction you effectively asked emu8086 to execute it! The first bytes of MSG correspond to valid 8086 instructions (AAS, PUSH ES, POP BX, and DEC DI) but the fifth byte represents the operand size prefix which is not available in the 8086 processor!

To quickly solve your problem just jump over MSG:

  ORG 100H
  jmp start
MSG DB 3FH, 06H, 5BH, 4FH,66H, 6DH,7DH,07H,7FH,6FH
start:

But it's even better to just put it after your code like you had originally, so it's not in the way in the first place. There's no benefit to having the first instruction of your program be a jmp when you could just have put the code there, unless you want it at a standard place in the binary so other things can edit the file. (.com executables don't have metadata to tell the program-loader where the entry-point is; it's fixed at IP=100h, the first byte of the file.)

Some observations

  • In LOOP AGAIN, the LOOP instruction depends on the whole CX register, yet you only initialized its low 8 bits via MOV CL,0AH.
  • Your code also uses the BX register to index the array, but you've never zeroed BX so you can't be sure the program will operate fine.
  • In MOV [1841H],0FFH, you seem to rely on emu8086 defaulting to the byte size when writing this immediate to a memory location. I would advice to always impose the size that you need, like in mov byte ptr [1841h], 255.
  • What confuses me is the lack of square brackets in CMP AL,MSG+BX.
    Shouldn't you write cmp al, [MSG+BX] similar to your use of square brackets in mov AL, [1840H], MOV [1841H],0FFH, and MOV [1841H],BL? For even more confusion (and some clarification) about the use of square brackets in MASM (emu8086 is MASM-style), read this Ross Ridge answer.

My version of the revised program:

  ORG  256
  jmp  start

msg db 3Fh, 06h, 5Bh, 4Fh, 66h, 6Dh, 7Dh, 07h, 7Fh, 6Fh

start:
  mov  al, [1840h]
  xor  bx, bx        ; ArrayIndex (offset)
again:
  cmp  al, [msg+bx]
  je   result
  inc  bx
  cmp  bx, 10        ; NumberOfElements
  jb   again
  mov  bl, -1
result:
  mov  [1841h], bl   ; display ARRAYINDEX if matched else display FF
  hlt

Related / duplicates:

Preterhuman answered 5/10, 2014 at 14:50 Comment(2)
I see, that clears up a lot, Thank you very much. I've tried both with brackets and without brackets, and they worked just fine. Can it be said that without the brackets, my emulator will still be able to refer to the array?Sherbet
Oh, okay. So it depends on the compiler itself. Thanks.Sherbet

© 2022 - 2024 — McMap. All rights reserved.