home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT1-5 / DETPROC2.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  3.3 KB  |  81 lines

  1. ;
  2. ;       Program DetProc2 ( Chapter 3 )
  3. ;
  4. page 55,132
  5. ;       This  program  tells  you what microprocessor has
  6. ;       your computer.   You  can  use  this  program  to
  7. ;       organize  quite  sophisticated  batch-files which
  8. ;       work  in  different  ways   depending   on   your
  9. ;       microprocessor    type.    The   program   passes
  10. ;       information to the another using the DOS  feature
  11. ;       called  Return  Code  and also puts message for a
  12. ;       user.   The  meanings  of  return  codes  are  as
  13. ;       follows:
  14. ;
  15. ;       0 - you have an i8086/i8088 processor;
  16. ;       1 - you have an i80186/i80188 processor;
  17. ;       2 - you have an i80286 processor;
  18. ;       3 - you have an i80386 processor;
  19. ;
  20. .model  small
  21. .stack
  22. .data
  23. MsgText db      'You have an '
  24. ProcId1 db      'i80'
  25. Procid2 db      'xxx'
  26.     db      ' microprocessor.'
  27.     db      '$'
  28. i86     db      '86 '
  29. i186    db      '186'
  30. i286    db      '286'
  31. i386    db      '386'
  32. .code   
  33. .startup
  34.     push    ds              ; push data segment register onto stack
  35.     pop     es              ; both ES an DS now point to DATA segment
  36. ;===    Try to clear bit 15 (to put 0 into it)
  37.     mov     dx,0            ; Zero in DX
  38.     push    dx              ; Store DX onto stack
  39.     popf                    ; Read stored value into flags
  40.     pushf                   ; Store flags onto stack
  41.     pop     dx              ; Read stored flags into DX
  42.     shl     dh,1            ; If bit 15 is set, CF=1
  43.     jb      Less286         ; 8086 or 80186
  44. ;===    Processor is 286 or above
  45.     mov     dx,7000h        ; Bits 12-14 of DX are set
  46.     push    dx              ; Store DX onto stack
  47.     popf                    ; Read stored value into flags
  48.     pushf                   ; Store flags onto stack
  49.     pop     ax              ; Read stored flags into DX
  50.     and     ax,dx           ; If bits 12-14 are not copied
  51.     jz      Is286           ;    processor is 80286
  52. ;===    Processor 386 or above
  53.     lea     si,i386         ; Address of text "386" to build up message
  54.     mov     al,3            ; Set return code to 3
  55.     jmp     Finish          ;    and exit the program
  56. ;===    Processor is 8086 or 80186
  57. Less286:lea     si,i86          ; Address of text "86 "  to build up message
  58.     mov     ax,1            ; Set return code to 0
  59.     mov     cx,32           ; Shift counter = 32
  60.     shl     ax,cl           ; Shift AX to the left 32 times
  61.                 ;    80186/80186 does not fulfil this well
  62.                 ;    so if AX isn't zero, processor is 80186/80188
  63. ;===    This is the end of program
  64. Finish: push    ax              ; Save the return code
  65.     mov     cx,3            ; Length of processor identifier
  66.     cld                     ; Set increasing addresses for MOVSB
  67.     lea     di,ProcId2      ; Target for processor ident
  68. rep     movsb                   ; Insert the processor identifier
  69.                 ;     into the message text
  70.     lea     dx,MsgText      ; Address of message text
  71.     mov     ah,9            ; Service 09 - output string
  72.     int     21h             ; Dos service call
  73.     pop     ax              ; Restore the return code
  74.     mov     ah,4Ch          ; Service 4Ch - terminate
  75.     int     21h             ; Dos service call
  76. ;===    Processor is 80286
  77. Is286:  lea     si,i286         ; Address of text "286" to build up message
  78.     mov     al,2            ; Set return code to 2
  79.     jmp     Finish          ;    and exit the program
  80.     end
  81.