Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - generally speaking, the more you know about how your computer works, the http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Generally speaking, the more you know about how your computer works, the
  more effective you'll be at writing programs for it. High-level
  programming languages, such as BASIC and C, are not designed to include
  every possible function that you might need while programming--though
  admittedly, some are better than others. At some point, you will want to
  go deeper into your system and use some of the routines the languages
  themselves use, or perhaps go even deeper and program at the hardware
  level.

  Although some languages provide limited means to talk directly to memory
  (as with PEEK and POKE in BASIC) or even to some of the chips (as with
  BASIC's INP and OUT statements), most programmers eventually resort to
  assembly language, the basic language from which all other languages and
  operating systems are built. The 8086 assembly language, like all other
  assembly languages, is composed of a set of symbolic instructions, as
  shown in Figure 2-1. An assembler translates these instructions and the
  data associated with them into a binary form, called machine language,
  that can reside in memory and be processed by the 8086 to accomplish
  specific tasks.


  Mnemonic           Full Name
  --------------------------------------------------------------------------
  Instructions recognized by all 8086-family microprocessors
  AAA                ASCII Adjust After Addition
  AAD                ASCII Adjust After Division
  AAM                ASCII Adjust After Multiplication
  AAS                ASCII Adjust After Subtraction
  ADC                ADd with Carry
  ADD                ADD
  AND                AND
  CALL               CALL
  CBW                Convert Byte to Word
  CLC                CLear Carry flag
  CLD                CLear Direction flag
  CLI                CLear Interrupt flag
  CMC                CoMplement Carry flag
  CMP                CoMPare
  CMPS               CoMPare String
  CMPSB              CoMPare String (Bytes)
  CMPSW              CoMPare String (Words)
  CWD                Convert Word to Doubleword
  DAA                Decimal Adjust After Addition
  DAS                Decimal Adjust After Subtraction
  DEC                DECrement
  DIV                Unsigned DIVide
  ESC                ESCape
  HLT                HaLT
  IDIV               Integer DIVide
  IMUL               Integer MULtiply
  IN                 INput from I/O port
  INC                INCrement
  INT                INTerrupt
  INTO               INTerrupt on Overflow
  IRET               Interrupt RETurn
  JA                 Jump if Above
  JAE                Jump if Above or Equal
  JB                 Jump if Below
  JBE                Jump if Below or Equal
  JC                 Jump if Carry
  JCXZ               Jump if CX Zero
  JE                 Jump if Equal
  JG                 Jump if Greater than
  JGE                Jump if Greater than or Equal
  JL                 Jump if Less than
  JLE                Jump if Less than or Equal
  JMP                JuMP
  JNA                Jump if Not Above
  JNAE               Jump if Not Above or Equal
  JNB                Jump if Not Below
  JNBE               Jump if Not Below or Equal
  JNC                Jump if No Carry
  JNE                Jump if Not Equal
  JNG                Jump if Not Greater than
  JNGE               Jump if Not Greater than or Equal
  JNL                Jump if Not Less than
  JNLE               Jump if Not Less than or Equal
  JNO                Jump if Not Overflow
  JNP                Jump if Not Parity
  JNS                Jump if Not Sign
  JNZ                Jump if Not Zero
  JO                 Jump if Overflow
  JP                 Jump if Parity
  JPE                Jump if Parity Even
  JPO                Jump if Parity Odd
  JS                 Jump if Sign
  JZ                 Jump if Zero
  LAHF               Load AH with Flags
  LDS                Load pointer using DS
  LEA                Load Effective Address
  LES                Load pointer using ES
  LOCK               LOCK bus
  LODS               LOaD String
  LODSB              LOaD String (Bytes)
  LODSW              LOaD String (Words)
  LOOP               LOOP
  LOOPE              LOOP while Equal
  LOOPNE             LOOP while Not Equal
  LOOPNZ             LOOP while Not Zero
  LOOPZ              LOOP while Zero
  MOV                MOVe data
  MOVS               MOVe String
  MOVSB              MOVe String (Bytes)
  MOVSW              MOVe String (Words)
  MUL                MULtiply
  NEG                NEGate
  NOP                No OPeration
  NOT                NOT
  OR                 OR
  OUT                OUTput to I/O port
  POP                POP
  POPF               POP Flags
  PUSH               PUSH
  PUSHF              PUSH Flags
  RCL                Rotate through Carry Left
  RCR                Rotate through Carry Right
  REP                REPeat
  REPE               REPeat while Equal
  REPNE              REPeat while Not Equal
  REPNZ              REPeat while Not Zero
  REPZ               REPeat while Zero
  RET                RETurn
  ROL                ROtate Left
  ROR                ROtate Right
  SAHF               Store AH into Flags
  SAL                Shift Arithmetic Left
  SAR                Shift Arithmetic Right
  SBB                SuBtract with Borrow
  SCAS               SCAn String
  SCASB              SCAn String (Bytes)
  SCASW              SCAn String (Words)
  SHL                SHift Left
  SHR                SHift Right
  STC                SeT Carry flag
  STD                SeT Direction flag
  STI                SeT Interrupt flag
  STOS               STOre String
  STOSB              STOre String (Bytes)
  STOSW              STOre String (Words)
  SUB                SUBtract
  TEST               TEST
  WAIT               WAIT
  XCHG               eXCHanGe
  XLAT               transLATe
  XOR                eXclusive OR

  Instructions recognized by the 80286 and 80386 only:
  ARPL               Adjust RPL field of selector
  BOUND              Check array index against BOUNDs
  CLTS               CLear Task-Switched flag
  ENTER              Establish stack frame
  INS                INput String from I/O port
  LAR                Load Access Rights
  LEAVE              Discard stack frame
  LGDT               Load Global Descriptor Table register
  LIDT               Load Interrupt Descriptor Table register
  LLDT               Load Local Descriptor Table register
  LMSW               Load Machine Status Word
  LSL                Load Segment Limit
  LTR                Load Task Register
  OUTS               OUTput String to I/O port
  POPA               POP All general registers
  PUSHA              PUSH All general registers
  SGDT               Store Global Descriptor Table register
  SIDT               Store Interrupt Descriptor Table register
  SLDT               Store Local Descriptor Table register
  SMSW               Store Machine Status Word
  STR                Store Task Register
  VERR               VERify a segment selector for Reading
  VERW               VERify a segment selector for Writing

  Instructions recognized by the 80386 only:
  BSF                Bit Scan Forward
  BSR                Bit Scan Reverse
  BT                 Bit Test
  BTC                Bit Test and Complement
  BTR                Bit Test and Reset
  BTS                Bit Test and Set
  CDQ                Convert Doubleword to Quadword
  CMPSD              CoMPare String (Doublewords)
  CWDE               Convert Word to Doubleword in EAX
  LFS                Load pointer using FS
  LGS                Load pointer using GS
  LSS                Load pointer using SS
  LODSD              LOaD String (Doublewords)
  MOVSD              MOVe String (Doublewords)
  MOVSX              MOVe with Sign-eXtend
  MOVZX              MOVe with Zero-eXtend
  SCASD              SCAn String (Doublewords)
  SETA               SET byte if Above
  SETAE              SET byte if Above or Equal
  SETB               SET byte if Below
  SETBE              SET byte if Below or Equal
  SETC               SET byte if Carry
  SETE               SET byte if Equal
  SETG               SET byte if Greater
  SETGE              SET byte if Greater or Equal
  SETL               SET byte if Less
  SETLE              SET byte if Less or Equal
  SETNA              SET byte if Not Above
  SETNAE             SET byte if Not Above or Equal
  SETNB              SET byte if Not Below
  SETNBE             SET byte if Not Below or Equal
  SETNC              SET byte if No Carry
  SETNE              SET byte if Not Equal
  SETNG              SET byte if Not Greater
  SETNGE             SET byte if Not Greater or Equal
  SETNL              SET byte if Not Less
  SETNLE             SET byte if Not Less or Equal
  SETNO              SET byte if Not Overflow
  SETNP              SET byte if Not Parity
  SETNS              SET byte if Not Sign
  SETNZ              SET byte if Not Zero
  SETO               SET byte if Overflow
  SETP               SET byte if Parity
  SETPE              SET byte if Parity Even
  SETPO              SET byte if Parity Odd
  SETS               SET byte if Sign
  SETZ               SET byte if Zero
  SHLD               SHift Left (Doubleword)
  SHRD               SHift Right (Doubleword)
  STOSD              STOre String (Doublewords)
  --------------------------------------------------------------------------


  Figure 2-1.  The instruction set used with the 8086, 80286, and 80386.

  --------------------------------------------------------------------------
  NOTE:
    Although this chapter discusses the details of 8086 programming,
    remember that we're implicitly talking about the 8088, 80286, and 80386
    as well. Information pertaining exclusively to the 80286 or 80386 will
    be noted.
  --------------------------------------------------------------------------

  The operations that the 8086 instructions can perform break down into only
  a few categories. They can do simple, four-function integer arithmetic.
  They can move data around. They can, using only slightly clumsy methods,
  manipulate individual bits. They can test values and take logical action
  based on the results. And last but not least, they can interact with the
  circuitry around them. The size of each instruction varies, but generally
  the most basic and often-used instructions are the shortest.

  Assembly-language programming can be carried out on one of two levels: to
  create interface routines that will tie high-level programs to the
  lower-level DOS and ROM-BIOS routines; or to create full-fledged
  assembly-language programs that are faster and smaller than equivalent
  high-level programs, or that perform exotic tasks at the hardware level,
  perhaps accomplishing a feat that is accomplished nowhere else. Either
  way, to understand how to use assembly language, you must understand how
  8086-family microprocessors process information and how they work with the
  rest of the computer. The rest of this chapter describes how the
  microprocessor and the computer's other parts communicate.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson