From news.sas.ab.ca!rover.ucs.ualberta.ca!news.bc.net!vanbc.wimsey.com!news.mindlink.net!agate!overload.lbl.gov!lll-winken.llnl.gov!uwm.edu!cs.utexas.edu!news.sprintlink.net!news.dgsys.com!DGS.dgsys.com!raymoon Mon Mar 27 16:41:13 1995
Path: news.sas.ab.ca!rover.ucs.ualberta.ca!news.bc.net!vanbc.wimsey.com!news.mindlink.net!agate!overload.lbl.gov!lll-winken.llnl.gov!uwm.edu!cs.utexas.edu!news.sprintlink.net!news.dgsys.com!DGS.dgsys.com!raymoon
From: raymoon@dgsys.com (Raymond Moon)
Newsgroups: comp.lang.asm.x86,alt.lang.asm
Subject: x86 Assembly Language FAQ - General Part 1/2
Followup-To: poster
Date: 25 Mar 1995 23:06:09 GMT
Organization: Digital Gateway Systems
Lines: 768
Distribution: world
Expires: Thu, 20 Apr 1995 23:59:59 GMT
Message-ID: <3l27l1$1j8@news.dgsys.com>
Reply-To: raymoon@dgs.dgsys.com
NNTP-Posting-Host: dgs.dgsys.com
Summary: This is the FAQ for the x86 Assembly Language programmers
 for the alt.lang.asm and comp.lang.asm.x86 newsgroups.  This
 particular section of the FAQ contains x86 assembly information
 common to all assemblers.
Keywords: x86 ASM FAQ General
X-Newsreader: TIN [version 1.2 PL2]
Xref: news.sas.ab.ca comp.lang.asm.x86:6021 alt.lang.asm:4553

Archive-name: asm_x86_faq/gen_part1
Alt-lang-asm-archive-name: asm_x86_faq/gen_part1
Comp-lang-asm-x86-archive-name: asm_x86_faq/gen_part1
Posting-Frequency: monthly (21st of every month)
Last-modified: 1995/03/22

------------------------------

Subject: 1. Introduction and Intent

This is the x86 Assembly Language FAQ for the comp.lang.asm.x86 and
alt.lang.asm and newsgroups.  This FAQ is posted monthly on or about
the 21st of the month on both newsgroups and news.answers, alt.answers
and comp.answers.  It also is archived at the normal FAQ archival
sites.  Currently, this FAQ is broken into four sections.  The
following are the section filenames (hopefully, once the FAQ as a
whole is approved) and the scope of each section of the FAQ.

asm_x86_faq/gen_part1 - This is the basic portion of the FAQ that
    contains information of interest to all assembly language
    programmers.  In general, the information contained in this
    portion of the FAQ is not specific to any particular assembler.

asm_x86_faq/gen_part2 - This is a continuation of the above FAQ.

asm_x86_faq/masm - This portion of the FAQ contains information
    specific for the Microsoft MASM.

asm_x86_faq/tasm - This portion of the FAQ contains information
    specific for the Borland TASM.

asm_x86_faq/A86 - This portion of the FAQ contains information
    specific for the A86 Shareware Assembler.

The scope and content of this FAQ is to go beyond just answering the
frequently asked questions.  I am including pointers to assembly
language treasure troves that are hidden out on the internet.  I
believe that this will enhance the FAQ's value not only to the novices
but also to the old hands.

Any subject listed as "OPEN" means that this topic as been requested
but no one has come forth and volunteered to write this section. 
Volunteers please indicate your intentions to the author listed below
either by posting to either newsgroup or by sending e-mail to the
author at the below address.

The general guidelines for submission are:
 *  accuracy and conciseness;
 *  pointers to where on the internet more detailed information is
    available; and
 *  any code submitted will be generic so that most assemblers can
    assemble successfully.

Any subject listed as "UNDER CONSTRUCTION" has a volunteer currently
writing that subject.  If you desire to assist or have some
information that you believe would be of help in writing that
particular subject, contact the contributor of that subject or post to
both newsgroups.  Once a subject is submitted to me, I will post it on
both newsgroups for comment.  After any changes that may be necessary
are made, I will include it in the next posting of the FAQ.

