home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / assembly-language / x86 / general / part3 < prev   
Encoding:
Text File  |  2000-03-22  |  37.7 KB  |  1,046 lines

  1. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!howland.erols.net!pants.skycache.com.MISMATCH!triton.skycache.com!portc01.blue.aol.com!portc.blue.aol.com!feed.newsreader.com!news!not-for-mail
  2. From: raymoon@ms1.dgsys.com (Raymond Moon)
  3. Newsgroups: alt.lang.asm,comp.lang.asm.x86,news.answers,alt.answers,comp.answers
  4. Subject: x86 Assembly Language FAQ - General Part 3/3
  5. Supersedes: <89sf1e$stn$3@news.dgsys.com>
  6. Followup-To: alt.lang.asm,comp.lang.asm.x86
  7. Date: 21 Mar 2000 23:03:27 GMT
  8. Organization: MoonWare
  9. Lines: 1020
  10. Approved: news-answers-request@MIT.EDU
  11. Distribution: world
  12. Expires: Thu, 20 Apr 2000 23:59:59 GMT
  13. Message-ID: <8b8v3v$n7i$3@news.dgsys.com>
  14. Reply-To: raymoon@moonware.dgsys.com
  15. NNTP-Posting-Host: dgs.dgsys.com
  16. X-Trace: news.dgsys.com 953679807 23794 207.154.12.1 (21 Mar 2000 23:03:27 GMT)
  17. X-Complaints-To: usenet@news.dgsys.com
  18. NNTP-Posting-Date: 21 Mar 2000 23:03:27 GMT
  19. Summary: This is the FAQ for the x86 Assembly Language programmers for
  20.  the alt.lang.asm and comp.lang.asm.x86 newsgroups.  This particular
  21.  section of the FAQ is part three of three parts that contain x86
  22.  assembly language information common to all assemblers.
  23. Keywords: x86 Assemby Language ASM FAQ General
  24. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  25. Xref: senator-bedfellow.mit.edu alt.lang.asm:25272 comp.lang.asm.x86:83705 news.answers:179901 alt.answers:47942 comp.answers:40154
  26.  
  27. Archive-Name: assembly-language/x86/general/part3
  28. Posting-Frequency: monthly (21st of every month)
  29. Last-modified: 2000/02/20
  30.  
  31. ------------------------------
  32.  
  33. Subject: 26.  WWW Assembly HomePages
  34.  
  35. 26.1  CAUTION
  36.  
  37. Individuals maintain all of the web sites listed here.  I will strive to
  38. maintain this list current but do not be surprised if the addresses no
  39. longer are current.
  40.  
  41. 26.2 ASSEMBLY LANGUAGE RELATED HOME PAGES
  42.  
  43. Randy HydeÆs Assembly Language Page
  44.     http://webster.ucr.edu/Page_asm
  45.         Excellent tutorial, Art of Assembly Language
  46.         ASM Style Guide
  47.  
  48. Christian LudoffÆs 80x86 Sandpile Page
  49.     http://www.sandpile.org  Basic Page
  50.     http://www.sandpile.org/80x86/overview.shtml
  51.         The second page is where you should kept you link.  Much good
  52.             information is available at this site.
  53.  
  54. EG3 Electronic CommunicationÆs Electronic EngineerÆs Toolbox
  55.     http://www.eg3.com/softd/assembly.htm
  56.     http://www.eg3.com/softdv/assembly.htm
  57.     http://www.eg3.com/softd/assmhot.htm
  58.         Assembly Language Hot Lists and Major Resources.
  59.  
  60. Robert Collins' x86 Monthly Digest
  61.     http://www.x86.org/
  62.         Intel processor bugs
  63.         Intel data sheets and programming manuals
  64.         In-Depth articles
  65.         Productivity ehancements and programming tips
  66.         Rober CollinsÆ Dr. DobbÆs Journal Undocumented Corner.
  67.         Much more
  68.  
  69. Jannes Faber's Assembly home page
  70.     http://www.fys.ruu.nl/~faber/Amain.html
  71.         List of ASM Books with short reviews
  72.         A few hints and tricks
  73.         Complete source code to some of his programs
  74.         A listing of EMS Professional Shareware products
  75.  
  76. Ray Rose's HTML For Assembler home page
  77.     http://www.alaska.net/~rrose/assembly.htm
  78.         An extensive list of ASM books without descriptions
  79.         Links to alt.lang.asm, comp.lang.asm.x86, and
  80.             alt.msdos.programmer newsgroups.
  81.         Link to the Yahoo/Computers and Internet/Languages/Assembly page
  82.             (see below)
  83.  
  84. NASM: The Netwide Assembler Project
  85.     http://www.cryogen.com/nasm
  86.     A group of programmers are writing a new assembler.  This home page
  87.         describes the project and where to download the latest version.
  88.  
  89. Michael Babcock's Programming Home Page (many broken links on pages)
  90.     http://w3.tyenet.com/mbabcock/mtb.programming.html
  91.         This home page has links to:
  92.             Optimizing 803/4/586 ASM Programming
  93.                 http://w3.tyenet.com/mbabcock/prg.optimize.html
  94.             ASM Tutorial
  95.                 http://w3.tyenet.com/mbabcock/prg.asmtut1.html
  96.             Utilities
  97.                 http://w3.tyenet.com/mbabcock/prg.utils.html
  98.  
  99. The Official Web Shareware Site
  100.     http://www.jumbo.com/pages/programming/dos/asmutl/
  101.         This site appears to have a few ASM files not on SimTel.
  102.  
  103. Dr. ASM's Assembly Home Page
  104.     http://web.syr.edu/~dbgrandi/assembly.htm
  105.     Some answered questions and links to other assembly related sites.
  106.  
  107. James Vahn's 80xxx Snippets - 80x86 Assembly Language Enthusiasts
  108.     http://www.cet.com/~jvahn
  109.         Download snippets & Booklist
  110.  
  111. Kip Irvine's Assembly Language Sources
  112.     http://www.nuvisionmiami.cim/kip/asm.htm
  113.  
  114. Gavin Estey's Home
  115.     http://www.strangecreations.com/library/assembly/index.htm
  116.         His ASM tutorial, other ASM Links, FAQs and Optimizations
  117.  
  118. Grzegorz Mazur's x86 CPU Stuff
  119.     http://grafi.ii.pw.edu.pl/gbm/x86/index.html
  120.         x86 CPU identification algorithms
  121.         Cyrix/IBM5x86/6x86 (and 486) control program
  122.         Links to other information on x86 family CPUs
  123.  
  124. Heath Holcomb's x86 Assembly Page
  125.     http://www.wfu.edu/~holcojh5/x86asm/x86asm.html
  126.         Some pointers on what is assembly language, what is assembly
  127.             good for, and what do you need to get started.
  128.         Pointers to ASM Tutorial, this FAQ, other ASM web pages
  129.  
  130. Eric Isaacson's A86 Assembler and D86 Debugger Page
  131.     http://eji.com/a86/index.htm
  132.         Overviews of a86 and a386 assemblers, d86 and d386 debuggers,
  133.             download and purchase of a86 and d86.
  134.  
  135. Tore Nilsson's Assembly Tutorial Page
  136.     http://www.ice-digga.com/programming/
  137.         VLA's Assembly and DMA programming tutorials, Asphyxia's VGA
  138.             tutorials, and some graphics and sound programming
  139.             information.
  140.  
  141. Gerd KortemeyerÆs 387/486DX/Pentium/Floating Point Processor Stuff
  142.     http://www.nscl.msu.edu/~kortemey/copro.html
  143.         A collection of assembler routines written for Turbo Pascal and
  144.         C++.  Most of the comments are in German after an English
  145.         introduction.
  146.  
  147. CameronÆs 386+ Programming Page             NOT CURRENTLY WORKING
  148.     http://free.prohosting.com/~cameron/
  149.         32 bit DOS extender/Utilities/pmode extender
  150.         File formats and specifications/Game programming
  151.         Knowledge Base with ASM tutorials, DenthorÆs VGA Trainer and
  152.             Univ. of Guadalajara ASM tutorial
  153.  
  154. PeterÆs PMODE Home Page
  155.     http://www.geocities.com/SiliconValley/Peaks/1231/
  156.         Pmode tutorials and programming related files
  157.  
  158. Niko KominÆs Assembler for PCS page
  159.     http://www.inx.de/~nkomin/html/assembe.htm
  160.         Shareware, pmode, x86 mnemonics, ASM related links.
  161.  
  162. Alexandre Zvenigorosky IIIÆs Programs for PC 386+
  163.     http://www.cpod.com/monoweb/zveni/prg.html
  164.         ZvenigoroskyÆs assembler and debugger, currently documentation
  165.             only in French.
  166.  
  167. Rich ElberÆs ValArrow (286 Assembler) Page
  168.     http://www.geocities.com/SiliconValley/Heights/7052/valarr2.html
  169.         Links to Arrowsoft Assembler, ZD86 debugger, discussion of
  170.             ArrowsoftÆs Assemblers deviations from MASM.
  171.  
  172. Kurt I. GroenbechÆs Alab Homepage
  173.     http://www.nano.no/~espeng/alab/
  174.         Home page for the Assembler Laboratory that is an IDE for
  175.             assemblers
  176.  
  177. Christian KurzkeÆs Advanced x86 Assembly Programming
  178.     http://wwwcip.informatik.uni-erlangen.de/user/cnkurzke/hwkmcs/index.html
  179.         Excerpts from lessons given at Adalbert Stifter Gymnasium in
  180.             1989
  181.  
  182. Bob RichardsonÆs PC Assembly Language Page
  183.     http://lexitech.com/bobrich/
  184.         Eighteen topics taken from his SELFIN PC Assembly Language
  185.             Group.
  186.  
  187. Jesper PedersenÆs Processor Information Page
  188.     http://www.imada.ou.dk/~jews/PInfo/intel.html
  189.         List of instructions and opcodes used by Intel, AMD, Cyrix and
  190.             Nexgen.
  191.  
  192. QuantasmÆs x86 and Pentium Programming Tips and Info
  193.     http://www.quantasm.com/freeinfo.html
  194.  
  195. Steve KempÆs Assembly Language Programming Index  (Not currently
  196. working)
  197.     http://www.dcs.ed.ac.uk/home/skx/asm/index.html
  198.         Assembly Language Newbie information.  A86 Source Code
  199.  
  200. Ferdi SmitÆs Assemble It! Page
  201.     http://www.xs4all.nl/~smit/
  202.         His own source code, 3D programming, his own ASM tutorial,
  203.             optimization and other information.
  204.  
  205. Paul Hsieh's x86 Assembly Language Page
  206.     http://www.geocities.com/SiliconValley/9498/asm.html
  207.         Feature articles, Optimization and General
  208.             Programming/References
  209.  
  210. Jaap Harm's 80x86 Assembly Page             (Not currently working)
  211.     http://home.worldonline.nl/~jaapharm/
  212.         Tutorial, source code and links
  213.  
  214. Charles Winneræs ASM Resources              (Not currently working)
  215.     http://www.cse.utoledo.edu/%7Ecwinner/assembly.html
  216.  
  217. G. Adam StanislavÆs Whiz Kid Technomagic
  218.     http://www.geocities.com/SiliconValley/Heights/7394/
  219.         Win95 Assembly Language source code examples
  220.  
  221. John EckerdalÆs Assembly Page
  222.     http://www.geocities.com/SiliconValley/Park/6452/index.html
  223.         Nice collection of Assembly Gems.
  224.  
  225. Gaz's Little Web Programming Page
  226.     http://www.fortunecity.com/skyscraper/fatbit/427/programming.html
  227.         Protected Mode Tutorial and large library of NASM source code
  228.         written for the WDosX 32 bit DOS extender
  229.         
  230. Christopher GieseÆs Triple Fault Club
  231.     http://www.netwurx.net/~geezer/os/index.htm
  232.         NASM and DJGPP Code, Protected Mode Code, OS Code
  233.  
  234. The Bass Demon's Operating System Theory Page
  235.     http://home.c2i.net/tkjoerne/os/index.htm
  236.         Information on Hard Disks, Partitioning and Booting, FAT
  237.         specific file system information, File system theory article,
  238.         Available assembler source codes and Memory Management
  239.  
  240. OS Development Page
  241.     http://milkyway.isa.net.au/os-dev/index2.html
  242.         Documentation, Links, Source files, Bulletin Board
  243.  
  244. The NASM Advocate
  245.     http://people.mw.mediaone.net/nasm/index.html
  246.         NASM source code, documentation (HTML format), NASM specific
  247.         IDE, NASM Links, NASM Mailing List and NASM Mailing List
  248.         Archives
  249.  
  250. Anthony's Programming Page:
  251.     http://www.geocities.com/SiliconValley/Network/4311/
  252.         Home of ALINK, a freeware linker for MSDOS and Win32. It links
  253.         Intel/Microsoft OMF object and library files, to MSDOS COM and
  254.         EXE files, and PE files for Win32 (including DLLs). Source code
  255.         (ANSI C) is also available for download û this should compile
  256.         with any 32-bit ANSI C compiler.
  257.  
  258. Craig Peacock's Interfacing the PC Page
  259.     http://www.senet.com.au/~cpeacock/
  260.         Much information about interfacing with the parallel and serial
  261.         ports, information about IRQs and AT keyboards, and many links
  262.         to more technical information.
  263.  
  264. Chris Dragan's Home Page
  265.     http://ams.ampr.org/cdragan/
  266.         His own programs and assembler source code, Win32 programs.
  267.  
  268. David Lindauer's LADSoft Computer Page
  269.     http://www.ladsoft.com
  270.         PMODE Information
  271.         Windows assembly demos for TASM
  272.         MSDOS Demo/utility programs
  273.  
  274. Jan Wagemakers' Linux and Assembler Home Page
  275.     http://bewoner.dma.be/JanW/eng.html
  276.  
  277. Brennan's Guide to Inline Assembly
  278.     http://www.rt66.com/~brennan/djgpp/bgtia.html
  279.         Information on AT&T syntax
  280.  
  281. Dr. Carter's PC Assembly Programming Code Page
  282.     http://www.comsc.ucok.edu/~pcarter/pcasm/code/
  283.         Much NASM code
  284.  
  285. Gustavo Net's ASM page
  286.     http://www.gustavo.net/programming/asm.shtml
  287.         Links to tutorials, Programmer's Forum, source code, and more.
  288.  
  289. Henry S. Takeuchi's Windows 95 Assembly Language Programming
  290.     http://www.eskimo.com/~htak/win95asm/win95asm.htm
  291.         Source code and tutorial
  292.  
  293. Glenn Strycker's The International Brotherhood of Assembly/Machine
  294. Programmers (IBAMP)
  295.     http://www.members.kconline.com/strycker/IBAMP/index.html
  296.         Assembly Chat and Forum, links, source code
  297.  
  298. Alexei A. Frounze HomePage!
  299.     http://alexfru.chat.ru/eindex.html
  300.         Protected Mode information, many ASM Links, V86 Mode Monitor
  301.         Tutorial, COFF Utilities
  302.  
  303. Linux/i386 assembly programming page
  304.     http://linuxassembly.org
  305.         Linux assembly documentation, tutorials and utilities. Many
  306.         Linux related links.
  307.  
  308. Alex Verstak Programming Page
  309.     http://members.tripod.com/~averstak/
  310.         Much disk structure, e.g., boot, FAT, directory and filenames û
  311.         short and long
  312.  
  313. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  314. Last changed: 20 Feb 2000
  315.  
  316. ------------------------------
  317.  
  318. Subject: 27.  Common Reason Why Memory Allocation Fails
  319.  
  320. 27.1  BACKGROUND
  321.  
  322. A common error received when first learning to use Int 21h Function 48h,
  323. allocate memory, is error code 8, insufficient memory available.
  324. Usually, the programmer then writes a small program that only allocates
  325. memory, and the program still fails.  This situation is quite puzzling
  326. because there should be hundreds of kilobytes of memory available but
  327. this function reports that there is insufficient memory for a few
  328. hundred bytes.  The reason is that DOS generally allocates all available
  329. memory above the loaded program to that program.  Therefore, there is no
  330. more memory to allocate, so the request fails.
  331.  
  332. 27.2  .COM FILES
  333.  
  334. Since a .COM file does not contain any header information, the DOS
  335. loader has no way of determining how much memory is required for a
  336. program beyond the physical size of the program.  Even this number is
  337. deceptive because it does not include a stack.  Therefore, DOS always
  338. allocates all available memory above the program to the program.
  339.  
  340. To use the allocate memory function, the programmer must release that
  341. extra memory using Int 21h Function 4ah, Set Memory Block Size.  Given
  342. that generally there is more that 64 Kbytes of memory, the DOS sets
  343. Stack Top to just under that value, it is generally safe to release all
  344. memory above 64 Kbytes.
  345.  
  346. 27.3 .EXE FILES
  347.  
  348. The amount of memory the DOS allocates to the loaded program depends
  349. upon a value in the .EXE header.  This value is called Maximum
  350. Allocation and is a word starting at offset 12.  This value specifies
  351. the number of 16-byte paragraphs beyond the image size wanted by the
  352. program to execute.  This value must be equal or greater than the
  353. Minimum Allocation, which is the number of 16-byte paragraphs beyond the
  354. image size required by the program to execute.  This space generally
  355. contains uninitialized variables and the stack.
  356.  
  357. The value of Maximum Allocation is set by the /CPARM Option for the
  358. Microsoft Linker.  By default, the linker sets this value to 0ffffh that
  359. will causes DOS to allocate the largest block of available memory.  This
  360. memory can be used as a heap, print buffer, etc.
  361.  
  362. 27.4  DETERMINING HOW MUCH MEMORY IS AVAILABLE TO A PROGRAM
  363.  
  364. In the PSP, at offset 02h, DOS loads a word that is the segment address
  365. of the next Memory Control Block or Arena.  Subtracting the PSP from
  366. that value at offset 02h will be the number of memory paragraphs
  367. allocated to the program.  The number of bytes can be calculated by
  368. shifting that number to the left by 4 bits, multiplying by 16, the size
  369. of a memory paragraph.
  370.  
  371. 27.5  HOW TO DEALLOCATE MEMORY AT THE START OF A PROGRAM
  372.  
  373. If you want to load and execute another program, you must release memory
  374. to make room for the program.  Also, since the largest chunk of memory
  375. is allocated already to the program, all requests to allocate memory
  376. generally fail.
  377.  
  378. Again, to use the allocated memory function, the programmer must release
  379. the extra memory above the program use as for a .COM file above.  The
  380. problem here is where is the end of the program.  The answer is not as
  381. simple as with the .COM file.  There are two basic solutions.
  382.  
  383. 1.  If you use the .dosseg option, the Microsoft Linker will define a
  384. label, _end, at the end of the DGROUP.  Since the .dosseg option also
  385. places any FAR data segments between the code and DGROUP segments, you
  386. can release all memory above that label.
  387.  
  388. 2.  If you do not want or are unable to use the first option, use an
  389. include file which declares all segments used by your program.  Define a
  390. label in the last segment and use it as the _end label in the first
  391. example.
  392.  
  393. 27.6  TELLING DOS NOT TO ALLOCATE ALL AVAILABLE MEMORY AT STARTUP
  394.  
  395. If you are using a Microsoft Linker or a compatible linker, you can use
  396. the /CPARMMAXALLOC or /CP switch.  Set this switch to /CP:1.  The Linker
  397. places 1 at offset 0ch in the .exe header.  This tells DOS that you only
  398. need a maximum of 1 paragraph of memory above your program.  DOS
  399. compares this to the minimum memory required at offset 0ah in the .exe
  400. header.  If the max is less than the minimum, DOS assigns the minimum.
  401. Therefore, your program gets only the memory necessary for it to
  402. execute, and all other memory above your program is available for
  403. allocation.
  404.  
  405. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  406. Last changed: 21 Feb 99
  407.  
  408. ------------------------------
  409.  
  410. Subject: 28.  Volume Serial Numbers
  411.  
  412. 28.1  VOLUME SERIAL NUMBER FORMAT
  413.  
  414. The volume serial number was introduced with DOS 4.0 as part of an
  415. extended boot record and is created through you either FORMAT a disk or
  416. use DISKCOPY to create another disk.  The serial number is a function of
  417. the time/date of the formatting or the diskcopying.  Note that DISCOPY
  418. generates a new volume serial number so a DISKCOPY is not an exact image
  419. of the source diskette.
  420.  
  421. 28.2  CALCULATING THE VOLUME SERIAL NUMBER
  422.  
  423. For example, say a disk was formatted on 26 Dec 95 at 9:55 PM and 41.94
  424. seconds.  DOS takes the date and time just before it writes it to the
  425. disk.
  426.  
  427. Low order word is calculated:               Volume Serial Number is:
  428.     Month & Day         12/26   0c1ah
  429.     Sec & Hundrenths    41:94   295eh               3578:1d02
  430.                                 -----
  431.                                 3578h
  432.  
  433. High order word is calculated:
  434.     Hours & Minutes     21:55   1537h
  435.     Year                1995    07cbh
  436.                                 -----
  437.                                 1d02h
  438.  
  439. Note that DOS interrupt 21h Functions 2ah, Get DOS Date, and 2ch, Get
  440. DOS Time, are particularly suited to getting the date and time for
  441. calculating the Volume Serial Number.
  442.  
  443. 28.3 READING AND SETTING THE VOLUME SERIAL NUMBER
  444.  
  445. To read the Volume Serial Number, use the IOCTL call, Int 21h function
  446. 440dh Minor Code 66h, Get Media ID.  To write the Volume Serial Number,
  447. use the IOCTL call, Int 21h function 440dh Minor Code 46h, Set Media ID.
  448.  
  449. WARNING!  These IOCTL calls use a structure that also contains the
  450. volume label and file system type.  So that you do not create errors
  451. with these values, I recommend that you always Minor Code 66h to
  452. initialize the structure before setting the Volume Serial Number to a
  453. new value and writing it back to the disk.
  454.  
  455. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  456. Last changed: 17 Feb 96
  457.  
  458. ------------------------------
  459.  
  460. Subject: 29.  .obj File Format
  461.  
  462. 29.1  INTEL
  463.  
  464. There are two sources for this information.  The first is available from
  465. Intel.  The Tools Interface Standards Committee has prepared the
  466. following documents:
  467.  
  468.     ftp://ftp.intel.com/pub/tis/omf11g.zip
  469.  
  470. The readme file in each .zip file states that the document is the
  471. Relocatable Object Module Format Specification, V1.1.
  472.  
  473. Unfortunately, both files unzip into documents formatted for Postscript
  474. printers.  Adobe's Acrobat can not display them, but Ghostscript can.
  475. If you need GhostScript, you can get it from the following site.  Read
  476. the ftp://ftp.cs.wisc.edu/pub/ghost/aladdin
  477.  
  478. 29.2  MICROSOFT
  479.  
  480. The second is from Microsoft.  This file is located at:
  481.  
  482.     ftp://ftp.microsoft.com/Softlib/MSLFILES/ss0288.exe
  483.  
  484. This file expands into ascii text files that are the Microsoft Product
  485. Support Services Application Note: Relocatable Object Module Format.
  486. These files date from 1992.  Also included are the .lib file format and
  487. the CodeView extensions.
  488.  
  489. 29.3  COFF format
  490.  
  491. This information is specific for DJGPP COFF but is this the same as used
  492. by Microsoft (I believe)
  493.     http://www.delorie.com/djgpp/doc/coff/
  494.  
  495. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  496. Last changed: 25 Oct 98
  497.  
  498. ------------------------------
  499.  
  500. Subject: 30.  Rebooting from Software
  501.  
  502. 30.1  WARM AND COLD REBOOT
  503.  
  504. Within DOS, there are two types of rebooting.  There is the warm reboot
  505. that is evoked by pressing the "Ctrl-Alt-Del" key combination.  During
  506. this reboot, all Power On System Tests, POSTs, are performed with the
  507. exception of the memory tests.  In addition to the POSTs, interrupt
  508. vectors are reinitialized and system timers reinitialized.  In other
  509. words, the BIOS code initializes the computer system to such a state
  510. that the computer system is ready for loading the operating system.
  511. Issuing an interrupt 19h does the loading of the operating system.
  512.  
  513. The second type of rebooting is a cold reboot that occurs when the
  514. system is turned on.  The only difference between a cold reboot and a
  515. warm reboot is the performing of the memory tests.
  516.  
  517. 30.2  PERFORMING A REBOOT FROM SOFTWARE
  518.  
  519. Whether a cold or warm reboot is performed depends upon the value if the
  520. reset flag in the ROM BIOS data area.  If this flag is set to 1234h, a
  521. warm reset is performed.  Any other value results in a cold reboot.
  522. Usually a zero is loaded for the cold reboot.  Code snippets to do this
  523. are:
  524.  
  525. ROMBIOS_DATA    segment at 0400h
  526.     org 72h
  527. ResetFlag   dw  ?
  528. ROMBIOS_DATA    ends
  529.  
  530. ROMBIOS     segment at 0f000h
  531.     org 0fff0h
  532. Reset   label   far
  533. ROMBIOS ends
  534.  
  535. In your code:
  536.  
  537.     mov ax, seg ROMBIOS_DATA
  538.     mov ds, ax
  539. ASSUME ds:ROMBIOS_DATA
  540.     mov ResetFlag, 1234h        ; or 0 if cold reset is desired
  541.     jmp Reset
  542.  
  543. 30.3  WARNINGS!
  544.  
  545. Neither the warm nor the cold boot flushes buffers, system, smartdrv,
  546. and EMM386, or notifies TSRs.  This can lead to lost of data.  The best
  547. source code that considers most of this is:
  548.  
  549.     ftp://ftp.simtel.net/pub/simtelnet/msdos/bootutil/reboot33.zip
  550.  
  551. Full source code is available.
  552.  
  553. 30.4  JUST USING INT 19H
  554.  
  555. Using this interrupt alone will only reload the operating system onto a
  556. computer system that may not be initialized properly for it.  The
  557. interrupt vectors are not reset but the TSRs that have hooks into the
  558. interrupt table may be overwritten.  Obviously, this can lead to the
  559. system hanging if one of these hooked and overwritten interrupts is
  560. called.  Other problems can be timers not reset or add-on cards not
  561. reinitialized properly.  So, do NOT use Int 19h to reboot the computer.
  562.  
  563. 30.5  USING F000:E05B INSTEAD OF F000:FFF0 AS THE JUMP ADDRESS
  564.  
  565. In the original IBM ROM BIOS, the instruction at f000:fff0 was a long
  566. jump to f000:e05b.  Some programs skipped the jump at f000:fff0 and went
  567. directly to the second address which is the start of the reset procedure
  568. in ROM BIOS.  I checked my 386 with non-IBM BIOS, and the start of the
  569. reset procedure is at the same address.  I believe that using the second
  570. address is dangerous because there is not any guarantee that it will
  571. stay the same.  In addition, if you are rebooting the computer what is
  572. the reason in saving a few cycles!  Stay with the address f000:fff0 as
  573. the jump there always will take the execution path to the correct code.
  574.  
  575. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  576. Last changed: 20 Dec 96
  577.  
  578. ------------------------------
  579.  
  580. Subject: 31.  Other FAQs
  581.  
  582. 31.1  COMP.OS.MSDOS.PROGRAMMER
  583.  
  584. This excellent FAQ is posted every 20 days to comp.os.msdos.programmer,
  585. comp.answers and news.answers newsgroup.
  586.  
  587. It is available from
  588.  
  589.     ftp://rtfm.mit.edu/pub/usenet-by-group/comp.os.msdos.programmer/
  590.  
  591. 31.2  COMMUNICATIONS FAQS
  592.  
  593. The following websites contains many links to communication and hardware
  594. related FAQs, e.g., serial port, game port, keyboard, modem, and LANs.
  595. Most of these FAQs are not approved FAQs so are not found at
  596. rtfm.mit.edu but that is not to say that these are not quality FAQs.
  597. There is much good information.
  598.  
  599.     http://www.webcom.com/~llarrow/comfaqs.html
  600.     http://www.repairfaq.com/filipg/LINK/F_LINKIN.html#LINKIN_003
  601.     http://www2.psyber.com/~tcj/faqnfile.html
  602.  
  603. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  604. Last changed: 25 Oct 98
  605.  
  606. ------------------------------
  607.  
  608. Subject: 32.  Pseudo Random Number Generator in Assembly Language
  609.  
  610. Mark Adler wrote a set or pseudo random number generators based upon
  611. algorithms from Knuth's "Art of Computer Programming", vol 2, 2nd ed.
  612. The file comes with full assembly source and .obj files for all major
  613. memory models.  While written to link with Turbo C, the .obj files when
  614. linked with Microsoft C worked well, except for the procedure that
  615. return a double random number.  The reason was that the return protocol
  616. is different between Borland C and Microsoft C.  Once the code was
  617. modified to work with Microsoft C, the code worked well.
  618.  
  619. To test the algorithms, I created an array of 100 random numbers and
  620. then generated random numbers and tried to determine if the original
  621. pattern was ever repeated.  My program kept the length of the longest
  622. matching series.  For real or double, the longest matching series was
  623. one after more than a billion random numbers.  For ints, 0 and 1 as the
  624. only selections produced the longest matching series of 31 matches after
  625. more than a billion random numbers.  Increasing the range of acceptable
  626. numbers quickly reduced the longest matching series to 2 in over 250
  627. million random numbers.  My short testing revealed that the longest
  628. matching series seldom increased after this number.
  629.  
  630. Lastly, to test the distribution, I counted the number of hits for each
  631. number between 0 and 100.  I collected about 100,000 hits for each
  632. number.  The standard deviation was only 319 or less than 0.33%.
  633.  
  634. While my testing was not a rigorous mathematical testing of the
  635. algorithm and its implementation, I believe for most uses, these
  636. procedures are adequate.
  637.  
  638. The file is available:
  639.     ftp://ftp.simtel.net/pub/simtelnet/msdos/turbo_c/tcrnd11.zip
  640.  
  641. Note that the description of this file is inaccurate.
  642.  
  643. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  644. Last changed: 4 May 96
  645.  
  646. ------------------------------
  647.  
  648. Subject: 33.  Command Line Arguments
  649.  
  650. 33.1  WHERE IS THE COMMAND LINE
  651.  
  652. DOS loads the command line into the PSP.  The length of the command line
  653. is stored in a byte at offset 80h.  The command line is stored in the
  654. next 127 bytes starting at 81h.  As, generally, there is a space between
  655. the filename and the start of the command line argument; a space usually
  656. is the first character in this string.  The string is terminated with a
  657. carriage return character, 0dh.
  658.  
  659. At startup for both .COM and .EXE format programs, DS and ES point to
  660. the PSP.
  661.  
  662. 33.2  HOW TO ACCESS THE COMMAND LINE ARGUMENTS
  663.  
  664. See Subject #8, How to Redirect STDERR to a File.  I have written a
  665. demonstration program that contains assembly language startup code that
  666. parses the command line arguments onto the stack and provides them as
  667. argc and *argv[] to the main procedure.  Anyone interested in accessing
  668. command line arguments should look at this code.
  669.  
  670. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  671. Last changed: 15 Jun 96
  672.  
  673. ------------------------------
  674.  
  675. Subject: 34.  Free 32 bit and DJGPP Assemblers
  676.  
  677. 34.1  Brennan Underwood's Guide to Inline Assembly under DJGPP.
  678.  
  679. This is an introduction to inline assembly under DJGPP and is based upon
  680. GCC.  The AT&T/UNIX syntax is explained.  The URL is:
  681.  
  682.     http://www.rt66.com/~brennan/djgpp/bgtia.html
  683.     http://sag-www.ssl.berkeley.edu/~korpela/djgpp_asm.html
  684.  
  685. 34.2  DJGPP QUICK ASM PROGRAMMING GUIDE
  686.  
  687. Andrew Ly has a web page covering:
  688.     URLs to FAQs
  689.     AT&T x86 ASM Syntax
  690.     Some inline ASM information
  691.     converting .obj/.lib files
  692.  
  693. The URL to this page is:
  694.     www.castle.net/~avly/djgpp.html
  695.  
  696. 34.3  FREE 32-BIT X86 ASSEMBLER FAQ/LINUX X86 ASSEMBLY HOWTO
  697.  
  698. Francois-Rene Rideau has authored a FAQ on free 32-bit assemblers or
  699. Linus x86 Assembly HowTo.  It is available:
  700.  
  701.     http://www.eleves.ens.fr:8080/home/rideau/Assembly-HOWTO
  702.     http://www.linuxhq.com/LDP/HOWTO/Assembly-HOWTO.html
  703.  
  704. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  705. Last changed: 21 Feb 99
  706.  
  707. ------------------------------
  708.  
  709. Subject: 35. TERSE Programming Language
  710.  
  711. Jim Neil has just announced his TERSE Programming Language.  TERSE gives
  712. all of the control available in assembly language with the look-and-feel
  713. and ease-of-use found in high-level languages.
  714.  
  715. It is available:
  716.     http://www.terse.com
  717.  
  718. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  719. Last changed: 19 Aug 96
  720.  
  721. ------------------------------
  722.  
  723. Subject: 36. Assembly Language IDEs
  724.  
  725. 36.1    ASMEDIT
  726.  
  727. ASMEDIT is an Integrated Development Environment (IDE) for Assembly
  728. Language programmers.  This IDE has a build in editor that provides
  729. syntax coloring, editing of files up to 256 Mbytes, dissammembly of
  730. short code pieces, and shelling to run external assemblers, linkers,
  731. debuggers and make programs.
  732.  
  733. The real benefit of ASMEDIT is its extensive help.  This help covers:
  734.     80x86 ASM mnemonics up to 686 including FPU and MMX;
  735.     Complete Opcode Tables;
  736.     BIOS Interrupts;
  737.     DOS Interrupts and DOS Functions;
  738.     EMS and Mouse Functions;
  739.     BIOS and DOS Data Structures;
  740.     Diagnostic Codes; and
  741.     VGA programming information.
  742.  
  743. ASMEDIT is available from simtel or any of its mirrors:
  744.  
  745.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/aedt182.zip
  746.  
  747. 36.2  ALAB
  748.  
  749. Assembler Laboratory is an assembler IDE, packed with nice features such
  750. as:
  751.  
  752.     syntax and error highlighting
  753.     proc, macro and data browsers
  754.     tasm, masm, a86 and dlink support
  755.     heuristic scan
  756.     opcode help, extended ascii chart, scan codes, calculator
  757.     much more!
  758.  
  759. The latest version is available from the authorÆs homepage:
  760.     http://www.nano.no/~espeng/alab/
  761.  
  762. 36.3 ASMIDE
  763.  
  764. The latest version of ASMIDE, 4.01, has the following features:
  765.     *   contains all the features of a conventional editor, such as
  766.         Finding, Replacing, Cutting, Copying, Pasting.
  767.     *   has the ability to open multiple files, allowing you to transfer
  768.         text between the files. Multiple windows can be Tiled or
  769.         Cascaded, and features Scroll bars.
  770.     *   has mouse support.
  771.     *   features a simple, 4 function, 3 mode calculator, and an Ascii
  772.         Chart.
  773.     *   has menu systems allowing you to assemble, link, run and debug
  774.         your program.  Short cut keys are also provided.
  775.     *   allows you to specify your own assembler, linker and debugger in
  776.         the configuration file.
  777.     *   features setup dialogs that provide support for TASM, TLINK,
  778.         MASM and LINK.
  779.  
  780. ASMIDE is available:
  781.     http://www.inx.de/~nkomin/files/asmide.arj
  782.  
  783. 36.4  NASMIDE
  784.  
  785. NASM-IDE is a front end for NASM that allows multiple files to be worked
  786. on within the same editing environment.  Written in Turbo Pascal and
  787. Turbo Vision, the NASM-IDE interface is clear and straightforward.
  788. Features include:
  789.  
  790.     Turbo Vision point-and-click style interface
  791.     Automatic syntax highlighting of source code
  792.     An ASM Assistant to guide users through the creation of assembler
  793.         projects
  794.     On-line help system
  795.     Support for three main output file formats - flat file binary and
  796.         DOS 16 bit and Win32 object files
  797.  
  798. Learn more about NASIDE and download it from:
  799.  
  800.     http://www.inglenook.co.uk/nasmide/index.html
  801.  
  802. 36.5  MicroASM
  803.  
  804. MicroASM is written by Ole Saether.  It is a Windows 95 & NT windows
  805. editor with support for MS-DOS command line assemblers.
  806.  
  807. With MicroAsm you can:
  808.  
  809.     Create and edit text files.
  810.     Run the files through your favorite command-line assembler.
  811.     Automatically highlight lines containing errors.
  812.  
  813. To learn more about it and download it, visit:
  814.     http://home.eunet.no/~oleset/microasm.htm
  815.  
  816. 36.6  TASM IDE
  817.  
  818. Joost Vrielink has developed a Turbo Assembler IDE.  It is free for
  819. downloading from his web site:
  820.     http://www.angelfire.com/in/tasm
  821.  
  822. The IDE is an editor just like WordPad, but compile/link/run/debug can
  823. be accomplished with just one click.  It also has a built-in
  824. dec/hex/bin/oct converter, and syntax highlighting is almost finished.
  825. It is perfectly suited to make simple 16-bit DOS programs within the
  826. Windows 95/98 environment.  Changes are being added quite often, so
  827. remember to return and check every now and then.
  828.  
  829. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  830. Last Changed: 19 Sep 98
  831.  
  832. -----------------------------
  833.  
  834. Subject 37.  Dissassemblers
  835.  
  836. 38.1  Review of Disassemblers
  837.  
  838. Jerzy Tarasiuk has reviewed some commercial and shareware disassemblers.
  839. The shareware assemblers are available in this directory.  The review is
  840. available:
  841.  
  842.     ftp://ftp.simtel.net/pub/simtelnet/msdos/disasm/aabstrct.txt
  843.  
  844. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  845. Last Changed: 13 Oct 96
  846.  
  847. -----------------------------
  848.  
  849. Subject: 38.  How to Optimize for the Pentium
  850.  
  851. 39.1 PENTIUM OPTIMIZATION SITE
  852.  
  853. The below site is updated as new information becomes available and
  854. contains information not found elsewhere.
  855.     http://announce.com/agner/assem
  856.  
  857. 38.2 LITERATURE AVAILABLE FROM INTEL
  858.  
  859. Much useful literature can be downloaded free from Intel's WWW site:
  860.     http://www.intel.com
  861.  
  862. The documents are in various different file formats.  If a particular
  863. document is in a format not supported by your word processing software,
  864. then you may seek an appropriate file viewer somewhere on the Internet.
  865. Many software companies are offering such file viewers free to support
  866. their file formats.
  867.  
  868. Tutorials for Optimizing the Pentium, and Pentium Pro/Pentium II can be
  869. downloaded from:
  870.     http://developer.intel.com/design/perftool/cbts/pentopt/index.htm
  871.     http://developer.intel.com/design/perftool/cbts/pproopt/index.htm
  872.  
  873. Manuals for the Pentium and Pentium Pro processors can be downloaded
  874. from:
  875.     http://developer.intel.com/design/pentium/manuals/
  876.     http://developer.intel.com/design/pro/manuals/
  877.  
  878. Detailed information on the MMX processors can be found in the
  879. documents:
  880. "MMX Technology Developers Guide", and "Programmers Reference Manual",
  881. both of which are available from:
  882.     http://developer.intel.com/drg/mmx/manuals/
  883.  
  884. Many other sources other than Intel also have useful information.  I
  885. would particularly recommend:
  886.     http://www.x86.org.
  887.  
  888. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  889. Last Changed: 20 Dec 97
  890.  
  891. -----------------------------
  892.  
  893. Subject: 39. Assembly Language Programming Style Guidelines
  894.  
  895. Randy Hyde has done it again.  He has written a style guide that will
  896. help you write more readable and maintainable assembly language code.
  897. The URL is:
  898.  
  899.     http://webster.ucr.edu/Page_softeng/sample.html
  900.  
  901. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  902. Last Changed: 21 May 97
  903.  
  904. -----------------------------
  905.  
  906. Subject: 40.  Other Assembly-Related Newsgroups
  907.  
  908. Here are some other assembly language newsgroups that may be of
  909. interest.
  910.  
  911.     news:msnews.microsoft.com/microsoft.public.masm
  912.     news:forums.borland.com/borland.public.tasm
  913.     news:fido7.talks-asm
  914.     news:alt.os.assembly
  915.     news:alt.os.development
  916.  
  917. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  918. Last Changed: 26 Dec 97
  919.  
  920. -----------------------------
  921.  
  922. Subject: 41.  ZD-86 Debugger
  923.  
  924. 41.1  DESCRIPTION
  925.  
  926. ZD86 is a full-featured Assembler Debugging Environment that provides
  927. Symbolic Debugging for most common Assemblers, including A86, MASM,
  928. TASM, etc.  The symbolic debugging capability displays and highlights
  929. your statement labels and variable names where you have placed them in
  930. your code.  It is a powerful tool for the advanced assembly language
  931. programmer yet friendly enough for someone just starting with assembly
  932. language.
  933.  
  934. 41.2  AVAILABILITY
  935.  
  936. The ZD86 Debugger is available from:
  937.  
  938.     ftp://cet.cet.com/pub/80xxx/zd86-101.zip
  939.  
  940. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  941. Last Changed: 22 Jun 97
  942.  
  943. -----------------------------
  944.  
  945. Subject: 42.  Links to x86 Processor Manufacturers
  946.  
  947. AMD
  948.     http://www.amd.com/K6/k6docs/index.html
  949.  
  950. Intel
  951.     http://developer.intel.com/design/PentiumII/manuals/
  952.  
  953. Cyrix
  954.     http://www.cyrix.com/developers/dv-home.htm
  955.  
  956. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  957. Last Changed: 25 Oct 98
  958.  
  959. -----------------------------
  960.  
  961. Subject: 43.  Linkers
  962.  
  963. 43.1  MicrosoftÆs 16-bit linker
  964.  
  965. Microsoft has its 16-bit DOS linker available from its FTP site.  The
  966. linkers URL is:
  967.     ftp://ftp.microsoft.com/softlib/mslfiles/lnk563.exe
  968.  
  969. 43.2  ALINK
  970.  
  971. ALINK is a freeware linker for MSDOS and Win32. It links Intel/Microsoft
  972. OMF object and library files, to MSDOS COM and EXE files, and PE files
  973. for Win32 (including DLLs). Source code (ANSI C) is also available for
  974. download  It should compile with any 32-bit ANSI C compiler.
  975.  
  976. Also available is IMPLIB, a Win32 import library generator, as a
  977. companion to ALINK.
  978.  
  979. These are available form AnthonyÆs Programming Page:
  980.     http://www.geocities.com/SiliconValley/Network/4311/index.html
  981.  
  982. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  983. Last Changed: 21 Feb 99
  984.  
  985. -----------------------------
  986.  
  987. Subject: 44.  ASM Mailing Lists
  988.  
  989. 44.1  NASM MAILING LIST
  990.  
  991. Michael Darling has started a NASM mailing list.  You can subscribe to
  992. the list on the following web page:
  993.     http://nasm.home.ml.org
  994.  
  995. 44.2  X86 ASM MAILING LIST
  996.  
  997. Michael Ware has created an x86 ASM mailing list.  You can subscribe to
  998. the list on the following web page:
  999.     http://www.eGroups.com/list/assembly
  1000.  
  1001. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  1002. Last Changed: 23 Nov 98
  1003.  
  1004. -----------------------------
  1005.  
  1006. Subject 45.  ASM Programming Journal
  1007.  
  1008. There is a new ASM Programming Journal.  Visit and read or download the
  1009. issues at:
  1010.     http://asmjournal.freeservers.com/
  1011.  
  1012. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  1013. Last Changed: 26 Feb 99
  1014.  
  1015. -----------------------------
  1016.  
  1017. Subject 46.  High Level Assembly Language
  1018.  
  1019. Randy Hyde has developed a High Level Assembly (HLA) language as a tool
  1020. to help teach assembly language programming and machine organization to
  1021. University students at the University of California, Riverside. The
  1022. basic idea was to teach students assembly language programming by
  1023. leveraging their knowledge of high level languages like C/C++ and
  1024. Pascal/Delphi. At the same time, HLA was designed to allow advanced
  1025. assembly language programmers write more readable and more powerful
  1026. assembly language code.
  1027.  
  1028. There is much documentation but it still is in development.  If you want
  1029. to give HLA a try, its URL is:
  1030.     http://webster.cs.ucr.edu/Page_hla/Page_hla.html
  1031.  
  1032. Contributor: Ray Moon, raymoon@moonware.dgsys.com
  1033. Last Changed: 20 Feb 2000
  1034.  
  1035. -----------------------------
  1036. Subject: 47. Acknowledgments
  1037.  
  1038. I would like to acknowledge all the people who have assisted me or any
  1039. of the contributors.  For their time and effort, this FAQ is a better
  1040. product.
  1041.  
  1042. David Boedicker, Barry Brey, Paolo Ciccone, Giuseppe De Marco, Morten
  1043. Elling, Kris Heidenstrom, Alan Illeman, Don Krull, Chabad Lubavitch,
  1044. Thanh Ma, Jeff Owens, Ed Parry, Keith Petersen, Michael Roberts, Russell
  1045. Schulz, Rocky Seelbach, Janos Szamosfalvi and Cedric Ware
  1046.