home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / assembly-language / x86 / general / part2 < prev    next >
Encoding:
Text File  |  2000-03-22  |  40.3 KB  |  990 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 2/3
  5. Supersedes: <89sf06$stn$2@news.dgsys.com>
  6. Followup-To: alt.lang.asm,comp.lang.asm.x86
  7. Date: 21 Mar 2000 23:03:00 GMT
  8. Organization: MoonWare
  9. Lines: 964
  10. Approved: news-answers-request@MIT.EDU
  11. Distribution: world
  12. Expires: Thu, 20 Apr 2000 23:59:59 GMT
  13. Message-ID: <8b8v34$n7i$2@news.dgsys.com>
  14. Reply-To: raymoon@moonware.dgsys.com
  15. NNTP-Posting-Host: dgs.dgsys.com
  16. X-Trace: news.dgsys.com 953679780 23794 207.154.12.1 (21 Mar 2000 23:03:00 GMT)
  17. X-Complaints-To: usenet@news.dgsys.com
  18. NNTP-Posting-Date: 21 Mar 2000 23:03:00 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 two of three parts that contain x86 assembly
  22.  language information common to all assemblers.
  23. Keywords: x86 Assembly Language ASM FAQ General
  24. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  25. Xref: senator-bedfellow.mit.edu alt.lang.asm:25271 comp.lang.asm.x86:83704 news.answers:179900 alt.answers:47941 comp.answers:40153
  26.  
  27. Archive-Name: assembly-language/x86/general/part2
  28. Posting-Frequency: monthly (21st of every month)
  29. Last-modified: 2000/02/20
  30.  
  31. ------------------------------
  32.  
  33. Subject: 15.  Accessing 4 Gigs of Memory in Real Mode
  34.  
  35. Flat real mode is a popular name for a technique used to access up to 4
  36. GB of memory, while remaining in real mode.  This technique requires a
  37. 80386 or higher processor.  The address space really is not flat.
  38. Actually, this technique allows you treat one or more segments as large
  39. (32-bit) segments, thereby accessing memory above 1 MB.
  40.  
  41. When the CPU accesses memory, the base address of the segment used is
  42. not described by the value currently in the appropriate register.  The
  43. value is stored internally in a structure known as the descriptor cache.
  44. Changing the value of a segment register results in that segment's entry
  45. in the descriptor cache being recalculated according to the rules of the
  46. current mode.  In real mode, the value of the segment register is
  47. shifted left four bits to find the base address of the segment, and the
  48. size of the segment is always 64k.  In protected mode, the value in the
  49. segment register is used as an index into a descriptor table located in
  50. memory, and the base address and size (which may be as small as 4 KB, or
  51. as large as 4 GB) from the descriptor table are loaded into the
  52. descriptor cache.
  53.  
  54. When the processor changes modes, the contents of the processor's
  55. internal descriptor cache are not changed.  The reason is because
  56. changing them would result in (at the very least) the code segment being
  57. recalculated according to the new mode's rules, most likely causing your
  58. program to crash.  Thus the program must load the segment registers with
  59. sensible values after the mode switch occurs.  Consider an example where
  60. real mode code is located in segment 1000h.  If switching modes caused
  61. an immediate recalculation of the descriptor cache, the processor would
  62. attempt to read entry 1000h of the descriptor table immediately upon
  63. switching to protected mode.  Even if this were a valid descriptor
  64. (unlikely), it would have to have a base address identical to real mode
  65. segment 1000h (i.e., 10000h), and a size limit of 64 KB to prevent a
  66. probable crash.  An invalid descriptor would cause an immediate
  67. processor exception.
  68.  
  69. Normally, aside from preventing situations like that in the above
  70. example, there is little to be said about this feature.  After all, as
  71. soon as you reload new values into the segment register, the descriptor
  72. cache entry for that segment will be reset according to the rules of the
  73. current mode.  After switching from protected mode to real mode,
  74. however, when you load the segment registers with their new values, the
  75. segment's base address is recalculated according to real mode rules, but
  76. the size limit is not changed.  After setting the 4 GB limit (which must
  77. be done in protected mode), it will stay in place until changed by
  78. another protected mode program, regardless of what values are loaded in
  79. the segment register in real mode.
  80.  
  81. So, the steps to using this technique are as follows:
  82.     1.  Set up a bare bones global descriptor table, with a null entry,
  83. and a single entry for a 4 GB segment.  The base address of this segment
  84. is not important.
  85.     2.  If you don't wish to define an interrupt descriptor table (IDT),
  86. you must disable interrupts before switching to protected mode.  You do
  87. not need a full-fledged protected mode environment for this, so it is
  88. easiest just to disable interrupts and not worry about the IDT.
  89.     3.  Switch to protected mode.
  90.     4.  Load the segment registers you wish to change with the selector
  91. for the 4 GB segment.  I recommend using FS and/or GS for this purpose,
  92. for reasons I'll describe below.
  93.     5.  Return to real mode.
  94.     6.  Re-enable interrupts.
  95.  
  96. After these steps, you can then load your segment registers with any
  97. value you wish.  Keep in mind that the base address will be calculated
  98. according to real mode rules.  Loading a value of 0 into a segment
  99. register will result in a 4 GB segment beginning at physical address 0.
  100. You can use any of the usual 32-bit registers to generate offsets into
  101. this segment.
  102.  
  103. Some points to keep in mind:
  104.     1.  Some software depends on 64 KB segment wrap-around.  While rare,
  105. it is possible that you will encounter software that crashes if the
  106. older segments (DS or ES) are 4 GB in size.  For that reason, I
  107. recommend only using FS and/or GS for this purpose, as they are not used
  108. as widely as the others.
  109.     2.  You should never change the limit of the code segment.  The
  110. processor uses IP (not EIP) to generate offsets into the code segment in
  111. real mode; any code beyond the 64 KB mark would be inaccessible,
  112. regardless of the segment size.
  113.     3.  You should never change the limit of the stack segment.  This is
  114. similar to the above; the processor uses SP in real mode, rather than
  115. ESP.
  116.     4.  Because of the necessity of switching to protected mode, this
  117. technique will not work in a virtual 8086 mode "DOS box" from Windows,
  118. OS/2, or any other protected mode environment.  It only works when you
  119. start from plain, real mode DOS.  Many memory managers also run DOS in
  120. V86 mode, and prevent the switch to protected mode.  It is possible to
  121. use VCPI to work around this, but if you go to that length you will
  122. probably find that you have implemented a complete protected mode
  123. environment, and would not need to return to real mode anyway.
  124.     5.  This technique will not work in the presence of any protected
  125. mode software that changes segment size limits.  When that software
  126. returns control to your real mode program, the limits will be the values
  127. to which the protected mode code set them.  If these limits are
  128. different that what your program used, problems can result.  At the very
  129. least, your program will return incorrect results when accessing data
  130. stored in extended memory.  At worst, your program will crash and burn.
  131.  
  132. The benefits of this technique are many.  Most importantly, you can
  133. access extended memory without resorting to slow BIOS calls or having to
  134. implement a complete DOS extender.  If your program uses interrupts
  135. extensively (timer interrupts for animation or sound, for example), real
  136. mode is a better choice because protected mode handles interrupts
  137. slower.  DOS itself uses this technique in HIMEM.SYS as a fast,
  138. practical method of providing access to extended memory.
  139.  
  140. Code demonstrating this technique is available:
  141.     ftp://x2ftp.oulu.fi/pub/msdos/programming/memory/realmem.zip
  142.  
  143. For further reading on this topic, I suggest "DOS Internals," by Geoff
  144. Chappell.  It is published by Addison-Wesley as part of the Andrew
  145. Schulman Programming Series.  The ISBN number is 0-201-60835-9.
  146.  
  147. Contributor: Sherm Pendley, grinch@access.mountain.net
  148. Last changed: 15 Jan 95
  149.  
  150. ------------------------------
  151.  
  152. Subject: 16. What Is Available at developer.intel.com
  153.  
  154. 16.1  PENTIUM & PENTIUM PRO INFORMATION
  155.  
  156. The gateway for information on the Pentium family of processors at Intel
  157. are:
  158.  
  159.     http://developer.intel.com/design/pentium
  160.     http://developer.intel.com/design/pro
  161.     http://developer.intel.com/design/pentiumiii/
  162.  
  163. Information linked to this page is:  Application Notes, Datasheets,
  164. Manuals, Specification Updates, and much more.
  165.  
  166. 16.2  INTEL DEVELOPMENT TOOLS
  167.  
  168. The below page has links to software, hardware, evaluation kits and
  169. documentation on Intel OEM products.  Areas covered are Intel Software
  170. Performance Products, Internet Technologies, Multimedia and Intel
  171. Products.
  172.  
  173.     http://developer.intel.com/design/develop.htm
  174.  
  175. 16.3  INTEL TECHNOLOGIES
  176.  
  177. Intel has overviews, in-depth system architecture tutorials and
  178. specifications on a variety of PC platform and communications
  179. technologies.  Areas covered are MMX Technology, Intelligent I/O,
  180. WinSock 2, and much more.
  181.  
  182.     http://developer.intel.com/design/tech.htm
  183.  
  184. 16.4  GET INTELÆS WEB SITE ON CDROM
  185.  
  186. Have you been spending a long time on line downloading one of the many
  187. manuals available from IntelÆs Developer Web Site.  Now you can get the
  188. entire Technology and Product portions of that web site available on
  189. CDROM.  You access the CDROMs with your browser.  It now takes longer to
  190. launch the Acrobat reader than to download a meg .pdf file.  With the
  191. Aug 98 version, the package includes three CD-ROMs:  Products and
  192. Product Selectors; Tools and Motherboards; and Technologies.
  193.  
  194. Sign up on Intel's Developer's Insight CD-ROM Registration Page:
  195.  
  196.         http://developer.intel.com/design/1b3/index.htm
  197.  
  198. The current version is May 99 but is quite up to date for manuals.  You
  199. can sign up for updates.  It appears that new subscriptions are not
  200. being accepted.  It appears that you can still order it at:
  201.  
  202.     http://apps.intel.com/scripts-order/viewbasket.asp?SKURev=273000_011&site=developer&LNavFile=TRUE
  203.  
  204. 16.5  Intel 80386 Programmer's Reference Manual
  205.  
  206. This is a very popular Intel Manual that is no longer available for
  207. downloading from Intel.  Luigi Sgro has translated it into HTML and is
  208. available:
  209.  
  210.     http://www.global.village.it/~gigio/it386idx.htm
  211.     
  212. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  213. Last changed: 23 Oct 99
  214.  
  215. ------------------------------
  216.  
  217. Subject: 17. Interrupts and Exceptions
  218.  
  219.     "(with interrupts) the processor doesn't waste its time looking for
  220.     work - when there is something to be done, the work comes looking
  221.     for the processor."
  222.                 - Peter Norton
  223.  
  224. INTERRUPTS AND EXCEPTIONS
  225.  
  226. Interrupts and exceptions both alter the program flow. The difference
  227. between the two is that interrupts are used to handle external events
  228. (serial ports, keyboard) and exceptions are used to handle instruction
  229. faults, (division by zero, undefined opcode).
  230.  
  231. Interrupts are handled by the processor after finishing the current
  232. instruction. If it finds a signal on its interrupt pin, it will look up
  233. the address of the interrupt handler in the interrupt table and pass
  234. that routine control.  After returning from the interrupt handler
  235. routine, it will resume program execution at the instruction after the
  236. interrupted instruction.
  237.  
  238. Exceptions on the other hand are divided into three kinds.  These are
  239. Faults, Traps and Aborts.  Faults are detected and serviced by the
  240. processor before the faulting instructions.  Traps are serviced after
  241. the instruction causing the trap.  User defined interrupts go into this
  242. category and can be said to be traps; this includes the MS-DOS INT 21h
  243. software interrupt, for example.  Aborts are used only to signal severe
  244. system problems, when operation is no longer possible.
  245.  
  246. See the below table for information on interrupt assignments in the
  247. Intel 386, 486 SX/DX processors, and the Pentium processor.  Type
  248. specifies the type of exception.
  249.  
  250.     ------------------------------
  251.     Vector number   Description
  252.     ------------------------------
  253.            0        Divide Error (Division by zero)
  254.            1        Debug Interrupt (Single step)
  255.            2        NMI Interrupt
  256.            3        Breakpoint
  257.            4        Interrupt on overflow
  258.            5        BOUND range exceeded
  259.            6        Invalid Opcode
  260.            7        Device not available (1)
  261.            8        Double fault
  262.            9        Not used in DX models and Pentium (2)
  263.           10        Invalid TSS
  264.           11        Segment not present
  265.           12        Stack exception
  266.           13        General protection fault
  267.           14        Page fault
  268.           15        Reserved
  269.           16        Floating point exception (3)
  270.           17        Alignment check (4)
  271.      18 û 31        Reserved on 3/486, See (5) for Pentium
  272.     32 û 255        Maskable, user defined interrupts
  273.     ------------------------------
  274.     (1) Exception 7 is used to signal that a floating point processor is
  275.         not present in the SX model. Exception 7 is used for programs
  276.         and OSs that have floating point emulation. In addition, the DX
  277.         chips can be set to trap floating point instructions by setting
  278.         bit 2 of CR0.
  279.     (2) Exception 9 is Reserved in the DX models and the Pentium, and is
  280.         only used in the 3/486 SX models to signal Coprocessor segment
  281.         overrun.  This will cause an Abort type exception on the SX.
  282.     (3) In the SX models this exception is called 'Coprocessor error'.
  283.     (4) Alignment check is only defined in 486 and Pentiums.  Reserved
  284.         on any other Intel processor.
  285.     (5) For Pentiums Exception 18 is used to signal what is called an
  286.         'Machine check exception'.
  287.     The other interrupts, (32-255) are user defined.  They differ in use
  288.     from one OS to another.
  289.  
  290. For a list of MS-DOS interrupts, see 'Obtaining HELPPC' (Subject #6) or
  291. Ralf Browns Interrupt List (Subject #11)
  292.  
  293. Contributor: Patrik Ohman, patrik@astrakan.hgs.se
  294. Last changed: 10 Jan 95
  295.  
  296. ------------------------------
  297.  
  298. Subject: 18.  ASM Books Available
  299.  
  300. The format is Author, Title, Level, and short description
  301.  
  302. Ray Duncan
  303. Advanced MSDOS Programming
  304. Advanced
  305. Both a tutorial and a reference for MS-DOS capabilities and services,
  306. including reference sections on DOS function calls, IBM ROM BIOS, mouse
  307. driver and LAM. expanded memory. Excellent quality example programs
  308. throughout.
  309.  
  310. By Peter Norton and John Socha
  311. Peter Norton's Assembly Language Book For the IBM PC
  312. Novice
  313. Good for an introduction to Assembly Language.  Plenty of programming
  314. examples.  Older versions of this book used to have a sample disk.  As
  315. you read the book, you slowly add on code to what eventually is Disk
  316. Patch - the book's version of Norton's commercially available Disk Edit
  317. program.   Great for complete beginners seeking novice rank.
  318.  
  319. Maljugin, Izrailevich, Sopin, and Lavin
  320. The Revolutionary Guide to Assembly Language
  321. Novice
  322. This is one of the best introductory texts I have ever seen.  There are
  323. so many authors that the topic is broken down into specific categories:
  324. video, BIOS, keyboard, etc..  Most intro texts force you to follow a set
  325. plan of learning assembly, but in this book you can turn to a specific
  326. t0pic almost immediately.  It is so-so as a reference book, however - a
  327. few tables of interrupts in the back.
  328.  
  329. Maljugin, Izrailevich, Sopin, and Lavin
  330. Master Class Assembly Language
  331. Advanced
  332. Review: This is the sequel to The Revolutionary Guide To Assembly
  333. Language.  Equally thick and massive, it covers many of the topics we
  334. see today - hardware interfaces, sound cards, data compression, even
  335. protected mode programming.  Brief review of assembly at the beginning,
  336. but moves very quickly.  Read this if you are intermediate seeking
  337. expert status.  Definitely not recommended for beginners.  If you are a
  338. beginner and you think you like the topics covered in this book, buy the
  339. one before it too.  Also comes with a disk of source code examples from
  340. the book (MASM highly recommended, not TASM).
  341.  
  342. Alan Wyatt
  343. Advanced Assembly Language
  344. Advanced
  345. This book's best feature is its comprehensive guide on device drivers.
  346. There are good chapters on controlling the mouse, file access, using
  347. memory, etc.
  348.  
  349. Ralf Brown and Jim Kyle
  350. PC Interrupts - 2nd Edition
  351. Intermediate/Advanced
  352. The definitive book on interrupt programming for PCS and compatibles.
  353. Based on the freeware Interrupt List by Ralf Brown
  354.  
  355. For an extensive book list without descriptions, point your web browser
  356. to:
  357.     http://www.alaska.net/~rrose/book.htm
  358. Sites with more books but no reviews are:
  359.     http://www.fys.ruu.nl/~faber/Amain.html#Books
  360.     http://www.cet.com/~jvahn/80xbook.html (short descriptions)
  361.  
  362. Contributors:  Antonio Alonso, Solomon Chang, Paul Gilbert, Dave
  363. Navarro, Mike Schmit and James Vahn.
  364.  
  365. Last changed: 6 Jul 97
  366.  
  367. ------------------------------
  368.  
  369. Subject: 19.  ASM Code Available on the Internet
  370.  
  371. 19.1  SIMTEL SITES
  372.  
  373. The SimTel has a directory devoted to assembly language.
  374.  
  375.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl
  376. or
  377.     http://www.simtel.net/simtel.net/msdos/asmutl-pre.html
  378.  
  379. 19.2  80xxx Snippets
  380.  
  381. Fidonet's echo for 80xxx programming has a collection of code that is
  382. maintained by Jim Vahn, jvahn@short.circuit.com.  The collection is on
  383. the web.  In addition to downloading the snippets there is an assembly
  384. language related book list.  The URL is:
  385.  
  386.     http://www.cet.com/~jvahn
  387.  
  388. The ability to get these files via e-mail has been discontinued.
  389.  
  390. 19.3  X2FTP.OULU.FI
  391.  
  392. This ftp site, x2ftp.oulu.fi, has some ASM source code not available at
  393. the SIMTEL sites.  The following describes some directories and the type
  394. of information that is available in them.
  395.  
  396. Protected mode utilities and some source code:
  397.     ftp://x2ftp.oulu.fi/pub/msdos/programming/pmode
  398. Some asm code:
  399.     ftp://x2ftp.oulu.fi/pub/msdos/programming/source
  400.     ftp://x2ftp.oulu.fi/pub/msdos/programming/progsrc
  401.  
  402. 19.4  JUMBO
  403.  
  404. JUMBO is the Official Web Shareware Site.  It has a directory devoted to
  405. assembly language source code, libraries and utilities:
  406.  
  407.     http://www.jumbo.com/pages/programming/dos/asmutl/ (broken)
  408.  
  409. 19.5  THEREEF
  410.  
  411. I just found another site that carries this asm source code.  This site
  412. has source code and information that I have not found elsewhere.
  413.  
  414.     http://www.iag.net/~philb/thereef/ftp_asm.htm
  415.  
  416. 19.6  PC GAMES PROGRAMMER ENCYCLOPEDIA
  417.  
  418. This encyclopedia is a collection of files related to game programming.
  419. Many of these files contain programming examples.  Topics included are
  420. ASM tutorial, VGA and SVGA programming information, graphic algorithms,
  421. graphic file formats, soundcard and other PC hardware programming
  422. information.  This encyclopedia is available online at the PC-GPE web
  423. page:
  424.  
  425.     http://www.qzx.com/pc-gpe/
  426.  
  427. 19.7  PROGRAMMERS DISTRIBUTION NETWORK ASSEMBLY LANGUAGE FILES
  428.  
  429. These files appear to be a mirror of the assembly-related files
  430. distributed on FidoNet by PDN.  There is one that is a must if you want
  431. to write ASM WinNT and Win95 applications.  It is walk32_1.zip.  Walk32
  432. is a complete app and dll development kit with linker and includes
  433. files, libraries, tools, and many samples.  MASM 6.x required.
  434.  
  435.     http://www.programmersheaven.com/files/asm/80x86/WALK32_1.ZIP
  436.     
  437. The page to all of ProgrammerÆs Heaven ASM files is:
  438.     http://www.programmersheaven.com/zone5/index.htm
  439.  
  440. 19.8  TENIE REMMELÆS ASSEMBLY SNIPPETS CODE COLLECTION
  441.  
  442. The Assembly Snippets is a large collection of assembly language code
  443. and other information.  Many files from the original 80XXX snippets, the
  444. ASM0-Z collection, and the Aquila site are included.  All code is 99%
  445. guaranteed to compile under TASM.  This new release contains the
  446. following items, among others:
  447.  
  448.   An object file disassembler       A 4971 byte Tetris game
  449.   Several Conway LIFE programs      Assembly & Disassembly tables
  450.   A demonstration of FakeMode       Several powerful editors
  451.   A complete DOS extender           A Pentium optimization list
  452.   A ModeX graphics library          Info for writing antivirus
  453.  
  454. You can download these rather large files from ProgrammerÆs Heaven:
  455.  
  456. http://www.programmersheaven.com/zone5/index.htm
  457.  
  458. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  459. Last changed: 24 Oct 99
  460.  
  461. ------------------------------
  462.  
  463. Subject: 20. How to Commit A File
  464.  
  465. The easiest solution is to open or create the file to be committed using
  466. Int 21h function 6ch, extended open/create.  The BX register contains
  467. the desired Open Mode.  One option that can be or'ed into this register
  468. is what Microsoft calls, OPEN_FLAGS_COMMIT, that has the value of 4000h.
  469. Using this option caused DOS to commit the file after each write.  This
  470. function has been available (documented) since DOS 4.0.
  471.  
  472. If you do not want to commit the file at each write but only when
  473. certain conditions are met, use Int 21h function 68h, commit file.  The
  474. functions have been available (documented) since DOS 3.3.
  475.  
  476. If you need to support versions of DOS before 3.3, the following
  477. technique will flush the all stored data without closing and opening the
  478. file.  The time consuming process is the opening of the file.
  479.     1.  Use 21h function 45h to create a duplicate file handle to the
  480.         file to be flushed.
  481.     2.  Close that duplicate file handle.
  482.  
  483. This technique will work all the way back to DOS 2.0.
  484.  
  485. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  486. Last changed: 30 Jan 95
  487.  
  488. ------------------------------
  489.  
  490. Subject: 21. Using Extended Memory Manager
  491.  
  492. 21.1  HOW TO USE XMS
  493.  
  494. XMS usage - short recipe:
  495. 1.  Verify have at least 286 (pushf; pop AX; test AX,AX; js error).
  496. 2.  Verify vector 2Fh set (DOS 3+ sets it during boot).
  497. 3.  AX=4300h, Int 2Fh, verify AL=80h (means XMS installed).
  498. 4.  AX=4310h, Int 2Fh, save ES:BX as dword XmsDriverAddr.
  499. 5.  AH=8, call [XmsDriverAddr] - returns ax=largest free XMS memory
  500.     block size in kB (0 if error).
  501. 6.  AH=9, DX=required size in kB, call [XmsDriverAddr] - allocates
  502.     memory (returns handle in DX - save it).
  503. 7.  AH=0Bh, DS:SI->structure {
  504.         dword size (in bytes and must be even),
  505.         word source_handle,
  506.         dword source_offset,
  507.         word destination_handle,
  508.         dword destination_offset }
  509.     (if any handle is 0, the "offset" is Real Mode segment:offset)
  510. 8.  AH=0Fh, BX=new size in kB, DX=handle, call [XmsDriverAddr] - changes
  511.     memory block size (without losing previous data).
  512. 9.  AH=0Ah, DX=handle, call [XmsDriverAddr] - free handle and memory.
  513.  
  514. Initially, should process #1-#6, then can use #7 to put data in/get data
  515. from XMS memory, or #8 to change XMS memory block size.  On exit, use #9
  516. to free allocated memory and handle.
  517.  
  518. Hint:  handle cannot be 0, since zero is used as "no handle allocated"
  519. value.
  520. Errors for XMS calls (except AH=7 - Query A20) are signaled by AX=0.
  521. Error code returned in BL, few codes can check for are:
  522.     80h - not implemented,
  523.     81h - VDISK detected (and it leaves no memory for XMS),
  524.     82h - A20 error (e.g., fail to enable address line A20),
  525.     A0h - all allocated,
  526.     A1h - all handles used,
  527.     A2h - invalid handle,
  528.     A3h/A4h - bad source handle/offset,
  529.     A5h/A6h - bad destination handle/offset,
  530.     A7h - bad length,
  531.     A8h - overlap (of source and destination areas on copy),
  532.     A9h - parity error (hardware error in memory),
  533.     Abh - block is locked,
  534.     00h - OK
  535.  
  536. For more info read INT 2Fh, AH=43h in Ralf Brown interrupt list.
  537.  
  538. 21.2  WHAT IS THE 'LINEAR BLOCK ADDRESS' RETURNED BY LOCK MEM BLOCK?
  539.  
  540. When you lock mem block, XMS driver arranges memory governed by it in a
  541. way the locked block forms one contiguous area in linear address space
  542. and returns you starting address of the memory.  Linear address is base
  543. address of segment + offset in segment, in Real Mode it is
  544. segment*16+offset, in Protected Mode the base address is kept in LDT or
  545. GDT; note offset can be 32-bit on 386+.  If paging is not enabled,
  546. linear address = physical address.  You do not need the linear address
  547. unless you use 32-bit offsets in Real Mode or you use Protected Mode
  548. (see previous answer for explanation of how you can access XMS memory).
  549.  
  550. Contributor: Jerzy Tarasiuk, JT@zfja-gate.fuw.edu.pl
  551. Last Changed: 30 Jan 95
  552.  
  553. ------------------------------
  554.  
  555. Subject: 22. EXE2BIN Replacement
  556.  
  557. A utility, EXE2BIN, used to be included in DOS.  This utility was needed
  558. to convert the output of the linker from .EXE to .COM format because the
  559. linkers could not do this directly.  As linkers became more capable, the
  560. need for this utility vanished, so EXE2BIN was dropped from DOS.  If you
  561. still are using an older assembler and linker, you now have been left
  562. out in the cold.  Well, not quite, as there are three shareware
  563. equivalent programs.
  564.  
  565. 22.1  EXECOM14.ZIP
  566.  
  567. EXECOM was written by Chris Dunford in C.  The .zip file contains the
  568. executable, documentation and the .c source that Chris Dunford has
  569. released into the public domain.  The current version is 1.04 with a
  570. 2 Mar 88 date.
  571.  
  572.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/execom14.zip
  573.  
  574. 22.2  BIN.ZIP
  575.  
  576. This replacement version was written by Bob Tevithick.  It is based upon
  577. versions 1.00 of Chris Dunford's program.  The .zip file contains only
  578. the executable and documentation.  No source is included.
  579.  
  580.  
  581.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/bin.zip
  582.  
  583. 22.3  X2B11.ZIP
  584.  
  585. X2B is written in 100% assembly language by Henry Nettles.  Again, it is
  586. based upon Chris Dunford's program.  The zip file contains the
  587. executable and .asm source.  The documentation is in the source code.
  588.  
  589.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/x2b11.zip
  590.  
  591. 22.4  THE REAL THING, EXE2BIN.EXE
  592.  
  593. If you need the real thing, EXE2BIN.EXE is available on the DOS
  594. Supplemental Diskettes.  These disks can be downloaded from Microsoft.
  595.  
  596. for MS DOS 6.0
  597.     ftp://ftp.microsoft.com/peropsys/msdos/public/supplmnt/DOS6SUPP.EXE
  598. for MS DOS 6.2
  599.     ftp://ftp.microsoft.com/peropsys/msdos/public/supplmnt/DOS62SP.EXE
  600. for MS DOS 6.21
  601.     ftp://ftp.microsoft.com/peropsys/msdos/public/supplmnt/SUP621.EXE
  602. for MS DOS 6.22
  603.     ftp://ftp.microsoft.com/peropsys/msdos/public/supplmnt/SUP622.EXE
  604.  
  605. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  606. Last changed: 8 Jan 96
  607.  
  608. ------------------------------
  609.  
  610. Subject: 23.  ASM Tutorials Available on the Internet
  611.  
  612. There are several assembly language tutorials available on the Internet.
  613.  
  614. 23.1  FROM SIMTEL MIRRORS
  615.  
  616. From the SimTel Mirrors, e.g., oak.oakland.edu, there are two tutorials
  617. available in the simtel/msdos/asmutil directory.
  618.  
  619.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/asmtutor.zip
  620.  
  621. The tutorial is by Joshua Averbach.  It is old, dated Jun 1988, and
  622. designed for the 8088 processor.
  623.  
  624.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/primer2.zip
  625.  
  626. This tutorial is designed specifically for the cheap assembler (CHASM)
  627. also available in this directory.
  628.  
  629. 23.2  GAVIN ESTEY'S TUTORIAL
  630.  
  631. A new tutorial has been written by Gavin Estey.  He has provided his
  632. tutorial in ascii text and in HTML format.  They are available:
  633.  
  634. HTML:
  635.     http://www.strangecreations.com /library/assembly/tutor/asm1.htm
  636. Text:
  637.     http://www.strangecreations.com /library/assembly/asmtut.txt
  638.  
  639. 23.3  VLA's ASSEMBLY LANGUAGE TUTORIAL
  640.  
  641. This tutorial is available directly or as part of the PC Games
  642. Encyclopedia:
  643.     ftp://teeri.oulu.fi/pub/msdos/programming/gpe/pcgpe10.zip
  644. or on-line at:
  645.     http://www.qzx.com/pc-gpe/asm.tutorials.html
  646.  
  647. 23.4  ASM Tutorial on University of Guadalajara Web Site
  648.  
  649. The on-line tutorial is available:
  650.     http://udgftp.cencar.udg.mx/ingles/tutor/Assembler.html
  651.  
  652. ASCII version:
  653.     http://udgftp.cencar.udg.mx/ingles/tutor/edition97/edit96.zip
  654. MS Word Version:
  655.     http://udgftp.cencar.udg.mx/ingles/tutor/edition97/ENSAMDOC.ZIP
  656.  
  657. 23.5  RANDALL HYDE'S ART OF ASSEMBLY LANGUAGE
  658.  
  659. Randy Hyde's Assembly Language Course Material.  This in my opinion is
  660. the best assembly language tutorial available on the Internet.
  661.  
  662.     http://webster.cs.ucr.edu/Page_asm/ArtOfAsm.html HTML Version
  663.     http://webster.cs.ucr.edu/Page_asm/ArtofAssembly/pdf/AoAPDF.html .pdf Version
  664.  
  665. Do not miss his Assembly Language Style Guide.
  666.     http://webster.cs.ucr.edu/Page_asm/moreasm/asmstyle.pdf .pdf version
  667.     http://webster.cs.ucr.edu/Page_asm/moreasm/asmstyle.htm HTML version
  668.  
  669. 23.6  PATRICK STUDDARD'S ASSEMBLY CLASS NOTES
  670.  
  671. Patrick Studdard has a very extensive library of supplementary class
  672. notes for assembly language.  These are available for all and not just
  673. those who are taking the class.  They are available:
  674.  
  675.     http://www.csis.american.edu/~studdard/classes/fall1995/4028201/notes/index.html
  676.  
  677. 23.7  TORE NILSSON'S ASSEMBLY TUTORIAL PAGE
  678.  
  679. VLA's Assembly and DMA programming tutorials, Asphyxia's VGA tutorials,
  680. and some graphics and sound programming information.
  681.  
  682.     http://www.ice-digga.com/programming/index2.html
  683.  
  684. 23.8  HOMER TILTONÆS ASSEMBLY LANGUAGE TUTORIAL
  685.  
  686. ZDNet offers an Assembly Language tutorial by Homer Tilton.  To find it,
  687. use the following URL:
  688.  
  689.     http://www6.zdnet.com/cgi-bin/texis/swlib/hotfiles/info.html?fcode=000804
  690.  
  691. 23.9  Mike BabcockÆs ASM Tutorial
  692.  
  693. Mike Babcock has a small tutorial.  Unfortunately, all the links on the
  694. page currently are broken.  The basic URL is:
  695.  
  696.     http://w3.tyenet.com/mbabcock/prg.asmtut1.html
  697.  
  698.     (Note that the internal links currently are broken.  I have
  699.     contacted the author, and he has replied that he will be correcting
  700.     this shortly.)
  701.  
  702. 23.10  BRIAN BROWNÆS CENTRAL INSTITUTE OF TECHNOLOGY COURSE WARE
  703.  
  704. Brian Brown as a very good tutorial along with others.  The assembly
  705. language tutorial, version 3.0, starts:
  706.  
  707.     http://www.cit.ac.nz/smac/asm/astart.htm
  708.  
  709. 23.11  FERDI SMIT ASSEMBLY LANGUAGE TUTORIAL
  710.  
  711. Ferdi Smit has a nice tutorial in text and HTML.  It is available:
  712.  
  713.     http://www.xs4all.nl/~smit/docs.htm#asm
  714.  
  715. 23.12  PROF. LOCKWOODÆS EE291 CLASS LECTURE NOTES
  716.  
  717. Prof. LockwoodÆs class lecture notes, resources, etc. are a very good
  718. source of information on assembly language programming.  His URL is:
  719.  
  720.     http://www.ece.uiuc.edu/~ece291/
  721.  
  722. Contributor: Raymond Moon, raymoon@moonware.dgsys.com
  723. Last changed: 9 Dec 97
  724.  
  725. ------------------------------
  726.  
  727. Subject: 24. Shareware Assemblers
  728.  
  729. 24.1  A86
  730.  
  731. This assembler is a very capable assembler for 80286 and earlier
  732. processors.  Registration will get you a version capable of handling
  733. 80386 processor.  For more details, see the A86 section of this FAQ.
  734.     http://www2.dgsys.com/~raymoon/faq/a86.html#3
  735.  
  736. If you want to go get them now:
  737.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/a86v402.zip
  738.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/d86v402.zip
  739.  
  740. 24.2  CHASM, CHASM4.ZIP
  741.  
  742. This assembler was the first shareware assembler available.  CHASM was
  743. written Mr. David Whitman.  The current version available is version 4
  744. and dated in 1983.  This version supports only 8088 processor, and the
  745. output only is:
  746.     .COM file (.EXE is not supported)
  747.     BLOADable - format for interpreted BASIC to load and execute
  748.     External procedure for TurboPascal - TurboPascal version not given
  749.  
  750. The version available on the internet is annoyware and crippleware.  For
  751. $40 registration fee, you will get the complete version without the
  752. annoying banner page.  This version supports macros, conditional
  753. assembly, include files, operand expressions and structures.
  754.  
  755. I do not recommend this assembler because of it limited capability and
  756. it is very out of date.  Its URL is:
  757.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/chasm4.zip
  758.  
  759. 24.4  THE ARROWSOFT ASSEMBLER, VALARROW.ZIP
  760.  
  761. This assembler is the public domain version of the Professional
  762. Arrowsoft Assembler by Arrowsoft Systems, Inc.  The version is 1.00d and
  763. is dated in 1986.  This assembler is a MASM 3.0 compatible assembler and
  764. supports up to 80286 processor.  Compared to the Professional version,
  765. the public domain version has one major limitation.  The source file
  766. size is limited to 64K bytes.
  767.  
  768. The file also includes a public domain linker, full screen editor and an
  769. EXE2BIN clone program.
  770.  
  771.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/valarrow.zip
  772.  
  773. Rick Elbers maintains several web pages dedicated to this assembler.  If
  774. you use this assembler, visit this site.
  775.  
  776.     http://www.geocities.com/SiliconValley/Heights/7052/valarr.html
  777.  
  778. 24.5  WOLFWARE ASSEMBLER, WASM223.ZIP
  779.  
  780. This assembler was written by Mr. Eric Tauck.  The latest version is
  781. 2.23 and dates from 1991.  This assembler supports up to the 80286
  782. processor.  It will assemble directly into a .COM file or .obj file.  It
  783. supports a simplified syntax and program structure so programs written
  784. for this assembler may not be compatible with other assemblers.  Several
  785. source files for programs are included with the .zip file.
  786.  
  787. It is available from the author at:
  788.     ftp://ftp.mc.net/pub/users/warp/wasm223.zip
  789.     
  790. 24.6  MAGIC ASSEMBLER, ASM110.ZIP
  791.  
  792. The version is 1.10 and dates from March 1995.  This assembler was
  793. written by Mr. Bert Greevenbosch.  The output is either a .COM file or a
  794. boot sector program.  The assembly commands are standard except for the
  795. jump and call commands.  Again, the source code will not be compatible
  796. with other assemblers.  Beware of version 1.04.  That version had a bug
  797. that when executed without the print command, the assembler terminated
  798. with a runtime error.  This is corrected in subsequent versions.
  799.  
  800.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/asm110.zip
  801.  
  802. 24.7  GEMA, GEMA.ZIP
  803.  
  804. This assembler revision is 2.6a with a date, 7 Jan 96.  It is different
  805. from all other x86 assemblers I have seen.  This assembler is based upon
  806. Motorola's 68k mnemonics and logical structure.  All instructions,
  807. Pentium Pro and known undocumented are supported.  GEMA was designed
  808. especially for 32-bit processing.  The assembler will take only one
  809. source code file and will output a .COM or .EXE file.  No linker is
  810. required.  DESA.EXE, a beta GEMA disassembler is available in the GEMA
  811. package. ASM2GEMA.EXE, a TASM to GEMA translator is no longer available
  812. as part of the GEMA package.  An interactive real and protected-mode
  813. debugger is in progress.
  814.  
  815. This assembler is available from:
  816.     ftp://ftp.nether.net/pub/gema/gema.zip  (ftp connections refused)
  817.     http://prinz.hannover.sgh-net.de/~londberg/Gema.zip
  818.  
  819. 24.8  NASM
  820.  
  821. The birth of this assembler started out of a thread that started on
  822. comp.lang.asm.x86.  When you download this assembler, you get the source
  823. code in ANSI C.  The web page devoted to this assembler is:
  824.  
  825.     http://www.cryogen.com/Nasm/
  826.     http://www.web-sites.co.uk/nasm/
  827.  
  828. NASM is an 80x86 assembler designed for portability and modularity.  It
  829. supports a range of object file formats including Linux a.out and ELF,
  830. COFF, Microsoft 16-bit OBJ and Win32. It will also output plain binary
  831. files. Its syntax is designed to be simple and easy to understand,
  832. similar to Intel's but less complex. It supports Pentium, P6 and MMX
  833. opcodes, and has macro capability. It includes a disassembler as well.
  834.  
  835. Major new features present in this release include:
  836.     1.  The long-awaited listing file support!
  837.     2.  Support for a search path for include files.
  838.     3.  OS/2 object file support, although it's experimental as yet
  839.         (could anyone with OS/2 _please_ give it a testing for me?).
  840.     4.  This release, and all NASM releases from now on, include pre-
  841.         built Win32 versions of NASM and NDISASM, as well as the 16-bit
  842.         DOS versions.
  843.     5.  Numerous bug fixes, including the repeatedly-reported bug about
  844.         blank lines in macro definitions, and the one that prevented 32-
  845.         bit OBJ files working with some linkers.
  846.  
  847. The assembler also is available from:
  848.  
  849.   ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/nasm097.zip  assembler
  850.   ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/nasm097d.zip docs
  851.   ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/nasm097s.zip source
  852.  
  853. 24.9  GAS, GNU Assembler
  854.  
  855. This assembler with many object-file utilities will run on 386 systems
  856. running the following operating systems: AIX 386BSD, NetBSD, BSDI/386,
  857. Linux, SCO, Unixware, DOS/DJGPP.  The below file is a gzipped tar file.
  858. You will need gzip and tar programs to uncompress and extract the files.
  859. The assembler and utilities are part of the GNU binutils file.
  860.  
  861.     ftp://prep.ai.mit.edu/pub/gnu/binutils-2.8.tar.gz           5018 Kb
  862.     ftp://prep.ai.mit.edu/pub/gnu/binutils-2.8-2.8.1-patch.gz     36 Kb
  863.  
  864. 24.10  REAL TOOLS 1.0 (BETA), RTOOLS.ZIP
  865.  
  866. This assembler is dated in Dec 93 and is a beta test.  The nice thing
  867. about this assembler is that it comes with its own DOS-windowing IDE.
  868. This assembler was written by International Systems development.  The
  869. instruction set supported is 486 including protected mode instructions,
  870. but some holes do exist.  This assembler has a unique way of supporting
  871. macros.  32-bit supported.  On line help and debugger are available with
  872. registered product.
  873.  
  874.     ftp://ftp.simtel.net/pub/simtelnet/msdos/asmutl/rtools.zip
  875.  
  876. 24.11  GENERAL ASSEMBLER, GASM01G.ZIP
  877.  
  878. This is a new assembler written by Jim Gage.  This version outputs .COM
  879. files and can be used to write device drivers.  Another version
  880. supporting up to the 486 instruction set and .obj output is in the
  881. works.  This assembler is available:
  882.  
  883.     http://www.engr.uark.edu/~jrg/gasm/gasm01f.zip
  884.  
  885. 24.12  CROSS FIRE ASSEMBLER
  886.  
  887. This assembler is an 80x86 assembler that uses 680x0 syntax.  If you are
  888. coming from the 680x0 environment, you may want to try this as your
  889. first assembler.  This assembler supports up to the pentium instruction
  890. set, 16 and 32 bit segments, supports direct generation of .com, .exe,
  891. .sys, and more file formats, and supports pmode programming.  This
  892. package comes with its own pmode DOS extender by TRAN.  Currently, the
  893. math coprocessor, MMX instructions and .obj output is not supported.
  894.  
  895. You can get this assembler:
  896.  
  897.     ftp://www.simtel.net/pub/simtelnet/msdos/asmutl/xfire510.zip
  898.  
  899. 24.13  JAS Assembler (DJGPP ASM)
  900.  
  901. Nicola Gaggi has written an assembler for DJGPP that is based upon NASM.
  902. Jas has a syntax much like TASM and is faster because it is a one pass
  903. assembler.
  904.  
  905. Download it from:
  906.     ftp://teeri.oulu.fi/pub/msdos/programming/djgpp2/jas12.zip
  907.  
  908. Version 1.3 should be available soon.
  909.  
  910. 24.14  Rodrigo AugustoÆs IASM V1.0
  911.  
  912. The Intel Architecture Assembler v1.0 is a platform independent
  913. assembler developed for the Intel 80x86 family of microprocessors.  It
  914. has a simple syntax.  The assembler was developed to get an easy to use
  915. flat memory assembler.  A linker is not necessary as the assembler
  916. outputs a .COM file, but this can be changed.  IASM supports
  917. instructions from all the Intel family, from the 8086/8088 to the
  918. Pentium II; MMX and floating point instructions also are supported.
  919. IASM can generate both 16 and 32-bits code.
  920.  
  921. The assembler is available from Rodrigo AugustoÆs home page:
  922.     http://www.dcc.ufmg.br/~augusto/project/
  923.  
  924. 24.15  The Visual Assembler
  925.  
  926. This assembler currently is under development, but it should be worth
  927. watching.  It is an attempt to apply Rapid Application Development
  928. techniques to assembly language programming.  The Visual Assembler is
  929. being developed based that assembly language can be used quickly and
  930. easily to program Win32 applications though the careful implementation
  931. and use of reusable class modules rather than classes.
  932.  
  933. The Visual Assembler is being build around an IDE that will make
  934. extensive use wizard modules that will guide the user through creating
  935. Win32 applications, libraries, drivers and VxDs.  The IDE will have
  936. integrated tools including a debugger, calculator, binary editor, and
  937. disassembler.  The IDE will support assembling through linking to the
  938. final program.
  939.  
  940. The home page of this effort is:
  941.     http://www.fortunecity.com/skyscraper/lycos/403/
  942.  
  943. 24.16  Gareth Owen's GASM
  944.  
  945.     http://www.athenenet.co.uk/homepages/gaz/gasm/
  946.         Use syntax similar to NASM
  947.  
  948. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  949. Last changed: 23 Nov 98
  950.  
  951. ------------------------------
  952.  
  953. Subject: 25.  Undocumented OpCodes
  954.  
  955. 25.1  WHAT AND WHERE
  956.  
  957. Robert Collins has make available an excellent article on Intel
  958. Undocumented OpCodes.  Just set your web browser to:
  959.  
  960.     http://www.x86.org/secrets/OpCodes.html
  961.  
  962. 25.2  EXTENDED FORMS OF AAM AND AAD INSTRUCTIONS
  963.  
  964. Mr. Collins describes extended forms these two instructions.  AAM is
  965. ASCII Adjust after Multiplication, and ADD is ASCII Adjust before
  966. Division.  These instructions are known as quick ways to divide and
  967. multiply by ten, as these instructions normally assemble with 10 as the
  968. default operand.   Using macros provided, any value from 0h to 0ffh can
  969. be substituted.  These instructions are available on all x86 Intel
  970. processors.
  971.  
  972. 25.3  SALC - SET AL ON CARRY
  973.  
  974. Mr. Collins describes this instruction a C programmers dream instruction
  975. for interfacing to assembly language procedures.  This instruction will
  976. set the AL register to 00h or 0ffh depending on whether the carry flag
  977. is clear or set, respectively.  This instruction is available on all x86
  978. Intel processors.
  979.  
  980. 25.4  ICE RELATED OPCODES
  981.  
  982. Mr. Collins describes several instructions that appear whose existence
  983. makes debugging run-time code easier on the ICE debugger.  There are:
  984.     ICEBP   - ICE Break Point
  985.     UMOV    - User Move Data
  986.     LOADALL - Loads the Entire CPU State
  987.  
  988. Contributor:  Raymond Moon, raymoon@moonware.dgsys.com
  989. Last changed: 4 Nov 95
  990.