For the ease of determining what has changed since the last FAQ, the
Table of Contents will have "REVISED" at the end of the subject line
for all revised subjects.  If more than one FAQ revision has been
missed, the "Last Changed:" entry at the end of each subject can be
used to determine which subjects have been revised during the
intervening time frame.

The information in this FAQ is free for all to use as long as you
acknowledge the source.  This FAQ can be reproduced in part or in its
entirety as long as the copyright is included.  This FAQ can be made
available on public servers, like ftp, gopher or WWW servers.  Please
do not modify the file, such as converting it into some other format,
without prior permission of the author.

Suggestions for changes and comments are always welcome.  They can be
posted to either newsgroup or e-mailed directly to the me.

As I had to break this section of the FAQ into two parts, I probably
will have to start the approval process all over again.  That is about
a two month process.  So, do not use the above filenames until this
FAQ is approved.

Author: Raymond Moon, raymoon@dgs.dgsys.com
Copyright 1995 - Raymond Moon
ALL RIGHTS RESERVED
Last Changed: 22 Mar 95

------------------------------

Subject: 2. Table of Contents

1.  Introduction and Intent                 REVISED
2.  Table of Contents                       REVISED
3.  Charters For comp.lang.asm.x86 and alt.lang.asm Newsgroups
4.  What is Assembly Language
5.  List of x86 OpCodes
6.  What is HELPPC and Where It Is Available
7.  How To Truncate a File
8.  How Can STDERR Be Redirected To a File
9.  How To Determine the CPU Type           
10. IRQ Assignments
11. Ralf Brown's Interrupt List
12. Using VGA Mode 13h for Fast Graphics
13. Real Mode/Protected Mode                OPEN
14. Shareware ASM Libraries
15. How To Determine If a Problem Pentium Is Present
16. Accessing 4 Gegs of Memory in Real Mode
17. Interrupts and Exceptions
18. What Is Available at intel.com
19. ASM Books Available                     UNDER CONSTRUCTION
20. ASM Code Available on Internet          NEW
21. How To Commit a File
22. Using Extended Memory Manager
23. Acknowledgments

------------------------------

Subject: 3. Charters For comp.lang.asm.x86 and alt.lang.asm 
Newsgroups

To know whether or not these newsgroups will meet your needs, the
purpose for which they were created are given below.

3.1  COMP.LANG.ASM.X86

comp.lang.asm.x86 was created based upon voting on a Request for
Discussion (RFD).  The RFD for this newsgroup is:

The unmoderated newsgroup comp.lang.asm.x86 is open to discussions on
all topics related to assembly language and low-level programming on
IBM machines with '86 processors.  Appropriate topics would include,
but not be limited to:
 
    Assembly language tips and tricks (code techniques)
    MASM, TASM, and other commercial assemblers
    Graphics, sound, and other hardware programming
    Assembly language code
    Assembly language related share/freeware
    Linking assembly language with other languages
    Etc...
 
Topics that are discouraged are:
 
    Flames about "{Language X} is {better/worse} than ASM"
    Flames like "{Assembler 1} is {better/worse} than {Assembler 2}"
    High-level language code, except when used for hardware
        programming

3.2  ALT.LANG.ASM

Alt newsgroups are initiated with a Proposal posting to the alt.config
newsgroup.  The proposal for alt.lang.asm is: 

alt.lang.asm will address the problems of machine language programmers
out there in InterNet land.  It will be a forum for discussion of
coding techniques and efficiency problems related to machine language. 
The scope will be broad.  We will not discriminate by machine
architecture, race or sex.

Contributors: Michael Averbuch, mikeaver@firefly.prairienet.org
              Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 28 Dec 94 

------------------------------

Subject: 4. What Is Assembly Language

4.1  WHAT IS MACHINE LANGUAGE?

