NEC V30MZ instruction set: Difference between revisions

From WSdev Wiki
Jump to navigationJump to search
(add modr/m byte section)
Line 522: Line 522:


=== ModR/M byte ===
=== ModR/M byte ===
The ModR/M byte, marked as <tt>oorrrmmm</tt>, is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that ''oo'' = <tt>00</tt>, ''mmm'' = <tt>110</tt> is a special case.


== Official instructions ==
== Official instructions ==

Revision as of 18:02, 26 December 2024

Official V30MZ (80186) Instructions
AAA AAD AAM AAS ADC ADD AND BOUND CALL CBW CLC
CLD CLI CMC CMP CMPSB CMPSW CS CWD DAA DAS DEC
DIV DS ENTER ES HLT IDIV IMUL IN INC INSB INSW
INT INTO IRET JA JBE JC JCXZ JG JGE JL JLE
JMP JNC JNO JNP JNS JNZ JO JP JS JZ LAHF
LDS LEA LEAVE LES LOCK LODSB LODSW LOOP LOOPE LOOPNE MOV
MOVSB MOVSW MUL NEG NOP NOT OR OUT OUTSB OUTSW POLL
POP POPA POPF PUSH PUSHA PUSHF RCL RCR REP REPNE RET
RETF ROL ROR SAHF SAR SBB SCASB SCASW SHL SHR SS
STC STD STI STOSB STOSW SUB TEST XCHG XLAT XOR
Intel <-> NEC mnemonic translation table
Intel NEC
AAA ADJBA
AAD CVTDB
AAM CVTBD
AAS ADJBS
ADC ADDC
ADD ADD
AND AND
BOUND CHKIND
CALL CALL
CBW CVTBW
CLC CLR1 CY
CLD CLR1 DIR
CLI DI
CMC NOT1 CY
CMP CMP
CMPSB CMPBKB
CMPSW CMPBKW
CS PS
CWD CVTWL
DAA ADJ4A
DAS ADJ4S
DEC DEC
DIV DIVU
DS DS0
ENTER PREPARE
ES DS1
HLT HALT
IDIV DIV
IMUL MUL
IN IN
INC INC
INSB INMB
INSW INMW
INT BRK
INTO BRKV
IRET RETI
JA BH
JBE BNH
JC/JB BC/BL
JCXZ BCWZ
JG BGT
JGE BGE
JL BLT
JLE BLE
JMP BR
JNC/JAE BNC/BNL
JNO BNV
JNP BPO
JNS BP
JNZ/JNE BNZ/BNE
JO BV
JP BPE
JS BN
JZ/JE BZ/BE
LAHF MOV
LDS MOV
LEA LDEA
LEAVE DISPOSE
LES MOV
LOCK BUSLOCK
LODSB LDMB
LODSW LDMW
LOOP DBNZ
LOOPE DBNZE
LOOPNE DBNZNE
MOV MOV
MOVSB MOVBKB
MOVSW MOVBKW
MUL MULU
NEG NEG
NOP NOP
NOT NOT
OR OR
OUT OUT
OUTSB OUTM
OUTSW OUTM
POLL POLL
POP POP
POPA POP
POPF POP
PUSH PUSH
PUSHA PUSH
PUSHF PUSH
RCL ROLC
RCR RORC
REP/REPE/REPZ REP/REPE/REPZ
REPNE/REPNZ REPNE/REPNZ
RET RET
RETF RET
ROL ROL
ROR ROR
SAHF MOV
SAR SHRA
SBB SUBC
SCASB CMPMB
SCASW CMPMW
SHL SHL
SHR SHR
SS SS
STC SET1 CY
STD SET1 DIR
STI EI
STOSB STMB
STOSW STMW
SUB SUB
TEST TEST
XCHG XCH
XLAT TRANS
XOR XOR

Official instructions by type

Type Instructions
Memory MOV XCHG XLAT LEA LDS LES IN OUT
Ports IN OUT INSB OUTSB INSW OUTSW
Arithmetic ADD SUB ADC SBB INC DEC MUL DIV IMUL IDIV CMP NEG
Numeric CBW CWD AAA AAS AAM AAD DAA DAS
Shift ROL ROR RCL RCR SHL SHR SAR
Bitwise AND OR XOR NOT TEST
Branch JC JNC JZ JNZ JBE JA JO JNO JP JNP JS JNS JL JGE JLE JG
Jump JMP CALL RET RETF
Loop LOOP LOOPE LOOPNE
Interrupt INT IRET INTO HLT BOUND
Stack PUSH POP PUSHA POPA PUSHF POPF
Flags CLC STC CLD STD CLI STI CMC LAHF SAHF
Prefix CS DS ES SS
String REP REPE REPNE MOVSB MOVSW LODSB STOSB LODSW STOSW CMPSB SCASB CMPSW SCASW
Other NOP ENTER LEAVE LOCK POLL

Instruction encoding

ModR/M byte

The ModR/M byte, marked as oorrrmmm, is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:

  • oo - Mode;
  • rrr - Two possible functions:
    • Register (for addressing modes which require both a register and a register/memory operand),
    • Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
  • mmm - Register/Memory.

The Mode and Register/Memory bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the Register field also refers to a register; it is always interpreted as if Mode was equal to 11.

R/M \ Mode 00 01 10 11 (byte) 11 (word)
000 DS:[BX + SI] DS:[BX + SI + disp8] DS:[BX + SI + disp16] AL AX
001 DS:[BX + DI] DS:[BX + DI + disp8] DS:[BX + DI + disp16] CL CX
010 SS:[BP + SI] SS:[BP + SI + disp8] SS:[BP + SI + disp16] DL DX
011 SS:[BP + DI] SS:[BP + DI + disp8] SS:[BP + DI + disp16] BL BX
100 DS:[SI] DS:[SI + disp8] DS:[SI + disp16] AH SP
101 DS:[DI] DS:[DI + disp8] DS:[DI + disp16] CH BP
110 DS:[disp16] SS:[BP + disp8] SS:[BP + disp16] DH SI
111 DS:[BX] DS:[BX + disp8] DS:[BX + disp16] BH DI

Note that oo = 00, mmm = 110 is a special case.

Official instructions

AAA


AAD


AAM


AAS


ADC


ADD


AND


BOUND


CALL


CBW


CLC


CLD


CLI


CMC


CMP


CMPSB


CMPSW


CS


CWD


DAA


DAS


DEC


DIV


DS


ENTER


ES


HLT


IDIV


IMUL


IN


INC


INSB


INSW


INT


INTO


IRET


JA


JBE


JC/JB


JCXZ


JG


JGE


JL


JLE


JMP


JNC/JAE


JNO


JNP


JNS


JNZ/JNE


JO


JP


JS


JZ/JE


LAHF


LDS


LEA


LEAVE


LES


LOCK


LODSB


LODSW


LOOP


LOOPE


LOOPNE


MOV


MOVSB


MOVSW


MUL


NEG


NOP


NOT


OR


OUT


OUTSB


OUTSW


POLL


POP


POPA


POPF


PUSH


PUSHA


PUSHF


RCL


RCR


REP/REPE/REPZ


REPNE/REPNZ


RET


RETF


ROL


ROR


SAHF


SAR


SBB


SCASB


SCASW


SHL


SHR


SS


STC


STD


STI


STOSB


STOSW


SUB


TEST


XCHG


XLAT


XOR