home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progasm / hints.arj / HINTS.TXT
Encoding:
Text File  |  1990-11-03  |  4.5 KB  |  101 lines

  1.                              WHAT TYPE CPU?
  2.  
  3. There are generally two microprocessor families, real-mode processors,
  4. and protected-mode processors (this term is only used to describe their
  5. capabilities). The real-mode family is the 8086, 8088, 80186, 80188,
  6. and the NEC V30 and V20. Protected-mode ones are 80286, 80386DX,
  7. 80386SX, and 80486. 80386DX and SX are regarded as one type. To
  8. separate between families, you must find if SP is decremented before or
  9. after a PUSH. In real-mode processors, SP is decremented before
  10. PUSHing, in protected-mode processors, SP is decremented after PUSHing.
  11. The following piece of code will separate real-mode CPUs from protected
  12. CPUs:
  13.  
  14.                PUSH SP
  15.                POP AX
  16.                CMP SP,AX
  17.                JE AN_8086
  18.  NOTE: The `JE' can also be `JZ', and DEBUG changes `JE' to `JZ'
  19.  automatically.
  20.  
  21. I don't know how to tell the difference between all real-mode
  22. processors, so in the programs I'd call them an 8086, because that's
  23. the sort of `leader' of the group.
  24. Now you know which family it's in, you have to sort out the 286, 386,
  25. and 486s. 286s cannot set the Nested Task (NT) bit of the flag
  26. register, so there's the key. NT is bit 14, which is 4000h
  27. (hexadecimal, or hex) can be set (or at least tried to be) with the OR
  28. command. Yes, as you guessed we also have a piece of code for that:
  29.  
  30.                PUSHF
  31.                POP AX
  32.                OR AX,4000h
  33.                PUSH AX
  34.                POPF
  35.                PUSHF
  36.                POP AX
  37.                TEST AX,4000h
  38.                JE A_286
  39.  
  40. That's out of the way. Now, as you probably know, a 486 has a memory-
  41. cache built-in. Due to this, on a 386, the write-through bit (bit 29)
  42. in the CR0 register cannot keep any data. Bit 29 represents 20000000h,
  43. and this test can be preformed by changing the state of bit 29, and
  44. testing if the bit is still changed. Of course, here is the code:
  45.  
  46.                MOV EAX,CR0
  47.                MOV EBX,EAX
  48.                XOR EAX,20000000h
  49.                MOV CR0,EAX
  50.                MOV EAX,CR0
  51.                CMP EAX,EBX
  52.                JE A_386
  53.  
  54. If execution falls down after the `JE A_386' instruction, then the
  55. processor is a 486. If you're using MASM, remember to put a `.386P'
  56.                              WHAT TYPE CPU?
  57.  
  58. directive to tell the assembler to use 386/486 instructions and
  59. registers. If you're using an assembler without 386/486 instructions
  60. allowed, then the following code will do the trick. Basically, you make
  61. the specified bytes be put in that area in the memory, which, when
  62. looked at by a 386 or 486 processor, will be interpreted as the
  63. appropriate registers and instructions:
  64.  
  65.                DB 0Fh,20h,C0h                ;MOV EAX,CR0
  66.                DB 60h,8Bh,D8h                ;MOV EBX,EAX
  67.                DB 66h,35h,00,00,00,20h       ;XOR EAX,20000000h
  68.                DB 0Fh,22h,C0h                ;MOV CR0,EAX
  69.                DB 0Fh,20h,C0h                ;MOV EAX,CR0
  70.                DB 66h,3Bh,C3h                ;CMP EAX,EBX
  71.                JE A_386
  72.  
  73. That's it for telling what type CPU, the next section is about the
  74. interrupts in your PC/XT/AT. Only the useful interrupts are shown.
  75. *NEW PAGE*
  76.                             USEFUL I/O PORTS
  77.  
  78. I/O ports are places in the computer, numbered 0-65535 which contain
  79. the numbers 0-255 in it. The computer will act differently upon the
  80. state of these, and I seriously warn you: do NOT experiment writing to
  81. the I/O ports, physical damage could be done, for they are places in
  82. the computer which are extremely special. The following is a list of
  83. useful I/O ports and their states:
  84.  
  85. 0060h :
  86.      Keyboard data input register
  87. 0061h :
  88.      Keyboard data output register
  89.  
  90. 0070h :
  91.      CMOS RAM address port(AT only)
  92. 0071h :
  93.      CMOS RAM data port, byte in CMOS RAM location specified in port
  94.      70h. Write to this to set CMOS RAM locations. Read from it to find
  95.      out contents of location.
  96. 02F8h-02FFh :
  97.      Serial 2; See technical reference manual
  98. 03F8h-03FFh :
  99.      Serial 1; See technical reference manual
  100.  
  101.