Although programmers tend to use C or C++ or Pascal these days, the
language closest to the PC hardware is machine language. Not one
second during a PC's powered on lifetime passes where the computer is
not executing machine language.

4.2  ASSEMBLY LANGUAGE OR MACHINE LANGUAGE

To word this simply, you can say that say that assembly language is a
human-readable text, and machine language is machine-readable binary
code. When you program in assembly language, you are programming on
the machine language level.

To program directly in machine language is teadious, so you use
assembly language instead, and use an assembler to produce the actual
machine code. 

4.3  WHEN TO USE ASSEMBLY LANGUAGE

I personally think that except as a learning exercise it's a waste of
time writing something in asm that can be written acceptably fast in a
high-level language.

Assembly language fits for the following:

 *  Low level control.  When you need to change the flags, or the
    control registers of the processor, as when entering protected
    mode.

 *  Speed.  Programs written in machine language execute fast!  It can
    execute 10-100 times the speed of BASIC, and about twice as fast
    as a program written in C or Pascal.

 *  Time Critical Code.  Critical sections of programs written in
    higher level languages, can be written in assembly to speed up
    sections.

 *  Small program size.  When you write a TSR for example this is very
    useful. Writing interrupt handlers is where assembly language
    shines.

Assembly language is very flexible and powerful, anything that the
hardware of the computer is capable of doing can be done in assembly.

Contributor: Patrik Ohman, patrik@astrakan.hgs.se
Last changed: 10 Jan 95 

------------------------------

Subject: 5. List Of x86 OpCodes

To obtain a full listing of the instruction set, opcodes and
instruction timing of the Intel processors, the book

Pentium<tm> Family, User's Manual
Volume 3: Architecture and Programming Manual
ISBN 1-55512-227-12

is the best source of information.

This book is available directly from Intel by calling or writing: 
Intel Literature Sales
P.O Box 7641
Mt. Prospect, IL 60056-7641
(800) 548-4725

Another source of information on the instruction set is the program
HelpPC, see obtaining HELPPC elsewhere in this document.

Contributor: Patrik Ohman, patrik@astrakan.hgs.se
Last changed: 10 Jan 95

------------------------------

Subject: 6. What Is HELPPC and Where Is It Available

HELPPC is a Quick Reference Utility for the intermediate to advanced
programmer.  It is a shareware program written by David Jurgens.  The
latest version is 2.10

The topics distributed in an easy database format are:
    BIOS interrupts;
    DOS interrupts and DOS functions;
    EMS and Mouse functions;
    BIOS and DOS data structures;
    diagnostic codes;
    DOS commands;
    80x86 assembler instructions;
    standard and vendor specific C functions; and
    various hardware specifications.

HELPPC is customizable by users.  The documentation describes how
users can incorporate their own information into the help file format. 
These user help files then can be incorporated into the database and
accessed via HELPPC application.

HELPPC comes in two versions.  The first is a DOS command line
program.  The second is a TSR.  The TSR supports context sensitive
help within many editors.  Only 32K is taken by the TSR version.

HELPPC requires:
    DOS 2.0 or greater;
    64K of RAM for DOS Command Line or 32K for TSR; and
    hard disk recommended.

HELPPC is available specifically from:

    ftp oak.oakland.edu
    anonymous ftp log on
    cd SimTel/msdos/info
    get helppc21.zip

HELPPC also is available from any site that mirrors the SimTel
directory.  (See File Availability under Subject #11 below for those
sites.)

Contributor:  Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 28 Dec 94

------------------------------

Subject: 7. How To Truncate A File

There is not any single DOS Int 21h function that performs this
operation.  A file can be truncated using two functions.  The
procedure is:

1.  Use Int 21h function 42h, Move File Pointer, to move the file
    pointer to the position where you want the file to be truncated.
2.  Use Int 21h function 40h, Write File or Device, to write zero
    bytes to the file.

Execution of the last DOS function will update the directory to the
new file length.

Contributor: Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 28 Dec 94

------------------------------

Subject: 8. How Can STDERR Be Redirected To A File

I understand that 4DOS has this capability at its command line.  If
you are looking in the assembly language FAQ for this information, an
assembly language answer probably is desired.  Here it is.

You will need to write a short program that performs the STDERR
redirection before loading and executing the desired program.  This
loader program relies upon the fact that a child program inherits all
open files of the parent program unless the parent program opens a
file with the inheritance flag set to no.

Because the full code for such a program is too large for this FAQ; I
will give are the salient specifications for such a program.

1.  The loader program accepts three command line arguments:
    a.  The full path and filename of the file into which STDERR is to
        be written.
    b.  The full path and filename of the program to be executed.
    c.  The command line for the program to be executed (should be
        delimited by double quotes to allow multiple arguments).  This
        argument is optional.
2.  Release all memory above the program using Int 21 function 4ah so
    that there will be room enough to load and execute the designated
    program. 
3.  Open the file from step 1.a above into which STDERR is to be
    written.
4.  Duplicate STDERR filehandle, which is 2, using Int 21h function
    45h.
5.  Using Int 21h function 46h, force STDERR filehandle, again 2, to
    have the filehandle of the opened file from step 2.
6.  Use Int 21h function 4b00h to load and execute the program from
    step 1.a.  Use the default environment and the command line from
    step 1.c above.
7.  Upon return from the function 4b00h, close the file opened in step
    2.
8.  To restore STDERR, use Int 21h function 46h to force STDERR, again
    2, to point to the filehandle saved from step 3 above.

This same technique can be applied to any of the standard devices.

I am finishing writing the above program and it should be available in
about a month.

Contributor: Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 28 Jan 95  

------------------------------

Subject: 9. How To Determine The CPU Type

9.1  CPUID PROGRAM

The type of processor and math coprocessor can be determined using two
functions that have been provided by Intel.  The source code to these
functions can be obtained from Intel by:


    ftp ftp.intel.com
    anonymous ftp log on
    cd pub/IAL/tools_utils_demos
    get cpuid3.zip

Three source files are included in this .zip file.
    cpuid3a.asm - This source code file contains two assembly language
        functions.  One determines the type of cpu from 8088/8086 to
        Pentium.  The second detects and identifies, if present, the
        type of math coprocessor.
    cpuid3b.c - a c program that calls the above two functions and
        displays the results.
    cpuid3c.asm - this is an assembly program equivalent to cpuid3b.c.

9.2  CPUID INSTRUCTION

On some 486 and all Pentium processors, Intel has included an
undocumented CPUID instruction.  More information on this instruction
and how to tell if a processor supports this instruction, see Ralf
Brown's OPCODE.LST, Subject #11).

You also can get the word directly from Intel

    ftp ftp.intel.com
    anonymous log on
    cd pub/IAL/Software_specs
    get cpuap.zip

    The file in the .zip file describes the CPUID instruction,
explains the evolution of CPU detections strategies and includes the
source code for the CPUID program.  UNFORTUNATELY, the format for the
file is a postscript print file.  To get a human readable copy, it
must be sent to a postscript printer!

Contributor: Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 5 Jan 95  

------------------------------

Subject: 10. IRQ Assignments

A list of IRQ assignments are available in David Jurgens' HELPPC
database.  See Subject #6 for details on how to obtain this program.

Contributor: Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 28 Dec 94  

------------------------------

Subject: 11. Ralf Brown's Interrupt List

The latest version of Ralf Brown's Interrupt List is 4.4.  It is dated
Jan 95.  The last few versions has been split into two versions, DOS
and Windows Help File.

DOS version filenames are: inter44a.zip, inter44b.zip, inter44c.zip, 
    inter44d.zip and inter44z.zip
Window Help File version filename is: intw44.zip.  The last version
    was in three .zips files.  This new .zip file is over 3 megs.

11.1  FILE AVAILABILITY

The files are available from one of SimTel's mirrored sites under the
SimTel/msdos/info subdirectory.  Some of these sites are:

    oak.oakland.edu         nic.funet.fi
    wuarchive.wustl.edu     src.doc.ic.ac.uk
    ftp.uu.net              archie.au
    
11.2  DOS VERSION

The DOS version first displays an index of interrupts.  The index
format is:  column 1 - interrupt number; column 2 - the AH register
value, generally the interrupt function number, if used; column 3 -
the AL register value, generally the interrupt subfunction number, if
used; and column 4 - a short description.  More detailed information
about an entry is available by highlighting the desired entry and
pressing enter key.

This interrupt list is very extensive.  Included are interrupts used
by various software packages that capture software interrupts and
various pieces of hardware that use interrupts as part of their
interface.  This list even has the interrupts used by several viruses
to determine their presence!
    
These .zip files also contain many other little gems.  These are:

OVERVIEW.LST - A brief description of each of the 256 interrupts.
86BUGS.LST - A list of undocumented and buggy instructions with
    descriptions of the x86 Intel processor and compatible processors. 
    And you thought that the Intel FDIV was the first bug in a
    processor!
CMOS.LST - a CMOS memory map.
OPCODE.LST - A list of undocumented instructions and documented
    instruction of any last processor.
PORTS.LST - I/O port addressed for XT, AT and PS/2 computers.
GLOSSARY.LST - glossary of PC terms.
MEMORY.LST - The format for various memory locations, such as the BIOS
    Data Segment, Interrupt Vector Table, and much, much more.

This version requires just under 5 Megs of disk space.

11.3  WINDOWS HELP FILE FORMAT

This version contains all the information that is contained in the DOS
version.  The difference is that  information in hypertext format so
that user can access it using the Windows Help program.  A nice
feature of this format is that it contains hot-links, an easy to use
database structure with categories, indexes and directories.  Plus,
using the Help search feature, users can search the database for
keywords.

This version requires just over 10 Megs of disk space.
 
Contributor: Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 19 Jan 95 

------------------------------

Subject: 12. Using VGA Mode 13h for Fast Graphics
 
12.1  INTRODUCTION AND PREPARATION
 
Mode 13h is so widely used for graphics applications in DOS because it
is very easy to use.  The screen is constantly being redrawn by the
video card.  To affect what the card draws, it is necessary to write
to the screen buffer.  The screen buffer in mode 13h is always at
segment:offset = A000:0000.  Thus, to set up drawing directly to the
video buffer, this is what you'd most often first do:
 
  ;Change the video mode to 13h
    xor ah, ah          ;VIDEO Function 00h: Change screen
    mov al, 13h         ;Put the desired graphics mode into AL
    int 10h             ;Call VIDEO
 
  ;Prepare for writing to the video buffer
    mov di, 0a000h      ;Put the video segment into DI
    mov es, di          ; so it can easily be put into ES
    xor di, di          ;Start writing at coordinates (0,0)
 
12.2  WRITING PIXELS TO THE SCREEN
 
Why is Mode 13h so popular?  To understand, you must know a few basic
facts.  In Mode 13h, the screen is 320 by 200, or 320 pixels across
and 200 pixels down.  In each pixel, there's a possibility of 256
colors, which can be fit into one byte.  Thus, 320*200*1 = 64000
bytes, about the size of one segment.  Think of the screen as an array
of colors.  The first row takes up addresses A000:0000 to A000:013F
(decimal 319), the second row takes up addresses A000:0140 to
A000:027F (decimal 639), and so on.  To plot a pixel, assuming
ES=A000:

  ;Plot a pixel in video mode 13h, where
  ;PixelAddress = (320 * Y) + X
    mov ax, 320     ; Prepare for the multiplication  
    mul [Y]         ; Assuming that Y is defined in the data segment
                    ;   earlier in the program
    mov di, ax      ; Put in into the pointer to the offset of ES
    add di, [X]     ; Assuming that X is defined in the data segment
                    ;   earlier in the program
    mov al, [Color] ; Assuming that Color is defined in the data
                    ;   segment earlier in the program
    stosb           ; Write it to the screen!

See how easy that was?  Something to remember is that it is
zero-based.  The upper-left corner is (0,0), and the lower-right is
(319,199).  A complete TASM Ideal mode procedure might look something
like this (it assumes that the video card is already set to mode 13h):
 
PROC WritePixel BASIC   ; Or whatever language you might want to link
                        ;  it to
    USES es, di         ; It's always a good idea to preserve ES and 
                        ;  DI
    ARG X:word, Y:word, Color:BYTE
    mov di, 0a000h      ; Put the video segment into DI
    mov es, di          ;   so it can easily be put into ES
    mov ax, 320         ; Prepare for the multiplication
    mul [Y]             ; Offset pointer by the Y value passed in
    mov di, ax          ; Put in into pointer to the offset of ES
    add di, [X]         ; Offset the pointer by the X value passed in
    mov al, [Color]     ; Put color to be written to the screen in AL
    stosb               ; Write it to the screen!
    ret
ENDP WritePixel

To write a horizontal line, just put the length in CX, and replace the
STOSB with a REP STOSB.  Writing a vertical line is only a little more
tricky.  Observe the following TASM Ideal mode procedure:

PROC VerticalLine BASIC ; Or whatever language you might want to link
                        ;  it to
    USES es, di         ; It's always a good idea to preserve ES and
                        ;  DI
    ARG X:word, Y:word, Color:BYTE, Length:word
    mov di, 0a000h      ; Put the video segment into DI
    mov es, di          ; so it can easily be put into ES
    mov ax, 320         ; Prepare for the multiplication  
    mul [Y]             ; Offset the pointer by the Y value passed in
    mov di, ax          ; Put in into the pointer to the offset of ES
    add di, [X]         ; Offset the pointer by the X value passed in
    mov al, [Color]     ; Put the color to be written to the screen in
                        ;  AL
    mov cx, [Length]    ; Prepare for the loop
YLoop:
    stosb               ; Write it to the screen!
    add di, 319         ; Move down one row (DI has already advanced
                        ;  once because of the STOSB, thus the 319)
    loop YLoop
    ret
ENDP VerticleLine
 
Observe how there is a tight loop that moves DI down one row each
iteration.
 
In short, the easiest way to write directly to the Mode 13h video 
buffer is to think of the screen as just a 320 by 200 array of bytes,
starting at A000:0000.
 
Author: Michael Averbuch (mikeaver@prairienet.org)
Last Change: 29 Dec 94

------------------------------

Subject: 13. Real Mode/Protected Mode

            OPEN

I really need some one to volunteer to author this section.

Contributor: 
Last changed:  

------------------------------

Subject: 14. Shareware ASM Libraries

14.1  ASMLIB PROGRAMMER'S TOOLKIT, VERSION 3.7

Douglas Herr's shareware assembly language library.  This library is
available from one of the SimTel mirror sites.

    ftp oak.oakland.edu
    anonymous log on
    cd SimTel/msdos/asmutil
    get asmlib37.zip

The zip file contains only the medium model of the library.  There are
405 assembly subroutines in a .lib file and documentation.  Source
code is available with registration and extra fee.  The library covers
the following areas:
    string and integer data manipulation
    disk & file subroutines
    EMS and XMS subroutines
    floating-point subroutines
    graphics
    keyboard input subroutines
    screen mode subroutines
    text-mode multi-window subroutines
    mathematical solutions
    subroutines which determine PC status
    text-mode video subroutines

asmlib37 also comes with an editor, E16, written entire with asmlib.

14.2  THE ASSEMBLY WIZARD'S LIBRARY, VERSION 1.6

This is Thomas Hanlin's shareware assembly language library.  This
library is available from one of the SimTel mirror sites.

    ftp oak.oakland.edu
    anonymous log on
    cd SimTel/msdos/asmutil
    get asmwiz16.zip 

This library comes with documentation and one .lib file that supports
small and tiny memory models.  Source code is available with
registration. The library covers the following areas:

    Base Conversions        Mouse Services
    Exception Handling      Sound and Music
    Delays and Countdowns   String Services
    File Handling           Telecommunications
    Filename Manipulation   Time and Date
    Keyboard Services       Video Services
    Long Integer Math       Miscellaneous Services
    Memory Services

14.3  UCR Standard Library for Assembly Language Programmers

This library is written by Randall Hyde and others.  Unlike the
previous libraries, there is no registrations fees and the included
source code is released to the public domain.  The author does request
that if you use the library, you contribute at least one routine to
the library.
    Standard Input Routines     Character Set Routines
    Standard Output Routines    Memory Management Routines
    Conversion Routines         String Handling Routines
    Utility Routines

14.4  ALIB Version 3.0

ALIB is Jeff Ownens' shareware assembly language library.  Like the
UCR library described above, registration fees are not requested.  The
library consists of 179 assembly source files covering the following
areas:
    compress    - data compression and expansion
    config      - program configuration, colors, paths, etc.
    compare     - compare strings
    convert     - hex/decimal/ascii conversions
    database    - simple database functions
    disk        - disk information, path changes, file searches
    display     - fast display functions, write to display memory
    error       - error handlers
    float       - simple floating point math package
    math        - dword math, crc, roots
    memory      - memory manager, extended, xms, ems, conventional
    menu        - menuing system
    message     - messages in windows on screen
    misc        - misc routines
    mouse/key   - mouse and keyboard functions
    parse       - extraction of parameters from command line
    random      - random number generators
    search      - search for character or string
    sort        - sort buffer or file
    sound       - sounds 
    string      - ascii string handling
    stdout      - characters, strings, spaces to stdout
    system      - system interrogation and setup
    time        - time and date conversions

Contributor: Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 1 Jan 95  

------------------------------

Subject: 15. How To Determine If A Pentium With The FDIV Problem Is
Present

The following is a short assembly language program that can
detect the FDIV error: (It has been pointed out to me that the test
against zero may lead to a false positive.  On my 387, the result is
exactly zero so that is why I coded it that way.  PENERR has been
tested on and identifies a Pentium with the FDIV error.)

=================================================================
;   PENERR.ASM - Determines if Pentium FDIV error is present
;   Version 1.00
;   Copyright 1994 - Raymond Moon
;   This program is free for all to use.
    .286
    .287
DGROUP  GROUP   _TEXT, _DATA
_DATA   SEGMENT PARA PUBLIC 'DATA'  ; Data segment
x   dd      4195835
y   dd      3145727
OK  byte    'No Error$'
ERR byte    'Pentium Error Present', 7, '$'
_DATA   ENDS

_TEXT   SEGMENT WORD PUBLIC 'CODE'  ; Code segment
    assume cs:DGROUP, ds:DGROUP
        org 100h
START:  finit
        fld x
        fld st
        fld y               ; 0 = y; 1 & 2 = x
        fdiv    st(2), st   ; 0 = y; 1 = x; 2 = x/y
        fmulp   st(2), st   ; 0 = x, 1 = (x/y)*y
        fsubp   st(1), st   ; 0 = (x/y)*y-x => should be zero
        fldz                ; 0 = 0; 1 = (x/y)*y-x
        fcomp   st(1)       ; Is it zero
        fstsw   ax          ; get control word
        ffree   st(1)
        ffree   st
        sahf                ; load flag register
        jz      EQUAL       ; If C3 not set, result = 0
        lea dx, ERR         ; DS:DX => ERR
        jmp     OUTPUT
EQUAL:  lea dx, OK          ; DS:DX => OK
OUTPUT: mov ah, 9h          ; Display string
        int 21h
        int 20h             ; Terminate program
_TEXT   ends
        end START
=================================================================
penerr.com in uuencode for those who do not want to assemble the above
source code.
=================================================================
begin 644 penerr.com
MF]OCV09``=G`V09$`=SZWLK>Z=GNV-F;W^#=P=W`GG0&C191`>L$C19(`;0)
MS2'-(````````````````````/L%0`#__R\`3F\@17)R;W(D4&5N=&EU;2!%
.<G)O<B!0<F5S96YT!R1R
`
end

Contributor: Raymond Moon, raymoon@dgs.dgsys.com
Last changed: 5 Jan 95  

 



