home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nasmide.zip / nasmide.hlp (.txt) < prev    next >
Borland Turbo Vision Help  |  1997-12-28  |  128KB  |  2,359 lines

  1. FBHF^
  2.  NASM-IDE online help
  3. Welcome to the NASM-IDE 1.1 online help. This section contains details on the using NASM-IDE to write and test your assembler code. 
  4.  Contents
  5.  Menus
  6.  Edit
  7. windows
  8.  Using
  9. Assistants
  10.  Programming
  11.  Credits
  12.  Using NASM-IDE online help
  13. You can learn about NASM-IDE and assembly language programming using NASM through this online Help system. 3
  14.  what you're reading right now is a help screen
  15.  most help screens have some highlighted items called help keywords on them
  16.    that lead to another help screen
  17.  you can use the tab key to move the cursor from one Help keyword to
  18.    another, then press enter to choose that item
  19.  with the mouse, you can click a help keyword to choose that item
  20. contents
  21. screen
  22.  Menus and hot keys
  23. You can choose from any of these commands on the menu bar: D
  24.  File
  25.  Edit
  26.  Search
  27.  Assemble
  28.  Options
  29.  Window
  30.  Help
  31. For further instructions on using the menu bar, see 'How
  32. bar' B
  33. For information about menu hot keys, go to the Hot
  34. keys section. 
  35. contents
  36. screen
  37.  How to use the menu bar
  38. When you're in a window, there are three ways to select a menu command: 
  39.   Press F10, then use the arrow keys
  40.  F10 
  41.   to go to the menu you want and use
  42.   them again to select a command.
  43.           Press enter to choose the selected
  44.           command.
  45.   Press Alt and the highlighted letter
  46.  Alt 
  47.   of the menu you want (such as Alt+F
  48.   for the File menu), use the arrow
  49.           keys to select a command, then press
  50.           enter to choose that command.
  51. You can also press the highlighted letter of a menu name or command instead of using the arrow keys. 
  52.   Click the title of the menu you want
  53.  Mouse 
  54.   to pull down, then click the menu
  55.   command you want to choose.
  56. The highlighted menu title is the currently selected menu. V
  57. Menu commands are followed by either an ellipsis mark (...), an arrow, or a hot key. k
  58.   Mark 
  59.  Name     
  60.  What the menu command does
  61.   ...  
  62.  Ellipsis 
  63.  Brings up a dialog box
  64.        
  65.           
  66.     >  
  67.  Arrow    
  68.  Displays another menu
  69.        
  70.           
  71.    F4  
  72.  Hot key  
  73.  Initiates some action when
  74.  (etc.)
  75.           
  76.  you choose that command or
  77.        
  78.           
  79.  press the specified hot key
  80. Menus
  81.  Hot Keys
  82. NASM-IDE's hot keys, or shortcuts, are two or three-key combinations you can press to enact a menu command directly, without pulling down any menus. 9
  83. NASM-IDE provides hot keys for these types of commands: \
  84.   Menu
  85. commands      Editing
  86.   Window
  87. management      Online
  88.   Program
  89. management
  90. Menus
  91.  Menu bar hot keys
  92.   Hot Key      
  93.  Goes to This Menu
  94.   Alt+A        
  95.  Assemble
  96.   Alt+E        
  97.  Edit
  98.   Alt+F        
  99.  File
  100.   Alt+H        
  101.  Help
  102.   Alt+O        
  103.  Options
  104.   Alt+S        
  105.  Search
  106.   Alt+W        
  107.  Window
  108.   Alt+X        
  109.  Exits NASM-IDE to DOS
  110.   F10          
  111.  Goes to the menu bar
  112.  Editing hot keys
  113. = Edit
  114. = Search
  115. = File
  116.   Hot Key   
  117.  What It Does                          
  118.  Menu Command
  119.   Ctrl+Del  
  120.  Removes selected text from the window 
  121. Clear
  122.             
  123.  but doesn't put it in the clipboard   
  124.             
  125.                                        
  126.   Ctrl+L    
  127.  Repeats last Find or Replace command  
  128. Search again
  129.             
  130.                                        
  131.   Alt+S R   
  132.  Opens Find and Replace dialog box     
  133. Replace
  134.             
  135.                                        
  136.   Alt+S F   
  137.  Opens a Find dialog box               
  138.             
  139.                                        
  140.   F2        
  141.  Saves file in active edit window      
  142.             
  143.                                        
  144.   F3        
  145.  Brings up Open a File dialog box so   
  146.             
  147.  you can open a file                   
  148.             
  149.                                        
  150.   Shift-Del 
  151.  Places selected text in the clipboard 
  152.             
  153.                                        
  154.   Shift-Ins 
  155.  Pastes text into the active window    
  156. Paste
  157.             
  158.  from the clipboard                    
  159.  Window management hot keys
  160. = Window
  161.   Hot Key 
  162.  What It Does                     
  163.  Menu Command
  164.   Alt+F3  
  165.  Closes the active window         
  166. Close
  167.           
  168.                                   
  169.   F5      
  170.  Zooms/unzooms the active window  
  171.           
  172.                                   
  173.   F6      
  174.  Switches the active window       
  175.           
  176.                                   
  177.   Alt+F6  
  178.  Returns to the previously active 
  179. Previous
  180.           
  181.  window                           
  182.           
  183.                                   
  184.   Ctrl+F5 
  185.  Changes size or position of      
  186. Size/Move
  187.           
  188.  active window                    
  189.  Online help hot keys
  190. = Help
  191.   Hot Key  
  192.  What It Does                     
  193.  Menu Command
  194.   F1       
  195.  Opens an online help screen      
  196.            
  197.                                   
  198.   Shift+F1 
  199.  Brings up help contents          
  200. Contents
  201.            
  202.                                   
  203. keys 
  204.  Program management hot keys
  205. =Assemble
  206.   Hot Key 
  207.  What It Does                     
  208.  Menu Command
  209.   Alt+F9  
  210.  Assembles program                
  211. Assemble
  212.           
  213.                                   
  214.   Ctrl+F9 
  215.  Runs program                     
  216.           
  217.                                   
  218.   F9      
  219.  Builds program                   
  220. Build
  221. keys 
  222.  Cancel button
  223.  [ Cancel ] 
  224. If you choose Cancel, nothing changes and no action occurs, but the dialog box is closed. i
  225. Esc is always a keyboard shortcut for Cancel even if a Cancel button does not appear in the dialog box. 
  226. contents
  227. screen
  228.  No button
  229.  [ No ] 
  230. Press N for No, or click the No button, to cancel the initiated action. 
  231. contents
  232. screen
  233.  OK button
  234.  [ OK ] 
  235. If you choose this button, the settings you've made in the dialog box are recorded in NASM-IDE. K
  236. If this is the default button, you only need to press enter to choose it. 
  237. contents
  238. screen
  239.  Yes button
  240.  [ Yes ] 
  241. Press Y for Yes, or click the Yes button, to continue the initiated action. 
  242. contents
  243. screen
  244.  Next button
  245.  [ Next ] 
  246. Pressing the Next button in an ASM Assistant will allow you to progress to the next stage of the assistant, saving any of the selections you have made so far. 
  247. contents
  248. screen
  249.  Finish button
  250.  [Finish] 
  251. The finish button appears on the final screen of an ASM Assistant. Pressing finish will cause the assistant to carry out tasks based on input from you earlier in the assistant. 
  252. contents
  253. screen
  254.  Help button
  255.  [ Help ] 
  256. Pressing the help button will bring up a help screen containing information on the currently selected part of the dialog. 4
  257. Help can also be activated by pressing the F1 key. 
  258. contents
  259. screen
  260.  Open button
  261.  [ Open ] 
  262. The open button opens a new edit window and places the selected file in that window. 
  263. contents
  264. screen
  265.  History list
  266. The history list attached to an input box lists whatever text you typed the last few times you used the dialog box. b
  267. You can get to the history list whenever you see a down-arrow icon to the right of an input box. 
  268. You can use the history list to re-enter text that you've already entered. You can also edit an entry in the history list directly. E
  269. Press esc to exit from the history list without making a selection. 
  270. contents
  271. screen
  272.  File  (Alt+F)
  273. The File menu offers choices for opening and loading existing files, creating new files, saving files, printing files, shelling to DOS and exiting NASM-IDE. &
  274. The following choices are available. 
  275.  New                Open               Reopen
  276.  Save               Save
  277. As            Save
  278.  Change
  279. Dir         Print              DOS
  280. shell
  281.  Exit
  282. Menus
  283.  File
  284. Selecting New presents you with a submenu containing two options, described below. 
  285.  Blank file
  286. Opens a new edit window with the default name Untitled and automatically makes the new edit window active. w
  287. Untitled files are used as temporary edit buffers and NASM-IDE prompts you to name an untitled file when you save it. *
  288.  ASM Assistant...
  289. Selecting ASM Assistant will start the new file assistant. For more information see Using
  290. Assistants. 
  291.  ASM Assistants
  292. The current version of NASM-IDE only features one ASM Assistant, the create
  293. assistant. 
  294. contents
  295.  Create new file assistant (1/4)
  296. The create new file assistant helps you to create a framework for your assembler project. It does this by asking questions about how you would like your source code file creating, and then automatically inserts the required text into a new edit window. 9
  297. The create new file assistant consists of four screens. Y
  298.  welcome screen
  299.  code
  300. generation
  301. options
  302.  segement
  303. options
  304.  confirmation
  305. screen
  306. contents
  307.  Create new file assistant (2/4)
  308. The code generation screen is shown below. 
  309.  ASM Assistant 2/4 
  310.                                                    
  311.  A     Select the options which you wish to      A 
  312.   S      include in your assembler project      S  
  313.    M                                           M   
  314.                                                    
  315.       
  316.  Code
  317. Generation 
  318.      
  319.       
  320. ) 16 bit                           
  321.      
  322.       
  323.  ( ) 32 bit (386+)                    
  324.      
  325.       
  326.      
  327.       
  328.  Start
  329. Address 
  330.      
  331.       
  332.  0000h (DOS .SYS file)                
  333.      
  334.       
  335.  0100h (DOS .COM file)                
  336.      
  337.       
  338.      
  339.                                                    
  340.        Cancel 
  341.         Help  
  342.        Next
  343.       
  344.        
  345.        
  346.        
  347.       
  348.                                                    
  349. create
  350. assistant
  351. (1/4)
  352.  Create new file assistant (2/4)
  353.  Code Generation 
  354. ) 16 bit                           
  355.  ( ) 32 bit (386+)                    
  356. Allows you to select whether the assembler should use 16 or 32 bit code generation. Please note that even if you select 16 bit code, you can still make use of 32 bit registers and opcodes. 8
  357. This option corresponds to a BITS assembler directive. ,
  358. create
  359. assistant
  360. (2/4)
  361.  Create new file assistant (2/4)
  362.  Start Address 
  363.  0000h (DOS .SYS file)                
  364.  0100h (DOS .COM file)                
  365. Allows the code start address to be set. This only applys to binary output code (.COM and .SYS), and corresponds to an ORG assembler directive. ,
  366. create
  367. assistant
  368. (2/4)
  369.  Create new file assistant (3/4)
  370. The segment options screen is shown below. q
  371.  ASM Assistant 3/4 
  372.                                                    
  373.  A     Select which segments you would like      A 
  374.   S    ASM Assistant to automatically insert    S  
  375.    M        into your assembler project        M   
  376.                                                    
  377.       
  378.  Segments 
  379.      
  380.       
  381.  [ ] .text (main code segment)        
  382.      
  383.       
  384.  [ ] .data (initialised data)         
  385.      
  386.       
  387.  [ ] .bss  (uninitialised data)       
  388.      
  389.       
  390.      
  391.                                                    
  392.        Cancel 
  393.         Help  
  394.        Next
  395.       
  396.        
  397.        
  398.        
  399.       
  400.                                                    
  401. create
  402. assistant
  403. (2/4)
  404.  Create new file assistant (3/4)
  405.  Segments 
  406.  [ ] .text (main code segment)        
  407.  [ ] .data (initialised data)         
  408.  [ ] .bss  (uninitialised data)       
  409. Allows you to select what segments to insert into the new file. This option corresponds to a SEGMENT assembler directive. 
  410.  .text - this is the segemnt where program code is entered
  411.  .data - this is where initialised data is entered (using the DB/DW/DD opcodes)
  412.  .bss  - this is where uninitialised data is entered (using the RESB/RESW/RESD opcodes}
  413. Not all segment names apply to all output type, refer to the programming
  414. NASM section for more information. ,
  415. create
  416. assistant
  417. (3/4)
  418.  Create new file assistant (4/4)
  419. The confirmation screen is shown below, press Finish to create the new source code file, press Cancel to exit from the assistant. {
  420.  ASM Assistant 4/4 
  421.                                       
  422.  A      ASM Assistant will now      A 
  423.   S     create your assembler      S  
  424.    M           project            M   
  425.                                       
  426.        Cancel 
  427.          Finish 
  428.       
  429.        
  430.          
  431.       
  432. create
  433. assistant
  434. (3/4)
  435.  File
  436. Open (F3)
  437. The open command displays the Open file dialog box. In this dialog box, you select the source code file you want to open in an Edit window. *
  438. The Open file dialog box is shown below. 
  439.  Open file 
  440.                                                
  441.   Name                                         
  442.    *.ASM                      
  443.     Open   
  444.                                     
  445.   Files                                        
  446.    BINTEST.ASM   
  447.                   Cancel  
  448.    DIFF.ASM      
  449.                   
  450.    LEAP.ASM      
  451.                              
  452.    DOCS\         
  453.                    Help   
  454.    TEMP\         
  455.                   
  456.    TERMINAL\     
  457.                              
  458.    ..\           
  459.                              
  460.                  
  461.                              
  462.               
  463.                                                
  464.  C:\NASMIDE\EXAMPLES\*.ASM                     
  465.  BINTEST.ASM  1343      Nov 15, 1997   2:39pm  
  466. The dialog is made up of the following elements. 
  467.  an input box with a history
  468.  a list box to traverse
  469.  the standard Cancel and Help action buttons
  470.  an open button
  471.  an information panel that describes the selected file
  472.  File name input box
  473.  Name 
  474.                                  
  475. The Name input box is where you enter the filename you want to open, or save the file under, or the file-name mask for the files list box. 3
  476. This input box has a history
  477. list attached to it. 
  478. contents
  479.  Files list box
  480.  Files 
  481.                                  
  482.   FILENM01.ASM  
  483.   FILENM09.ASM  
  484.   FILENM02.ASM  
  485.   FILENM10.ASM  
  486.   FILENM03.ASM  
  487.   FILENM11.ASM  
  488.   FILENM04.ASM  
  489.   FILENM12.ASM  
  490.   FILENM05.ASM  
  491.   ..\           
  492.   FILENM06.ASM  
  493.   \MOREXAMP     
  494.   FILENM07.ASM  
  495.   \TOURS        
  496.   FILENM08.ASM  
  497.   \ANSWERS.DIR  
  498. The files list box lists the names of files in the current directory that match the file-name mask in the file
  499. input
  500. box, plus the parent directory and all subdirectories. 
  501. contents
  502.  File
  503. Reopen
  504. Choose File|Reopen to reopen a recently closed file. When you close a file, it is added to the Reopen list. 
  505. When you select Reopen, a list of the five most recently closed files is displayed. Select the file you wish to reopen using the mouse, cursor keys, or by pressing the number shown in red to the left of the filename. 8
  506. The selected file will be opened in a new edit window. 
  507. contents
  508.  File
  509. Save (F2)
  510. The save command saves the file that is in the active Edit window to disk. If the file is untitled then NASM-IDE opens the Save
  511. As dialog box so you can rename the file and save it in a different directory or on a different drive. 
  512.  File
  513. Save As...
  514. Save As opens the Save file as dialog box, where you can save the file in the active Edit window under a different name, in a different directory, or on a different drive. n
  515. You can enter the new file name, including the drive and directory, and click or choose OK to save the file. -
  516. The Save file as dialog box is shown below. 
  517.  Save file as 
  518.                                                
  519.   Name                                         
  520.    *.ASM                      
  521.      OK    
  522.                                     
  523.   Files                                        
  524.    BINTEST.ASM   
  525.                   Cancel  
  526.    DIFF.ASM      
  527.                   
  528.    LEAP.ASM      
  529.                              
  530.    DOCS\         
  531.                    Help   
  532.    TEMP\         
  533.                   
  534.    TERMINAL\     
  535.                              
  536.    ..\           
  537.                              
  538.                  
  539.                              
  540.               
  541.                                                
  542.  C:\NASMIDE\EXAMPLES\*.ASM                     
  543.  BINTEST.ASM  1343      Nov 15, 1997   2:39pm  
  544. The dialog is made up of the following elements. 
  545.  an input box with a history
  546.  a list box to traverse
  547.  the standard Cancel and Help action buttons
  548.  an OK (save) button
  549.  an information panel that describes the selected file
  550.  File
  551. Save all
  552. Save all saves all modified files in open edit windows. 
  553.  File
  554. Change dir...
  555. Change dir brings up the Change
  556. Directory
  557. dialog
  558. box, where you can specify a directory to make current. U
  559. The current directory is the one NASM-IDE uses to save files and to look for files. 
  560.  The Change Directory dialog box
  561. The Change Directory dialog box consists of an input box, a list box, the standard OK and Help buttons, and two other buttons: Chdir and Revert. |
  562.  Directory
  563. name 
  564.                                      
  565. The Directory Name input box is where you type in the path of the new directory. 
  566.  Directory
  567. tree 
  568.    Drives                            
  569. C:\                            
  570.      
  571. NASMIDE                      
  572.        
  573. EXAMPLES                   
  574. The Directory Tree list box is where you point to (or move the cursor to) a directory name and choose the directory you want. 
  575. If you're using the keyboard, press enter to make the selected directory be the current directory, then choose OK or press esc to exit the dialog box. (
  576.  [Chdir] 
  577. The Chdir button initiates the directory change once you've selected or typed in a directory name. +
  578.  [Revert] 
  579. The Revert button goes back to the previous directory, as long as you haven't yet exited the dialog box. 
  580. contents
  581. screen
  582.  The Change Directory dialog box
  583.  Directory name 
  584.                                      
  585. The Directory Name input box is where you type in the path of the new directory you want to change to. 3
  586. This input box has a history
  587. list attached to it. /
  588. Change
  589. Directory
  590. dialog
  591. screen
  592.  The Change Directory dialog box
  593.  Directory tree 
  594.    Drives                            
  595. C:\                            
  596.      
  597. NASMIDE                      
  598.        
  599. EXAMPLES                   
  600. The Directory Tree list box is where you select the directory you want to move to. i
  601. From the keyboard, press enter to make the selected directory be the current directory, then choose OK. k
  602. As soon as you change directories, the new current directory tree appears in the Directory Tree list box. /
  603. Change
  604. Directory
  605. dialog
  606. screen
  607.  The Change Directory dialog box
  608.  [Chdir] 
  609. Once you've typed a directory name in the input box, or selected one in the Directory Tree list box, choose the Chdir button. (
  610. Choose Cancel if you change your mind. a
  611. You can also just press enter once the file is selected, or you can double-click the file name. /
  612. Change
  613. Directory
  614. dialog
  615. screen
  616.  The Change Directory dialog box
  617.  [Revert] 
  618. If you change your mind about the directory you've picked and you want to go back to the previous one (and you haven't yet exited the dialog box), choose the revert button. /
  619. Change
  620. Directory
  621. dialog
  622. screen
  623.  File
  624. Print
  625. The print command prints the contents of the active edit window to a printer attached to LPT1. F
  626. The print command is disabled if the active window can't be printed. 
  627. contents
  628. screen
  629.  File
  630. DOS Shell
  631. With the DOS shell command, you can leave NASM-IDE temporarily to perform a DOS command or enter another program. G
  632. To return to NASM-IDE, type EXIT at the DOS prompt, then press enter. 
  633. contents
  634. screen
  635.  File
  636. Exit (Alt+X)
  637. The exit command exits NASM-IDE, removes it from memory, and returns you to DOS. c
  638. If you've modified a source file without saving it, NASM-IDE prompts you to do so before exiting. 
  639. contents
  640. screen
  641.  Edit (Alt+E)
  642. The edit menu provides commands to cut, copy, and paste text in edit windows. D
  643. You can also open a Clipboard window to view or edit its contents. /
  644. You can choose from these edit menu commands. Q
  645.  Undo         Cut             Copy
  646.  Paste        Clear           Show
  647. clipboard
  648. Menus
  649.  Edit
  650. Undo (Alt+BkSp)
  651. The undo command takes back the last editing command you performed on a line. Undo works on the last modified or deleted line. 
  652.  Edit
  653. Cut (Shift+Del)
  654. The cut command removes the selected text from your document and places the text in the clipboard. x
  655. You can then choose Edit
  656. Paste to paste the cut text into any other document (or somewhere else in the same document). [
  657. The text remains selected in the clipboard so you can paste it as many times as you want. 
  658.  Edit
  659. Copy (Ctrl+Ins)
  660. The copy command leaves the selected text intact but places an exact copy of it in the clipboard. F
  661. To paste the copied text into any other document, choose Edit
  662. Paste. 
  663.  Edit
  664. Paste (Shif+Ins)
  665. The paste command inserts the selected text from the clipboard into the current window at the cursor position. 
  666.  Edit
  667. Clear (Ctrl+Del)
  668. The clear command removes the selected text but does not put it into the clipboard. Q
  669. This means you can't paste the text as you could if you had chosen Cut or Copy. &
  670. The cleared text is not retrievable. 
  671.  Edit
  672. Show clipboard
  673. The show clipboard command opens the clipboard window, which stores the text you cut and copy from other windows. Any text you cut or copy is appended to the end of the clipboard. f
  674. The currently selected (highlighted) clipboard text is the text NASM-IDE uses when you choose Paste. 
  675.  Search (Alt+S)
  676. The search menu provides commands to search for text in your source code files. "
  677. These are the available options: <
  678.  Find     Replace      Search
  679. Again      Go
  680. Number
  681. Menus
  682.  Search
  683. Find...
  684. The find command displays the Find
  685. dialog
  686. box, where you type in the text you want to search for. t
  687. You can set several options in this dialog box that affect the search. (Ctrl+Q F is a shortcut to the dialog box.) 
  688. Search
  689.  The Find dialog box
  690. The Find dialog box is shown below. 
  691.  Find 
  692.                                     
  693.   Text
  694. find                      
  695.                                
  696.                                     
  697. sensitive               
  698. Whole
  699. words
  700. only             
  701.                                     
  702.                                     
  703.                  OK   
  704.     Cancel 
  705.                
  706. Search
  707.  The Find/Replace dialog box
  708.  Text to find:
  709.                  
  710. The text to find input box is where you enter the search string. =
  711. To begin the search, choose OK, choose Cancel to forget it. 
  712. If you want to enter a string that you've searched for previously, press the down arrow key to show the history
  713. list, then choose from that list. #
  714. dialog
  715. screen
  716.  The Find/Replace dialog box
  717.  [ ] Case sensitive 
  718. [ ] When Case Sensitive is checked (on), NASM-IDE differentiates uppercase from lowercase when performing a search. $
  719. Case sensitive off is the default. #
  720. dialog
  721. screen
  722.  The Find/Replace dialog box
  723.  [X] Whole words only 
  724. When the whole words only option is checked (on), NASM-IDE searches for words only - the search string must have punctuation or space characters on both sides. #
  725. dialog
  726. screen
  727.  Search
  728. Replace...
  729. The replace command displays the replace dialog box, where you type in the text you want to search for and text you want to replace it with. 
  730. Search
  731.  The Replace dialog box
  732. The replace dialog box is shown below. Most components of the replace dialog box are identical to those in the find dialog box. 
  733.  Replace 
  734.                                       
  735.   Text
  736. find                        
  737.                                  
  738.                                       
  739.   New
  740. text                            
  741.                                  
  742.                                       
  743. sensitive                 
  744. Whole
  745. words
  746. only               
  747.    [X]
  748. Prompt
  749. replace              
  750. Replace
  751. all                    
  752.                                       
  753.            OK   
  754.       Cancel 
  755.        
  756.          
  757.       
  758.        
  759. Search
  760.  The Replace dialog box
  761.  New text:
  762.                  
  763. Use this box to enter your replacement string. You can also use the history
  764. list to the right of the box to select a string you've used previously. f
  765. If all your options and buttons are set correctly, just press enter to begin the search and replace. &
  766. Replace
  767. dialog
  768. screen
  769.  The Replace dialog box
  770.  [X] Prompt on replace   
  771. Check this box when you want NASM-IDE to prompt you before replacing each time it finds the search string in your file. &
  772. Replace
  773. dialog
  774. screen
  775.  The Replace dialog box
  776.  [ ] Replace all 
  777. Check this box when you want NASM-IDE to replace all occurrences of the search string found. &
  778. Replace
  779. dialog
  780. screen
  781.  Search
  782. Search again
  783. The search again command repeats the last find or replace command. ]
  784. All settings you made in the find dialog box remain in effect when you choose search again. 
  785. Search
  786.  Search
  787. Go to line number...
  788. The go to line number command displays the dialog box shown below, which prompts for the line number you want to find. l
  789. NASM-IDE displays the current line number and column number in the lower left corner of every edit window.  
  790.  Go to line number 
  791.                                      
  792.    Enter
  793. number       
  794.                                      
  795.      OK   
  796.     Cancel 
  797.      Help  
  798. Search
  799.  Search
  800. Go to line number...
  801.  Enter new line number 
  802.           
  803. The enter new line number input box is where you type in which line of source code you want to go to. If you enter a number which is larger than the number of lines in the edit window, NASM-IDE will go to the last line in the window. 
  804. You can enter and search for a specific line number in your file, or you can use the history list to select a previously used number. j
  805. Current line and column numbers for your file are displayed in the lower left corner of the edit window. 
  806. Search
  807.  Assemble (Alt+A)
  808. You use the commands on the assemble menu to assemble, build, and run your program. %
  809. You can choose from these commands: s
  810.  Assemble                   Build
  811.  Run                        Primary
  812.  Clear
  813. primary
  814. file         Parameters
  815. Menus
  816.  Assemble
  817. Assemble (Alt+F9)
  818. The Assemble
  819. Assemble command assembles the file in the active edit window. 
  820. NASM-IDE runs NASM in a DOS shell, and unless any errors occur, a blank screen will be visible while assembly is in progress. p
  821. When assembly is complete, the NASM-IDE desktop is redisplayed, and the error
  822. information
  823. window is displayed. 
  824. Assemble
  825.  Assemble
  826. Build (F9)
  827. The Assemble
  828. Build command works in two ways depending on your NASM-IDE configuration. k
  829.  if no primary
  830. file has been selected then Assemble
  831. Build
  832.    works in the same way as Assemble
  833. Assemble
  834.  if a primary
  835. file has been selected then Assemble
  836. Build
  837.    will assemble the primary file, regardless of the active edit window
  838. Assemble
  839.  Assemble
  840. Run (Ctrl+F9)
  841. The Assemble
  842. Run command works in two ways depending on your NASM-IDE configuration. z
  843.  if no primary
  844. file has been selected then Assemble
  845.    will assemble and run the program in the active edit window
  846.  if a primary
  847. file has been selected then Assemble
  848.    will assemble and run the primary file, regardless of the active edit
  849.    window
  850. When your program is run, NASM-IDE passes any parameters you have entered using the Run
  851. Parameters command. 
  852. Assemble
  853.  Assemble
  854. Primary File...
  855. The Assemble
  856. Primary File command leads to the Primary
  857. dialog
  858. box, where you specify which .ASM file will be assembled when you choose Assemble
  859. Build. i
  860. Use Primary File when you're working on a program that uses several source code files or include files. ^
  861. No matter which file you've been editing, Build and Run always operate on your primary file. 
  862. If you specify another file as a primary file, but want to assemble only the file in the active edit window, choose Assemble (Alt+F9). 
  863. Assemble
  864.  The Primary File dialog box
  865. The Primary File dialog box is shown below. 
  866.  Primary file 
  867.                                                
  868.   Name                                         
  869.    *.ASM                      
  870.      OK    
  871.                                     
  872.   Files                                        
  873.    BINTEST.ASM   
  874.                   Cancel  
  875.    DIFF.ASM      
  876.                   
  877.    LEAP.ASM      
  878.                              
  879.    DOCS\         
  880.                    Help   
  881.    TEMP\         
  882.                   
  883.    TERMINAL\     
  884.                              
  885.    ..\           
  886.                              
  887.                  
  888.                              
  889.               
  890.                                                
  891.  C:\NASMIDE\EXAMPLES\*.ASM                     
  892.  BINTEST.ASM  1343      Nov 15, 1997   2:39pm  
  893. The dialog is made up of the following elements. 
  894.  an input box with a history
  895.  a list box to traverse
  896.  the standard Cancel and Help action buttons
  897.  an OK (save) button
  898.  an information panel that describes the selected file
  899. Assemble
  900. Primary
  901. File...
  902. screen
  903.  Clear Primary file
  904. The clear primary file command deselects the primary
  905. file. k
  906. Once you clear the primary file, the Build and Run options will use the file in the active editor window. 
  907. Assemble
  908. Parameters...
  909. The Run
  910. Parameters command brings up the program
  911. parameters
  912. dialog
  913. box, where you type in command-line arguments for your running programs exactly as if you had typed them on the DOS command line. X
  914. You can't use DOS redirection commands (< and >) in the program parameters dialog box. 
  915. Assemble
  916.  The Program Parameters dialog box
  917. The Program Parameters dialog box (shown below) consists of an input box and the standard OK, Cancel, and Help buttons. m
  918.  Program parameters 
  919.                                                 
  920.   Parameters                               
  921.                                                 
  922.                 OK   
  923.     Cancel 
  924.      Help  
  925.               
  926. Assemble
  927.  The Program Parameters dialog box
  928.  Parameters 
  929.                                       
  930. The parameters input box is where you enter the parameters that you want NASM-IDE to pass to your running program. =
  931. You don't need to enter the program name in this input box. ;
  932. Parameters take effect only when your program is started. )
  933. Parameters
  934. dialog
  935. screen
  936.  Options (Alt+O)
  937. The options menu contains commands that let you view and change various default settings in NASM-IDE. ;
  938.  Assembler...        Directories...        Environment...
  939. Menus
  940.  Options
  941. Assembler...
  942. The Options
  943. Assembler command displays the Assembler
  944. Options dialog box, where you choose how you want the assembler to generate code and which types of warnings you want the assembler to give.  
  945. Options
  946. screen
  947.  The Assembler Options dialog box
  948. The Assembler Options dialog box is shown below. 
  949.  Assembler Options 
  950.                                    
  951.   Output format                    
  952. executable
  953. file         
  954. device
  955. driver           
  956. object
  957. file      
  958. Win32
  959. object
  960. file    
  961. object
  962. file     
  963. object
  964. file            
  965.                                    
  966.   Warnings                         
  967.    [X]
  968. macro
  969. parameters    
  970.    [X]
  971. Missing
  972. colon
  973. label     
  974.                                    
  975.                                    
  976.      OK   
  977.    Cancel 
  978.     Help  
  979. Assemble
  980. screen
  981.  The Assembler Options dialog box
  982.  ( ) COM executable file 
  983. When this option is selected NASM-IDE assembles your code into a flat form binary file, with a .COM extension. S
  984. This is the only output type that can be executed using the Assemble
  985. Run command. 
  986. NASM-IDE does not check that the code produced is a valid executable, and running code which should not be executed may cause unpredictable results. %
  987. Assembler
  988. Options
  989. screen
  990.  The Assembler Options dialog box
  991.  ( ) SYS device driver 
  992. When this option is selected NASM-IDE assembles your code into a flat form binary file, with a .SYS extension. %
  993. Assembler
  994. Options
  995. screen
  996.  The Assembler Options dialog box
  997.  ( ) DOS 16 bit object file 
  998. When this option is selected NASM-IDE assembles your code into a 16 bit relocatable object code format file, with a .OBJ extension. 
  999. Files assembled in this mode can then be used with high level languages such as C and Pascal. For more information on using object files with other langauges, consult their documentation. %
  1000. Assembler
  1001. Options
  1002. screen
  1003.  The Assembler Options dialog box
  1004.  ( ) Win32 32 bit object file 
  1005. When this option is selected NASM-IDE assembles your code into a 32 bit relocatable object code format file, with a .OBJ extension. k
  1006. The Win32 format option generates Microsoft Win32 (Windows 95 or Intel platform Windows NT) object files. %
  1007. Assembler
  1008. Options
  1009. screen
  1010.  The Assembler Options dialog box
  1011.  ( ) COFF 32 bit object file  
  1012. When this option is selected NASM-IDE assembles your code into a 32 bit relocatable object code format file, with a .O extension. \
  1013. The COFF object format generates code which is compatible for use with the DJGPP compiler. &
  1014. Assembler
  1015. Options
  1016. screen
  1017.  The Assembler Options dialog box
  1018.  ( ) OS/2 object file 
  1019. When this option is selected NASM-IDE assembles your code into a 16 bit relocatable object code format file, with a .OBJ extension, which includes extensions for use with the OS/2 operating system. %
  1020. Assembler
  1021. Options
  1022. screen
  1023.  The Assembler Options dialog box
  1024.  [ ] Too few macro parameters 
  1025. When this option is enabled NASM-IDE will generate a warning if a macro call involves a number of parameters which the macro in question is not ready to support. %
  1026. Assembler
  1027. Options
  1028. screen
  1029.  The Assembler Options dialog box
  1030.  [ ] Missing colon for label 
  1031. When this option is enabled NASM-IDE will generate a warning if a line in the source code is encountered which appears to be a label but does not have a trailing colon. m
  1032. The purpose of this warning is that it is possible that the text is a mistyped opcode, rather than a label. %
  1033. Assembler
  1034. Options
  1035. screen
  1036.  Options
  1037. Directories...
  1038. This command opens the Directories
  1039. dialog
  1040. box, which contains several input boxes. 
  1041. The directories dialog box is where you specify the directories NASM-IDE will use when running and when storing your programs.  
  1042. Options
  1043. screen
  1044.  The Directories dialog box
  1045. The directories dialog box is shown below. 
  1046.  Directories 
  1047.                                                 
  1048.   Include
  1049. directory                        
  1050.                                                 
  1051.   Output
  1052. directory                         
  1053.                                                 
  1054.                 OK   
  1055.     Cancel 
  1056.      Help  
  1057.               
  1058. Options
  1059. screen
  1060.  The Directories dialog box
  1061.  Include directory 
  1062.                                     
  1063. This input box specifies the directory, or directories that contains your standard include files. J
  1064. Include files are those specified with the %include assembler directive. B
  1065. Multiple directories are separated be a semi-colon, for example: &
  1066.  C:\NASMIDE;C:\NASMIDE\INCLUDE;....;
  1067. Directories
  1068. dialog
  1069. screen
  1070.  The Directories dialog box
  1071.  Output directory 
  1072.                                  
  1073. This input box specifies the directory that stores your output files generated by the assembler. b
  1074. If this entry is blank, your output files are stored in the directory where your source code is. 1
  1075. You cannot specify multiple output directories. *
  1076. Directories
  1077. dialog
  1078. screen
  1079.  Options
  1080. Environment
  1081. The environment command allows you to customise NASM-IDE with environment-wide settings. 4
  1082. The Environment Options dialog box is shown below. 
  1083.  Environment Options 
  1084.                                     
  1085.   Screen size                       
  1086. lines                     
  1087. 43/50
  1088. lines                  
  1089.                                     
  1090.   Editor                            
  1091. Create
  1092. backup
  1093. files          
  1094.    [X]
  1095. Autosave
  1096. assemble         
  1097.                                     
  1098.   Startup                           
  1099. Display
  1100. screen          
  1101.                                     
  1102.                                     
  1103.      OK   
  1104.     Cancel 
  1105.      Help  
  1106. Options
  1107. screen
  1108.  The Environment Options dialog box
  1109.  ( ) 25 lines    
  1110. When Screen Size is set to 25 Lines (the default), NASM-IDE uses 25 lines and 80 columns. n
  1111. This is the only screen size available on systems with a monochrome display or Color Graphics Adapter (CGA). '
  1112. environment
  1113. options
  1114. screen
  1115.  The Environment Options dialog box
  1116.  ( ) 43/50 lines 
  1117. If your PC has an EGA or a VGA, you can set the Screen Size option to 43/50 lines. m
  1118. With this setting on, NASM-IDE uses 43 lines by 80 columns for an EGA, or 50 lines by 80 columns for a VGA. '
  1119. environment
  1120. options
  1121. screen
  1122.  The Environment Options dialog box
  1123.  [X] Create backup files 
  1124. When you check Create backup files (the default) and you choose File
  1125. Save, NASM-IDE automatically creates a backup of the source file that's in the edit window and gives that backup file the extension .BAK. '
  1126. environment
  1127. options
  1128. screen
  1129.  The Environment Options dialog box
  1130.  [X] Autosave on assemble 
  1131. When you check Autosave on assemble NASM-IDE automatically saves the file in the active edit window before running the assembler. If this option is not enables then NASM-IDE will prompt you to save modified files before assembling. '
  1132. environment
  1133. options
  1134. screen
  1135.  The Environment Options dialog box
  1136.  [X] Display logo screen 
  1137. When checked, NASM-IDE displays a graphical logo screen on startup (only on VGA systems). On some computers this may prevent NASM-IDE from starting correctly. When this option is disabled, a simple text message is displayed instead. '
  1138. environment
  1139. options
  1140. screen
  1141.  Window (Alt+W)
  1142. The window menu contains commands for manipulating and opening windows. 
  1143. Most of the windows you open from this menu have all the standard window elements, like scroll bars, a close box, and zoom icons. O
  1144. For more about windows and their elements, see the Window
  1145. basics help screen. ?
  1146.  Window management commands
  1147.  Tile              Cascade
  1148.  Close
  1149. All         Size/Move
  1150.  Zoom              Next
  1151.  Previous          Close
  1152.  Error
  1153. information
  1154. Menus
  1155.  Window basics
  1156. Most of what you see and do in NASM-IDE happens in a window. a
  1157. A window is a bordered screen area that you can move, resize, zoom, rearrange, close, and open. 
  1158. NASM-IDE makes it easy to spot the active window; it always has a double-lined border around it, and it always has these elements: 
  1159.    Close
  1160. box              Zoom
  1161.        
  1162.                       
  1163. Title
  1164.                             
  1165.                             
  1166.                             
  1167.                             
  1168.  Scroll
  1169.                             
  1170.                             
  1171.                             
  1172.                      
  1173.                 Scroll
  1174. You can have any number of windows open in NASM-IDE (memory allowing), but only one window can be active at any time. The active window is the one that you're currently working in. 
  1175. Generally, any command you choose or text you type applies only to the active window. (But if you have the same file open in several windows, the action applies to the file in each of those windows.) j
  1176. If your windows overlap, the active window is always the topmost one (the one on top of all the others). 
  1177. Edit windows also show the cursor's position (the current line and column number) as YY:XX in the bottom of the edit window frame, where YY is the line number and XX is the column number. 
  1178. contents
  1179. screen
  1180.  Zoom box
  1181. The zoom box appears in the window's upper right corner. y
  1182. If the icon in the zoom box is an up arrow, you can click the arrow to enlarge the window to the largest size possible. 
  1183. If the icon is a double-headed arrow, the window is already at its maximum size; click the arrow to return the window to its previous size. E
  1184. To zoom a window from the keyboard, choose Window|Zoom or press F5. !
  1185. Window
  1186. basics
  1187. screen
  1188.  Close box
  1189. You can click the close box to quickly close the window. Alternatively, you can choose Window|Close or press Alt-F3. !
  1190. Window
  1191. basics
  1192. screen
  1193.  Title bar
  1194. You can double-click the title bar to zoom the window. You can also drag the title bar to move the window around. !
  1195. Window
  1196. basics
  1197. screen
  1198.  Scroll bars
  1199. Scroll bars are horizontal or vertical bars that show both mouse and keyboard users how far into the file they've gone. You use these bars with a mouse to scroll the contents of the window. {
  1200.  Click the arrow at either end to scroll one line at a time. (Keep the
  1201.    mouse button pressed to scroll continuously.)
  1202.  You can click the shaded area at either end of the scroll box to scroll
  1203.    the window one page (windowful) at a time.
  1204.  You can drag the scroll box to any spot on the scroll bar to quickly
  1205.    move to a spot in the window relative to the position of the scroll box.
  1206. Window
  1207. basics
  1208. screen
  1209.  Window
  1210. Choose Window
  1211. Tile to tile all your open edit windows. L
  1212.                
  1213.                
  1214.                
  1215.                
  1216.                
  1217.                
  1218.                
  1219.                
  1220.                
  1221.                
  1222.                
  1223.                
  1224.                
  1225.                
  1226.                
  1227.                
  1228.              Tiled windows
  1229. Window
  1230. screen
  1231.  Window
  1232. Cascade
  1233. Choose Window
  1234. Cascade to stack all open edit windows. A
  1235.                          
  1236.                          
  1237.                          
  1238.                          
  1239.                          
  1240.       Cascaded edit windows
  1241. Window
  1242. screen
  1243.  Window
  1244. Close all
  1245. Choose close all to close all windows. Choose close to close the active window. 
  1246. Window
  1247. screen
  1248.  Window
  1249. Size/Move (Ctrl+F5)
  1250. Choose this command to change the size or position of the active window. 
  1251.  Size
  1252. If you press shift while you use the arrow keys, you can change the size of the window. When it's at the size you want, press enter. Q
  1253. If a window has a resize corner, you can drag that corner to resize the window. 
  1254.  Move
  1255. When you choose Window
  1256. Size/Move, the active window moves in response to the arrow keys. Once you've moved the window to where you want it, press enter. 7
  1257. You can also move a window by dragging its title bar. 
  1258. Window
  1259. screen
  1260.  Window
  1261. Zoom (F5)
  1262. Choose zoom to resize the active window to the maximum size. b
  1263. If the window is already zoomed, you can choose this command to restore it to its previous size. 
  1264. You can also double-click anywhere on the window's title bar (except where an icon appears), or on the zoom
  1265. box in the window's upper right corner, to zoom or unzoom the window. 
  1266. Window
  1267. screen
  1268.  Window
  1269. Close (Alt+F3)
  1270. Choose close to close the active window. N
  1271. You can also click the close
  1272. box in the upper left corner to close a window. (
  1273. Choose Close
  1274. all to close all windows. 
  1275. Window
  1276. screen
  1277.  Window
  1278. Next (F6)
  1279. Choose next to make the next window active, which makes it the topmost open window. 
  1280. Window
  1281. screen
  1282.  Window
  1283. Previous (Shift+F6)
  1284. Choose previous to make the most-recently active window active again. 
  1285. Window
  1286. screen
  1287.  Window
  1288. Error information
  1289. The error information window displays the contents of the NASM.LOG file which is created by the assembler each time you assemble, build or run your code. ~
  1290. If no error message were returned by the assembler, the error information window displays the message 'No errors occurred.'. 6
  1291. If an error message occurs you can do the following: 
  1292.  Use the cursor keys or the mouse and the scroll bar to move the highlight
  1293.    bar over the error message you are interested in.
  1294.  Press enter or double-click on an error message to go to the source code
  1295.    which generated the error. If the source code file is open, NASM-IDE makes
  1296.    the window containing the file active, and places the cursor at the start
  1297.    of the line containing the error. If the code file is not open, NASM-IDE
  1298.    will open a new window and will place the cursor at the start of the line
  1299.    containing the error.
  1300. The error information window is displayed automatically by NASM-IDE after the assembler has been used. 
  1301. Window
  1302. screen
  1303.  Help (Alt+H)
  1304. The help menu provides access to on-line help, which comes up in a special help window. The text in the help window is a help screen. 
  1305. Help is also available in the form of one-line menu and dialog-box hints which appear on the status line whenever you select a menu command or dialog box item. /
  1306. These are the available help system commands: O
  1307.  Help
  1308. contents
  1309.  Using
  1310.  Integer
  1311. opcodes
  1312.  Floating
  1313. point
  1314. opcodes
  1315.  About...
  1316. Menus
  1317.  Help
  1318. Help contents (F1)
  1319. The help
  1320. contents screen provides a summary of several help topics you can choose from. 
  1321. screen
  1322.  Help
  1323. Using help
  1324. The using
  1325. help screen provides a summary of how to use the NASM-IDE on-line help system. 
  1326. screen
  1327.  Help
  1328. Integer opcodes
  1329. The integer opcodes help provides an on-line reference for all 80x86 family opcodes. @
  1330. To view the integer opcodes help, choose Help
  1331. Integer opcodes. 
  1332. screen
  1333.  Help
  1334. Floating point opcodes
  1335. The floating point opcodes help provides an on-line reference for all 80x87 family opcodes. N
  1336. To view the floating point opcodes help, choose Help
  1337. Floating point opcodes. 
  1338. screen
  1339.  Help
  1340. About...
  1341. When you choose the about command from the help menu, a dialog box appears, showing copyright and version information. T
  1342. The about box also show the URLs for the NASM-IDE homepage and the NASM homepages. )
  1343. Press Esc or click OK to close the box. 
  1344. screen
  1345.  Edit windows
  1346. Edit windows are where you type in and edit your NASM-IDE code. You can also do the following in an edit window: h
  1347.  assemble your programs
  1348.  run your programs
  1349.  read them from disk files
  1350.  save them to disk files
  1351. You can open as many edit windows as you want, within the limits of available memory. J
  1352.  Closing and opening edit windows
  1353. To close an active edit window, click the window's close
  1354. box or choose Window
  1355. Close. _
  1356. To open an edit window, choose File
  1357. Open. You can open the same file in more than one window. (
  1358.  Editor commands
  1359.  Block
  1360. commands
  1361.  Cursor
  1362. movement
  1363. commands
  1364.  Insert
  1365. delete
  1366. commands
  1367.  Miscellaneous
  1368. commands
  1369. contents
  1370. screen
  1371.  Block commands
  1372.   Mark block begin         
  1373.  Ctrl+K B
  1374.   Mark block end           
  1375.  Ctrl+K K
  1376.   Mark single word         
  1377.  Ctrl+K T
  1378.   Copy block               
  1379.  Ctrl+K C
  1380.   Move block               
  1381.  Ctrl+K V
  1382.   Delete block             
  1383.  Ctrl+K Y
  1384.   Mark line                
  1385.  Ctrl+K L
  1386.   Copy to clipboard        
  1387.  Ctrl+Ins
  1388.   Cut to clipboard         
  1389.  Shift+Del
  1390.   Delete block             
  1391.  Ctrl+Del
  1392.   Paste to clipboard       
  1393.  Shift+Ins
  1394. windows
  1395. screen
  1396.  Cursor movement commands
  1397.  Character left  
  1398.  Ctrl+S or Left arrow
  1399.  Character right 
  1400.  Ctrl+D or Right arrow
  1401.  Word left       
  1402.  Ctrl+A or Ctrl+Left arrow
  1403.  Word right      
  1404.  Ctrl+F or Ctrl+Right arrow
  1405.  Line up         
  1406.  Ctrl+E or Up arrow
  1407.  Line down       
  1408.  Ctrl+X or Down arrow
  1409.  Scroll up       
  1410.  Ctrl+W
  1411.  Scroll down     
  1412.  Ctrl+Z
  1413.  Page up         
  1414.  Ctrl+R or PgUp
  1415.  Page down       
  1416.  Ctrl+C or PgDn
  1417. windows
  1418. screen
  1419.  Insert & delete commands
  1420.  Insert mode on/off    
  1421.  Ctrl+V or Ins
  1422.  Insert line           
  1423.  Ctrl+N
  1424.  Delete line           
  1425.  Ctrl+Y
  1426.  Delete to end of line 
  1427.  Ctrl+Q Y
  1428.  Delete character left 
  1429.  Ctrl+H or Backspace
  1430.  Delete character      
  1431.  Ctrl+G or Del
  1432.  Delete word right     
  1433.  Ctrl+T
  1434. windows
  1435. screen
  1436.  Miscellaneous editor commands
  1437.  Menu bar             
  1438.  Save and edit        
  1439.  Ctrl+K S or F2
  1440.  Open file            
  1441.  Close active window  
  1442.  Alt+F3
  1443.                       
  1444.  Find                 
  1445.  Ctrl+Q F
  1446.  Find & replace       
  1447.  Ctrl+Q A
  1448.  Repeat last find     
  1449.  Ctrl+L
  1450.  Abort operation      
  1451. windows
  1452. screen
  1453.  Programming in NASM
  1454. NASM is the assembler which NASM-IDE uses to generate code from your source code files. 
  1455. This information is based on the NASM.DOC file that is distributed as part of the full NASM archive available from the NASM website (see Help
  1456. About). ,
  1457. Choose from one of the following sections. G
  1458.  Introduction
  1459.  Quick
  1460. start
  1461. users
  1462.  Writing
  1463. programs
  1464.  Floating
  1465. point
  1466. instructions
  1467.  Pseudo-opcodes
  1468.  Effective
  1469. addresses
  1470.  Unusual
  1471. instruction
  1472. sizes
  1473.  Constants
  1474.  Expressions
  1475.  Critical
  1476. expressions
  1477.  Local
  1478. labels
  1479.  Assembler
  1480. directives
  1481. preprocessor
  1482.  Output
  1483. formats
  1484.  Common
  1485. problems
  1486. contents
  1487. screen
  1488.  Introduction
  1489. The Netwide Assembler (NASM) is a fully 80x86 compatible assembler which is available for DOS and Unix based systems. NASM-IDE is a front-end for the DOS version of the assembler. \
  1490. This section of the NASM-IDE on-line help will provide information on programming in NASM. 
  1491. Please note that this help is in now way meant to be a tutorial in assembly language programming, it is simply an overview intended to get you started with NASM as quickly as possible. '
  1492. Programming
  1493. screen
  1494.  Quick start for MASM users
  1495. If you're used to writing programs with Microsoft's Macro Assembler (MASM), or with Borland's Turbo Assembler (TASM) in MASM compatible (non ideal) mode, or with A86, this section attempts to outline the major differences between MASM's syntax and NASM's. 
  1496. If you're not already used to MASM, this section will probably only be of help if you are trying to convert code from MASM to NASM. i
  1497.  Case
  1498. sensitivity
  1499.  Instructions
  1500. register
  1501. names
  1502.  Variable
  1503. typing
  1504.  Offset
  1505. square
  1506. brackets
  1507. Programming
  1508. screen
  1509.  Case sensitivity
  1510. NASM is case sensitive: it makes a difference whether you call your label 'foo', 'Foo' or 'FOO'. 
  1511. If you're assembling to the DOS
  1512. object
  1513. format or the OS/2
  1514. object
  1515. format then you can use the 'UPPERCASE' assembler directive. '
  1516. Quick
  1517. start
  1518. users
  1519.  Instructions and register names
  1520. NASM calls the floatingpoint stack registers 'st0', 'st1' and so on, whereas MASM uses 'ST(0)'. 
  1521. NASM doesn't support LODS, MOVS, STOS, SCAS, CMPS, INS, or OUTS, it only supports the size-specified versions LODSB, MOVSW, SCASD and so on. '
  1522. Quick
  1523. start
  1524. users
  1525.  Variable typing
  1526. When you declare a variable as 'var dw 0', MASM will remember that 'var' is a variable of type word. This means that instructions such as 'mov var, 2' can be unambiguously given the word size rather than byte or dword. 
  1527. NASM doesn't and won't do this. The statement 'var dw 0' merely defines 'var' to be a label marking a point in memory. NASM does not remeber that there are two bytes of data following that point in memory before the next line of code. 
  1528. If you want to store the number 2 in such a variable, you must always specify the size of the operation, for example 'mov word [var], 2'. '
  1529. Quick
  1530. start
  1531. users
  1532.  Offset and square brackets
  1533. In MASM, declaring 'var dw 0' entitles you to code 'mov ax, var' to get at the contents of the variable. In order to get the address of the variable you must write 'mov ax, offset var'. 
  1534. In NASM, 'mov ax, var' gives you the address of the variable, not the contents. To get the contents you must code 'mov ax, [var]'. 
  1535. This brings consistency to the syntax: 'mov ax, [var]' and 'mov ax, [bx]' both refer to the contents of memory and both have square brackets, whereas neither 'mov ax, bx' nor 'mov ax, var' refers to memory contents and so neither one has square brackets. 
  1536. The hybrid-style syntaxes supported by MASM and its clones, such as 'mov ax, table[bx]', where a memory reference is denoted by one portion outside square brackets and another portion inside, are also not supported by NASM. The correct syntax for the above is 'mov ax, [table + bx]'. ]
  1537. Likewise, 'mov ax, es:[di]' is incorrect in NASM, you should use 'mov ax, [es:di]' instead. '
  1538. Quick
  1539. start
  1540. users
  1541.  Writing programs with NASM
  1542. Each line of a NASM source file should contain some combination of the four fields: 0
  1543.  LABEL:    INSTRUCTION    OPERANDS    ;COMMENT
  1544. All of these fields are optional. For example, the presence or absence of the OPERANDS field is dependent on the INSTRUCTION field. l
  1545. Lines may also contain nothing but an assembler directive - see Assembler
  1546. directives for more information. 
  1547. NASM-IDE has a limit of 255 charcters per line, an error message will be displayed if you attempt to enter a line longer than this. (
  1548. Programming
  1549. screen
  1550.  Labels
  1551. A label acts as a pointer to the position in the source code where it is written. W
  1552. Labels may have white space before and after them, and can optionally end in a colon. ;
  1553. For example, the label 'START' can be defined as follows: 
  1554.     START
  1555. or  START: 
  1556. both are equally valid. However, it is possible to configure NASM so that a warning is generated if a label is the only text on a line, and it has no trailing colon (see Assembler
  1557. options). This is to help prevent mistyped opcodes being mistaken for labels. .
  1558. Labels must comply with the following rules: 
  1559.  The first character must be either a letter, a question mark (?), or an
  1560.    underscore (_), unless the label is to be a local
  1561. label
  1562.    in which case it will begin with a full stop (.).
  1563.  The characters that follow the first one can be letters, digits,
  1564.    underscores (_), '$', '#', '@', '~', '?' and '.', no spaces are allowed.
  1565. A label may also be prefixed with a $ sign to indicate that it is intended to be read as an identifier and not a reserved word. For example, if a module you are linking with defines a symbol 'eax', you can refer to it as '$eax' in NASM code to distinguish it from the register name 'eax'. ,
  1566. Writing
  1567. programs
  1568. screen
  1569.  Instructions
  1570. Instructions can be any machine opcode, see Help
  1571. Integer opcodes and Help
  1572. Floating point opcodes for information on the 80x86 instruction set. b
  1573. An instruction can be prefixed by LOCK, REP, REPE/REPZ or REPNE/REPNZ, for example: 'rep movsw'. 
  1574. Explicit address-size and operand-size prefixes A16, A32, O16 and O32 are provided (see 'Unusual
  1575. instruction
  1576. sizes' for more information). e
  1577. You can also use a segment register as a prefix to an instruction. For example, coding 'es mov [bx], ax' is equivalent to coding 'mov [es:bx], ax'. The latter syntax is recommended, since it is consistent with other syntactic features of the language, but for instructions such as 'lodsb', there is no other way to add a segment override than as a prefix. ]
  1578. An instructions can also be a NASM pseudo-opcode - see pseudo-opcodes for more information. ,
  1579. Writing
  1580. programs
  1581. screen
  1582.  Operands
  1583. The operands field can be nonexistent, or huge, depending on the instruction. When operands are registers, they are given simply as register names, e.g. 'eax', 'ss', 'di' for example. E
  1584. Operands may also be effective
  1585. addresses, constants or expressions. ,
  1586. Writing
  1587. programs
  1588. screen
  1589.  Comments
  1590. A comment is anything that comes after the first semicolon on a line, excluding semicolons inside quoted strings. ,
  1591. Writing
  1592. programs
  1593. screen
  1594.  Floating point instructions
  1595. NASM has built-in support for assembling FPU opcodes. However, its syntax is not necessarily the same as that used by other assemblers. 
  1596. NASM uses the notation 'st0', 'st1', etc. to denote the FPU stack registers. NASM also accepts a wide range of single-operand and two-operand forms of the instructions. 
  1597. If you wish to use the single-operand form exclusively, you can use the TO keyword which makes available the opcodes which cannot be easily accessed by one operand. For example: 
  1598.  fadd st1       ; this sets st0:= st0 + st1
  1599.  fadd st0,st1   ; so does this
  1600.  fadd st1,st0   ; this sets st1:= st1 + st0
  1601.  fadd to st1    ; so does this
  1602. FPU instructions that reference memory must use the prefixes DWORD, QWORD or TWORD to indicate what size of memory operand they refer to. 
  1603. NASM will never automatically insert WAIT instructions into your code stream. You must code WAIT yourself before any instruction that needs it, although on 286 processors or above, WAIT instructions are not needed. c
  1604. NASM supports specification of floating point constants by means of 'dd' (single precision), 'dq' (double precision) and 'dt' (extended precision). Floating-point arithmetic is not done, due to portability constraints (not all platforms on which NASM can be run support the same floating point types), but simple constants can be specified. For example: ,
  1605.  gamma dq 0.5772156649  ; Euler's constant
  1606. Programming
  1607. screen
  1608.  Pseudo-opcodes
  1609. Pseudo-opcodes are not real 80x86 machine opcodes, but are still entered in instruction field as it is the most convenient place to put them. !
  1610. The current pseudo-opcodes are: W
  1611.  RESB,
  1612. RESW,
  1613. RESD,
  1614.  INCBIN
  1615.  TIMES
  1616. Programming
  1617. screen
  1618.  Pseudo-opcodes - DB, DW, DD, DQ and DT
  1619. DB, DW, DD, DQ and DT work as you would expect: they can each take an arbitrary number of operands, and when assembled, they generate nothing but those operands. x
  1620. All three of them can take string constants as operands. See the Constants section for details about string constants. "
  1621. Pseudo-opcodes
  1622. screen
  1623.  Pseudo-opcodes - RESB, RESW, RESD, RESQ and REST
  1624. RESB, RESW, RESD, RESQ and REST are designed to be used in the BSS section of a module: they declare uninitialised storage space. ]
  1625. Each takes a single operand, which is the number of bytes, words or doublewords to reserve. 
  1626. NASM does not support the MASM/TASM syntax of reserving uninitialised space by writing 'DW ?' or similar, you must use the RES pseudo-opcodes. "
  1627. Pseudo-opcodes
  1628. screen
  1629.  Pseudo-opcodes - INCBIN
  1630. INCBIN is used to include a binary file verbatim into the output file. This can be handy for (for example) including graphics and sound data directly into a game executable file. .
  1631. It can be called in one of these three ways: 
  1632.     INCBIN "file.dat"               ; include the whole file
  1633.     INCBIN "file.dat", 1024         ; skip the first 1024 bytes
  1634.     INCBIN "file.dat", 1024, 512    ; skip the first 1024, and
  1635.                                     ; actually include at most 512
  1636. Pseudo-opcodes
  1637. screen
  1638.  Pseudo-opcodes - EQU
  1639. EQU defines a symbol to a specified value. When EQU is used, the LABEL field must be present. The action of EQU is to define the given label name to the value of its (only) operand. This definition is absolute, and cannot change later. 
  1640. For example: 3
  1641.  message db 'hello, world'
  1642.  msglen  equ $-message
  1643. This defines 'msglen' to be the constant 12. 'msglen' may not then be redefined later. 
  1644. The value of 'msglen' is evaluated once, using the value of '$' (see the section 'Expressions' for details of '$') at the point of definition, rather than being evaluated wherever it is referenced and using the value of '$' at the point of reference. "
  1645. Pseudo-opcodes
  1646. screen
  1647.  Pseudo-opcodes - TIMES
  1648. The TIMES prefix causes the instruction to be assembled multiple times. This is partly NASM's equivalent of the DUP syntax supported by MASM-compatible assemblers, in that it is possible to do the following: 
  1649.  zerobuf: times 64 db 0
  1650. TIMES does not only take a numeric constant, but a numeric expression, so it is also possible to do the following: 6
  1651.  buffer: db 'hello, world'
  1652.  times 64-$+buffer db ' '
  1653. Which will store exactly enough spaces to make the total length of 'buffer' up to 64. ^
  1654. TIMES can also be applied to ordinary opcodes, so you can code trivial unrolled loops in it: 
  1655.  times 100 movsb
  1656. Note that there is no effective difference between 'times 100 resb 1' and 'resb 100', except that the latter will be assembled about 100 times faster due to the internal structure of the assembler. 
  1657. Note also that TIMES can't be applied to macros. The reason for this is that TIMES is processed after the macro phase, which allows the argument to TIMES to contain expressions such as '64-$+buffer' as shown above. "
  1658. Pseudo-opcodes
  1659. screen
  1660.  Effective addresses
  1661. The addressing scheme used by NASM is very simple, although it can involve more typing than other assemblers. 
  1662. To refer to the contents of a memory location, square brackets are required. This applies to simple variables, computed offsets, segment overrides, effective addresses - everything. 
  1663. For example: R
  1664.  wordvar dw 123
  1665.  mov ax, [wordvar]
  1666.  mov ax, [wordvar+1]
  1667.  mov ax, [es:wordvar+bx]
  1668. NASM does not support the various strange syntaxes used by MASM and others, such as: 
  1669.  mov ax, wordvar        ; this is legal, but means something else
  1670.  mov ax, es:wordvar[bx] ; not even slightly legal
  1671.  es mov ax, wordvar[1]  ; the prefix is OK, but not the rest
  1672. If no square brackets are used, NASM interprets label references to mean the address of the label. Hence there is no need for MASM's OFFSET keyword. 
  1673. For example: 
  1674.  mov ax, wordvar
  1675. Loads AX with the address of the variable 'wordvar'. f
  1676. More complicated effective addresses are handled by enclosing them within square brackets as before: 1
  1677.  mov eax, [ebp+2*edi+offset]
  1678.  mov ax, [bx+di+8]
  1679. Provided your effective address expression evaluates algebraically to something that the instruction set supports, NASM will be able to assemble it. 
  1680. For example: u
  1681.  mov eax, [ebx*5]       ; actually assembles to [ebx+ebx*4]
  1682.  mov ax, [bx-si+2*si]   ; actually assembles to [bx+si]
  1683. There is an ambiguity in the instruction set, which allows two forms of 32-bit effective address with equivalent meaning: )
  1684.  mov eax, [2*eax+0]
  1685.  mov eax, [eax+eax]
  1686. These two expressions clearly refer to the same address. The difference is that the first one, if assembled 'as is', requires a four-byte offset to be stored as part of the instruction, so it takes up more space. n
  1687. NASM will generate the second (smaller) form for both of the above instructions, in an effort to save space. [
  1688. There is currently no way of forcing NASM to generate the larger form of the instruction. 
  1689. An alternative syntax is supported, in which prefixing an operand with '&' is synonymous with enclosing it in square brackets. The square bracket syntax is the recommended one. 
  1690. For example: 
  1691.  mov eax, &ebx+ecx
  1692. is equivalent to 
  1693.  mov eax, [ebx+ecx]
  1694. Programming
  1695. screen
  1696.  Unusual instruction sizes
  1697. A number of assemblers seem to have trouble assembling instructions that use a different operand or address size from the one they are expecting. While simple code such as 'mov eax, 2' can be easily dealt with, some instructions are more complicated. 
  1698.  Jumps
  1699.  Loops
  1700.  Strings
  1701. Programming
  1702. screen
  1703.  Unusual instruction sizes - Jumps
  1704. Suppose you are in a 16-bit segment, in protected mode, and you want to execute a far jump to a point in a 32-bit segment. You need to code a 32-bit far jump in a 16-bit segment, something that not all assemblers will easily support. NASM can, by means of the 'word' and 'dword' specifiers. 
  1705. So you can code: 
  1706.  jmp 1234h:5678h            ; this uses the default segment size
  1707.  jmp word 1234h:5678h       ; this is guaranteed to be 16-bit
  1708.  jmp dword 1234h:56789ABCh  ; and this is guaranteed 32-bit
  1709. Similarly, if you are coding in a 16-bit code segment, but trying to access memory in a 32-bit data segment, your effective addresses will want to be 32-bit. 
  1710. As soon as you specify an effective address containing a 32-bit register, like '[eax]', the addressing is forced to be 32-bit anyway. But if you try to specify a simple offset, such as '[label]' or '[0x10000]', you will get the default address size, which in this case will be wrong. 
  1711. However, NASM allows you to code '[dword 0x10000]' to force a 32-bit address size, or conversely '[word wlabel]' to force 16 bits. W
  1712. Be careful not to confuse 'word' and 'dword' inside the square brackets with outside. 
  1713. For example: $
  1714.  mov word [dword 0x123456], 0x7890
  1715. Which moves 16 bits of data to an address specified by a 32-bit offset. There is no contradiction between the 'word' and 'dword' in this instruction, since they modify different aspects of the functionality. 2
  1716. An even more confusing situation is shown below: "
  1717.  call dword far [fs:word 0x4321]
  1718. Which takes an address specified by a 16-bit offset, and extracts a 48-bit dword far pointer from it to call. {
  1719. Using this effective-address syntax, the 'dword' or 'word' override may come before or after the segment override if any. 
  1720. For example: ;
  1721.  mov ax, [fs:dword 0x123456]
  1722.  mov ax, [dword fs:0x123456]
  1723. Are equivalent forms, and generate the same code. -
  1724. Unusual
  1725. instruction
  1726. sizes
  1727. screen
  1728.  Unusual instruction sizes - Loops
  1729. In a 16-bit segment, the LOOP instruction uses CX as its count register by default, and in a 32-bit segment it uses ECX. But it is possible to do either one in the other segment, and NASM allows this by letting you specify the count register as a second operand, for example: }
  1730.  loop label       ; uses CX or ECX depending on mode
  1731.  loop label, cx   ; always uses CX
  1732.  loop label, ecx  ; always uses ECX
  1733. Unusual
  1734. instruction
  1735. sizes
  1736. screen
  1737.  Unusual instruction sizes - Strings
  1738. The string instructions LODSB, STOSB, MOVSB, CMPSB, SCASB, INSB, and OUTSB can all have strange address sizes. Typically, in a 16-bit segment they read from [DS:SI] and write to [ES:DI], and in a 32-bit segment they read from [DS:ESI] and write to [ES:EDI]. 
  1739. However, this can be changed by the use of the explicit address-size prefixes 'a16' and 'a32'. These prefixes generate null code if used in the same size segment as they specify, but generate an 0x67 prefix otherwise. 
  1740. Hence 'a16' generates no code in a 16-bit segment, but 0x67 in a 32-bit one, and vice versa. So 'a16 lodsb' will always generate code to read a byte from [DS:SI], no matter what the size of the segment. 
  1741. There are also explicit operand-size override prefixes, 'o16' and 'o32', which will optionally generate 0x66 bytes, but these are provided for completeness and should never have to be used. _
  1742. (Note that NASM does not support the LODS, STOS, MOVS etc. forms of the string instructions.) -
  1743. Unusual
  1744. instruction
  1745. sizes
  1746. screen
  1747.  Constants
  1748. NASM can accept three kinds of constant: #
  1749.  Numeric
  1750.  Character
  1751.  String
  1752. Programming
  1753. screen
  1754.  Constants - Numeric
  1755. Numeric constants are simply numbers. NASM supports a variety of syntaxes for expressing numbers in strange bases. For example you can do any of the following: v
  1756.  100   ; this is decimal
  1757.  0x100 ; hexadecimal
  1758.  100h  ; hex as well
  1759.  $100  ; hex again
  1760.  100q  ; octal
  1761.  100b  ; binary
  1762. Leading zeros make no difference to NASM, with the exception of hexadecimal constants that begin with a letter and use the trailing 'h' syntax, in which case a leading zero is required so that it will not be mistaken for a label. [
  1763. The 'x' in '0x100', and the trailing 'h', 'q' and 'b', may all be upper case if you want. 
  1764. Constants
  1765. screen
  1766.  Constants - Character
  1767. Character constants consist of up to four characters enclosed in single or double quotes. No escape character is defined for including the quote character itself: if you want to declare a character constant containing a double quote, enclose it in single quotes, and vice versa. _
  1768. Character constants' values are worked out in terms of a little-endian computer, for example: 
  1769.  mov eax, 'abcd'
  1770. Then if you were to examine the binary output from NASM, it would contain the visible string 'abcd', which of course means that the actual value loaded into EAX would be 0x64636261 ('dcba'), not 0x61626364 ('abcd'). 
  1771. Constants
  1772. screen
  1773.  Constants - String
  1774. String constants are like character constants. If a character constant appearing as operand to a DB, DW or DD is longer than the word size involved (1, 2 or 4 respectively), it will be treated as a string constant instead, which is to say the concatenation of separate character constants. 
  1775. For example: 
  1776.  db 'hello, world'
  1777. Declares a twelve-character string constant. Similarly: '
  1778.  dd 'dontpanic'   ; a string constant
  1779. Is equivalent to writing: 7
  1780.  dd 'dont', 'pani', 'c'   ; three character constants
  1781. So that what actually gets assembled is equivalent to: 
  1782.  db 'dontpanic', 0, 0, 0
  1783. Constants
  1784. screen
  1785.  Expressions
  1786. Expressions in NASM can be formed of the following operators: 1
  1787.   Operator    
  1788.  Description
  1789.       |       
  1790.  Bitwise OR
  1791.       ^       
  1792.  Bitwise XOR
  1793.       &       
  1794.  Bitwise AND
  1795.       ~       
  1796.  Bitwise NOT
  1797.       <<      
  1798.  Logical bitwise left shift
  1799.       >>      
  1800.  Logical bitwise right shift
  1801.       +       
  1802.  Addition
  1803.       -       
  1804.  Subtraction
  1805.       *       
  1806.  Multiplication
  1807.       /       
  1808.  Division (unsigned)
  1809.       %       
  1810.  Modulo (unsigned)
  1811.       //      
  1812.  Division (signed)
  1813.       %%      
  1814.  Modulo (signed)
  1815.       SEG     
  1816.  Segment base value
  1817.       WRT     
  1818.  With Reference To
  1819. The order of precedence is given below: 
  1820.  Operators          
  1821.  Precedence
  1822.      |              
  1823.  Lowest
  1824.      ^              
  1825.      &              
  1826.    << >>            
  1827.  (binary) + -       
  1828.  * / % // %%        
  1829.  (unary) + - ~ SEG  
  1830.  Highest
  1831. Operators within a precedence level associate to the left (i.e. '2-3-4' evaluates the same way as '(2-3)-4'). 
  1832. Note that since the '%' character is used by the preprocessor, it's worth making sure that the '%' and `%%' operators are followed by a space, to prevent the preprocessor trying to interpret them as macro-related code. 
  1833. A form of algebra is done by NASM when evaluating expressions. Algebra can be done also be used with labels, for example 'label2*2-label1' is an acceptable way to define an address as far beyond 'label2' as 'label1' is before it. 
  1834. In less algebraically capable assemblers, one might have to write that as 'label2 + (label2-label1)', where the value of every sub-expression is either a valid address or a constant. NASM can of course cope with that version as well. 
  1835. Expressions may also contain the special token '$', known as a 'Here' token, which always evaluates to the address of the current assembly point. That is, the address of the assembly point before the current instruction gets assembled. 
  1836. The special token `$$' evaluates to the address of the beginning of the current section. This can be used for alignment, as shown below: :
  1837.  times ($$-$) & 3 nop ; pad with NOPs to 4-byte boundary
  1838. Note that this technique aligns to a four-byte boundary with respect to the beginning of the segment - if you can't guarantee that the segment itself begins on a four-byte boundary, this alignment is useless or worse. Be sure you know what kind of alignment you can guarantee to get out of your linker before you start trying to use TIMES to align to page boundaries. (
  1839. Programming
  1840. screen
  1841.  Expressions - SEG and WRT
  1842. NASM contains the capability for its object file formats to permit programs to directly refer to the segment-base values of their segments. x
  1843. This is achieved either by the object format defining the segment names as symbols, or by the use of the SEG operator. 
  1844. SEG is a unary prefix operator which, when applied to a symbol defined in a segment, will yield the segment base value of that segment. 
  1845. In 16 bit DOS Object file and OS/2 object file format, symbols defined in segments which are grouped are considered to be primarily a member of the group, not the segment, and the return value of SEG reflects this. 
  1846. SEG may be used for far pointers and it is guaranteed that for any symbol 'sym', using the offset 'sym' from the segment base 'SEG sym' yields a correct pointer to the symbol. Hence you can code a far call by means of: 
  1847.  CALL SEG routine:routine
  1848. Or store a far pointer in a data segment by: 
  1849.  DW routine, SEG routine
  1850. For convenience, NASM supports the forms: $
  1851.  CALL FAR routine
  1852.  JMP FAR routine
  1853. As direct synonyms for the canonical syntax: 4
  1854.  CALL SEG routine:routine
  1855.  JMP SEG routine:routine
  1856. No alternative syntax is supported for: 
  1857.  DW routine, SEG routine
  1858. Simply referring to 'sym', for some symbol, will return the offset of 'sym' from its preferred segment base (as returned from 'SEG sym'). Sometimes, you may want to obtain the offset of 'sym' from some other segment base. ~
  1859. For example the offset of 'sym' from the base of the segment it's in, where normally you'd get the offset from a group base. 
  1860. This is accomplished using the WRT (With Reference To) keyword. If 'sym' is defined in segment 'seg' but you want its offset relative to the beginning of segment 'seg2', you can do the following: 
  1861.  mov ax, sym WRT seg2
  1862. The right-hand operand to WRT must be a segment-base value. You can also do 'sym WRT SEG sym2' if you need to.  
  1863. expressions
  1864. screen
  1865.  Critical expressions
  1866. NASM is a two-pass assembler - it goes over the input once to determine the location of all the symbols, then once more to actually generate the output code. Most expressions are non-critical, in that if they contain a forward reference and hence their correct value is unknown during the first pass, it doesn't matter. 
  1867. However, arguments to RESB, RESW and RESD, and the argument to the TIMES prefix, can actually affect the size of the generated code, and so it is critical that the expression can be evaluated correctly on the first pass. 
  1868. In these situations, expressions may not contain forward references. This prevents NASM from having to sort out a mess such as: 0
  1869.  times (label-$) db 0
  1870.  label: db 'where am I?'
  1871. In which the TIMES argument could equally legally evaluate to anything, or perhaps even worse: 6
  1872.  times (label-$+1) db 0
  1873.  label: db 'NOW where am I?'
  1874. In which any value for the TIMES argument is by definition invalid. 
  1875. Since NASM is a two-pass assembler, this criticality condition also applies to the argument to EQU. Suppose, if this were not the case, we were to have the setup: 
  1876.  mov ax, a
  1877.  a equ b
  1878. On pass one, 'a' cannot be defined properly, since 'b' is not known yet. On pass two, 'b' is known, so line two can define 'a' properly. p
  1879. Unfortunately, line 1 needed 'a' to be defined properly, so this code will not assemble using only two passes. 
  1880. In an effective address such as '[eax+offset]', the value of 'offset' can be stored as either 1 or 4 bytes. NASM will use the one-byte form if it knows it can, to save space, but will therefore be fooled by the following: &
  1881.  mov eax,[ebx+offset]
  1882.  offset equ 10
  1883. In this case, although 'offset' is a small value and could easily fit into the one-byte form of the instruction, when NASM sees the instruction in the first pass it doesn't know what 'offset' is, and for all it knows 'offset' could be a symbol requiring relocation. So it will allocate the full four bytes for the value of 'offset'. This can be solved by defining 'offset' before it's used. (
  1884. Programming
  1885. screen
  1886.  Local labels
  1887. A local label is one that begins with a period, for example: *
  1888.  hello:     ; hello is not a local label
  1889.  .hello2:   ; hello2 is a local label
  1890. The 'localness' comes from the fact that local labels are associated with the previous non-local label, so that you may declare the same local label twice if a non-local one intervenes. Hence: 
  1891.  label1     ; some code
  1892.  .loop      ; some more code
  1893.  jne .loop
  1894.  label2     ; some code
  1895.  .loop      ; some more code
  1896.  jne .loop
  1897. In the above code, each 'jne' instruction jumps to the line of code before it, since the '.loop' labels are distinct from each other. 
  1898. NASM also provides addition functionality in that local labels are actually defined in terms of their associated non-local label. This makes it possible to write: Y
  1899.  label3            ; some more code
  1900.                    ; and some more
  1901.  jmp label1.loop
  1902. So although local labels are usually local, it is possible to reference them from anywhere in your program, if you really have to. (
  1903. Programming
  1904. screen
  1905.  Assembler directives
  1906. Assembler directives appear on a line by themselves (apart from a comment). They come in two forms: user-level directives and primitive directives. 
  1907. Primitive directives are enclosed in square brackets (no white space may appear before the opening square bracket, although white space and a comment may come after the closing bracket) and were used mainly by previous versions of NASM. 
  1908. User-level directives look the same, only without the square brackets, and are the more modern form. They are implemented as macros expanding to primitive directives. 
  1909. Some directives are universal in that they may be used in any situation, and do not change their syntax. Other directives are only available to certain output formats. 3
  1910. The following assembler directives are available: 
  1911.  ABSOLUTE
  1912.  BITS
  1913.  COMMON
  1914.  ENDSTRUC
  1915.  EXTERN
  1916.  GLOBAL
  1917.  IEND
  1918.  ISTRUC
  1919.  SECTION
  1920.  SEGMENT
  1921.  STRUC
  1922.  UPPERCASE
  1923. Programming
  1924. screen
  1925.  Assembler directives - BITS
  1926. 'BITS 16' or 'BITS 32' switches NASM into 16-bit or 32-bit mode. B
  1927. This is equivalent to USE16 and USE32 segments, in TASM or MASM. 
  1928. In 32-bit mode, instructions are prefixed with 0x66 or 0x67 prefixes when they use 16-bit data or addresses, in 16-bit mode, the reverse happens. .
  1929. NASM's default depends on the object format. (
  1930. Assembler
  1931. directives
  1932. screen
  1933.  Assembler directives - SECTION and SEGMENT
  1934. 'SECTION name' or 'SEGMENT name' changes which section the code you write will be assembled into. j
  1935. Acceptable section names vary between output formats. Currently all formats support the names '.text', '.data' and '.bss'. Note that '.bss' is an uninitialised data section, and so you will receive a warning from NASM if you try to assemble any code or data in it. The only thing you can do in '.bss' without triggering a warning is to use RESB, RESW and RESD. ;
  1936. In object files segments can be declared with attributes: >
  1937.  SEGMENT CODE PRIVATE ALIGN=16 CLASS=CODE OVERLAY=OVL2 USE16
  1938. You can specify segments to be PRIVATE, PUBLIC, COMMON or STACK; their alignment may be any power of two from 1 to 256 (although only 1, 2, 4, 16 and 256 are really supported, so anything else gets rounded up to the next highest one of those); their class and overlay names may be specified. u
  1939. You may also specify segments to be USE16 or USE32. The defaults are PUBLIC ALIGN=1, no class, no alignment, USE16. O
  1940. You can also specify that a segment is absolute at a certain segment address: !
  1941.  SEGMENT SCREEN ABSOLUTE=0xB800
  1942. The ABSOLUTE and ALIGN keywords are mutually exclusive. 
  1943. The format-specific directive GROUP allows segment grouping: 'GROUP DGROUP DATA BSS' defines the group DGROUP to contain segments DATA and BSS. K
  1944. Segments are defined as part of their group by default: if variable 'var' is declared in segment 'data', which is part of group 'dgroup', then the expression 'SEG var' is equivalent to the expression 'dgroup', and the expression 'var' evaluates to the offset of the variable 'var' relative to the beginning of the group 'dgroup'. ~
  1945. You must use the expression 'var WRT data' to get the offset of the variable 'var' relative to the beginning of its segment. 
  1946. NASM allows a segment to be part of more than one group but will generate a warning. References to the symbols in that segment will be resolved relative to the first group it is defined in. )
  1947. Assembler
  1948. directives
  1949. screen
  1950.  Assembler directives - ABSOLUTE
  1951. 'ABSOLUTE address' can be considered a different form of 'SECTION', in that it must be overridden using a SECTION directive once you have finished using it. 
  1952. It is used to assemble notional code at an absolute offset address; of course, you can't actually assemble code there, since no object file format is capable of putting the code in place, but you can use RESB, RESW and RESD, and you can define labels. K
  1953. Hence you could, for example, define a C-like data structure by means of: 
  1954.  absolute 0
  1955.           stLong  resd 1
  1956.           stWord  resw 1
  1957.           stByte1 resb 1
  1958.           stByte2 resb 1
  1959.           st_size:
  1960.                   segment .text
  1961. and then carry on coding. This defines 'stLong' to be zero, 'stWord' to be 4, 'stByte1' to be 6, 'stByte2' to be 7 and 'st_size' to be 8. d
  1962. So this has defined a data structure, however the STRUC directive provides a nicer way to do this. (
  1963. Assembler
  1964. directives
  1965. screen
  1966.  Assembler directives - EXTERN
  1967. 'EXTERN symbol' defines a symbol as being external, in the C sense. 'EXTERN' states that the symbol is not declared in this module, but is declared elsewhere, and that you wish to reference it in this module. (
  1968. Assembler
  1969. directives
  1970. screen
  1971.  Assembler directives - GLOBAL
  1972. 'GLOBAL symbol' defines a symbol as being global, in the sense that it is exported from this module and other modules may reference it. 
  1973. All symbols are local, unless declared as global. Note that the 'GLOBAL' directive must appear before the definition of the symbol it refers to. (
  1974. Assembler
  1975. directives
  1976. screen
  1977.  Assembler directives - COMMON
  1978. 'COMMON symbol size' defines a symbol as being common: it is declared to have the given size, and it is merged at link time with any declarations of the same symbol in other modules. (
  1979. Assembler
  1980. directives
  1981. screen
  1982.  Assembler directives - STRUC and ENDSTRUC
  1983. 'STRUC structure' begins the definition of a data structure, and 'ENDSTRUC' ends it. A structure may be defined using STRUC as follows: r
  1984.            struc st
  1985.    stLong  resd 1
  1986.    stWord  resw 1
  1987.    stByte  resb 1
  1988.    stStr   resb 32
  1989.            endstruc
  1990. Notice that this code still defines the symbol 'st_size' to be the size of the structure. The 'size' suffix is automatically appended to the structure name. Notice also that the assembler takes care of remembering which section you were assembling in (whereas in the version using ABSOLUTE it was up to the programmer to sort that out). (
  1991. Assembler
  1992. directives
  1993. screen
  1994.  Assembler directives - ISTRUC and IEND
  1995. 'ISTRUC structure' begins the declaration of an initialised instance of a data structure. You can then use the 'AT' macro to assign values to the structure members, and 'IEND' to finish. 
  1996. For example: 
  1997.        istruc st
  1998.     at stLong, dd 0x1234
  1999.     at stWord, dw 23
  2000.     at stByte, db 'q'
  2001.     at stStr, db 'hello, world', 13, 10, 0
  2002.        iend
  2003. Note that there's nothing stopping the instruction after 'at' from overflowing on to the next line if you want. So the above example could just as well have contained: <
  2004.     at stStr, db 'hello, world'
  2005.               db 13, 10, 0
  2006. Or even (if you prefer this style): 2
  2007.    at stStr
  2008.    db 'hello, world'
  2009.    db 13, 10, 0
  2010. Note also that the 'ISTRUC' mechanism is implemented as a set of macros, and uses TIMES internally to achieve its effect; so the structure fields must be initialised in the same order as they were defined in. )
  2011. Assembler
  2012. directives
  2013. screen
  2014.  Assembler directives - ORG
  2015. The binary output format supports a format-specific directive, which is ORG. v
  2016. 'ORG addr' declares that your code should be assembled as if it were to be loaded into memory at the address 'addr'. X
  2017. So a DOS .COM file should state 'ORG 0x100', and a DOS .SYS file should state 'ORG 0'. 
  2018. There should be one ORG directive, at most, in an assembly file: NASM does not support the use of ORG to jump around inside an object file, like MASM does. )
  2019. Assembler
  2020. directives
  2021. screen
  2022.  Assembler directives - UPPERCASE
  2023. The directive 'UPPERCASE' causes all symbol, segment and group names output to the object file to be uppercased. The actual assembly is still case sensitive. )
  2024. Assembler
  2025. directives
  2026. screen
  2027.  The preprocessor
  2028. NASM contains a full-featured macro preprocessor, which supports conditional assembly, multi-level file inclusion, two forms of macro (single-line and multi-line), and a 'context stack' mechanism for extra macro power. Preprocessor directives all begin with a '%' sign. '
  2029. The following sections are available: 
  2030.  Single-line
  2031. macros
  2032.  Multiple-line
  2033. macros
  2034.  Standard
  2035. macros
  2036.  Conditional
  2037. assembly
  2038.  File
  2039. inclusion
  2040. context
  2041. stack
  2042. Programming
  2043. screen
  2044.  The preprocessor - single-line macros
  2045. Single-line macros are defined in a similar way to C, using the '%define' command. Hence you can do: c
  2046.  %define ctrl 0x1F &
  2047.  %define param(a,b) ((a)+(a)*(b))
  2048.          mov byte [param(2,ebx)], ctrl 'D'
  2049. Which will expand to: '
  2050.  mov byte [(2)+(2)*(ebx)], 0x1F & 'D'
  2051. When the expansion of a single-line macro contains tokens which invoke another macro, the expansion is performed at invocation time, not at definition time. Thus the code: 5
  2052.  %define a(x) 1+b(x)
  2053.  %define b(x) 2*x
  2054.  mov ax,a(8)
  2055. Will evaluate in the expected way to 'mov ax,1+2*8', even though the macro 'b' wasn't defined at the time of definition of 'a'. 
  2056. Macros defined with '%define' are case sensitive: after '%define foo bar', only 'foo' will expand to bar: 'Foo' or 'FOO' will not. 
  2057. By using '%idefine' instead of '%define' (the `i' stands for 'insensitive') you can define all the case variants of a macro at once, so that '%idefine foo bar' would cause 'foo', 'Foo' and 'FOO' all to expand to 'bar'.     
  2058. There is a mechanism which detects when a macro call has occurred as a result of a previous expansion of the same macro, to guard against circular references and infinite loops. If this happens, the preprocessor will only expand the first occurrence of the macro. 
  2059. Hence: T
  2060.  %define a(x) 1+a(x)
  2061.  mov ax,a(3)          ; becomes 1+a(3) and expands no further
  2062. This can be useful for doing things like this: {
  2063.  %macro extrn 1    ; see 'Multiple-line
  2064. macros'
  2065.  extern _%1        ; for information on %macro
  2066.  %define %1 _%1
  2067.  %endmacro
  2068. Which would avoid having to put leading underscores on external variables, because you could just code: 
  2069.  extrn foo
  2070.  mov ax,foo
  2071. And it would expand as: V
  2072.  extern foo
  2073.  %define foo _foo
  2074.  mov ax,foo         ; becomes mov ax, _foo as required
  2075. Single-line macros with parameters can be overloaded: it is possible to define two or more single-line macros with the same name, each taking a different number of parameters, and the macro processor will be able to distinguish between them. 
  2076. However, a parameterless single-line macro excludes the possibility of any macro of the same name with parameters, and vice versa (though single-line macros may be redefined, keeping the same number of parameters, without error). %
  2077. preprocessor
  2078. screen
  2079.  The preprocessor - multiple-line macros
  2080. These are defined using '%macro' and '%endmacro', so that simple things like this can be done: D
  2081.  %macro prologue 0
  2082.         push ebp
  2083.         mov ebp,esp
  2084.  %endmacro
  2085. This defines 'prologue' to be a multi-line macro, taking no parameters, which expands to the two lines of code given. 
  2086. Similarly to single-line macros, multi-line macros are case-sensitive, unless you define them using '%imacro' instead of '%macro'. 
  2087. The '0' on the '%macro' line indicates that the macro 'prologue' expects no parameters. Macros can be overloaded: if two macros are defined with the same name but different numbers of parameters, they will be treated as separate. Multi-line macros may not be redefined. :
  2088. The assembler will usually generate a warning if you code a line which looks like a macro call but involves a number of parameters which the macro in question isn't ready to support. (For example, if you code a macro '%macro foo 1' and also '%macro foo 3', then you write 'foo a,b', a warning will be generated.) 
  2089. This feature can be disabled (see 'Assemble
  2090. options'), since sometimes it's intentional (for example, you might define '%macro push 2' to allow you to push two registers at once; but 'push ax' shouldn't then generate a warning). o
  2091. Macros taking parameters can be written using '%1', '%2' and so on to reference the parameters. So this code: G
  2092.  %macro movs 2
  2093.         push %2
  2094.         pop %1
  2095.  %endmacro
  2096.  movs ds, cs
  2097. Will define a macro 'movs' to perform an effective MOV operation from segment to segment register. The macro call given would of course expand to 'push cs' followed by 'pop ds'. 
  2098. You can define a label inside a macro in such a way as to make it unique to that macro call (so that repeated calls to the same macro won't produce multiple labels with the same name), by prefixing it with '%%'. So, for example: A
  2099.  %macro retz
  2100.         jnz %%skip
  2101.         ret
  2102.  %%skip:
  2103.  %endmacro
  2104. This defines a different label in place of '%%skip' every time it's called. (Of course the above code could have easily been coded using 'jnz $+3', but not in more complex cases...). 
  2105. The actual label defined would be '..@2345.skip', where 2345 is replaced by some number that changes with each macro call. Users are warned to avoid defining labels of this shape themselves. 
  2106. Sometimes you want a macro to be able to accept arbitrarily many parameters and lump them into one. This can be done using the '+' modifier on the '%macro' line: 
  2107.  %macro fputs 2+
  2108.         [section .data] ; this is done as a primitive to avoid
  2109.                         ; disturbing the __SECT__ define
  2110.         %%str db %2
  2111.         %%end:
  2112.         __SECT__        ; this expands to a whole [section xxx] primitive
  2113.         mov dx, %%str
  2114.         mov cx, %%end-%%str
  2115.         mov bx, %1
  2116.         call writefile
  2117.  %endmacro
  2118.  fputs [filehandle], "hi there", 13, 10
  2119. This declares 'fputs' to be a macro that accepts at least two parameters, and all parameters after the first one are lumped together as part of the last specified one (in this case %2). So in the macro call, '%1' expands to '[filehandle]' while '%2' expands to the whole remainder of the line: '"hi there", 13, 10'. s
  2120. Note also the switching of sections in the middle of this macro expansion, to ensure separation of data and code. 
  2121. There is an alternative mechanism for putting commas in macro parameters: instead of specifying the large-parameter-ness at macro definition time, you can specify it at macro call time, by the use of braces to surround a parameter which you want to contain commas. 
  2122. So, for example: 
  2123.  %macro table_entry 2
  2124.         %%start:
  2125.         db %1
  2126.         times 32-($-%%start) db 0
  2127.         db %2
  2128.         times 64-($-%%start) db 0
  2129.  %endmacro
  2130.  table_entry 'foo', 'bar'
  2131.  table_entry 'megafoo', { 27,'[1mBAR!',27,'[m' }
  2132. Will expand to, effectively (actually, there will be labels present, but these have been omitted for clarity), the following: 
  2133.  db 'foo'
  2134.  times 32-3 db 0
  2135.  db 'bar'
  2136.  times 64-35 db 0
  2137.  db 'megafoo'
  2138.  times 32-7 db 0
  2139.  db 27,'[1mBAR!',27,'[m'
  2140.  times 64-46 db 0
  2141. Macro parameter expansions can be concatenated on to other tokens, so that you can do this: O
  2142.  %macro keytab_entry 2
  2143.         keypos%1 equ $-keytab
  2144.         db %2
  2145.  %endmacro
  2146.  keytab:
  2147.  keytab_entry F1,128+1
  2148.  keytab_entry F2,128+2
  2149.  keytab_entry Return,13
  2150. Which will define labels called 'keyposF1', 'keyposF2' and 'keyposReturn'. You can similarly do concatenations on the other end, such as '%1foo'. If you need to concatenate a digit on to the end of a macro parameter expansion, you can do this by enclosing the parameter number in braces: '%{1}' is always a valid synonym for `%1', and has the advantage that it can be legitimately prepended to a digit, as in '%{1}2', and cause no confusion with '%{12}'. 
  2151. Macro-specific labels and defines can be concatenated similarly: '%{%foo}bar' will succeed where '%%foobar' would cause confusion. 
  2152. (As it happens, '%%foobar' would work anyway, due to the format of macro-specific labels, but for clarity, '%{%foo}bar' is recommended if you really want to do anything this perverse...) 
  2153. The parameter handling has a special case: it can treat a macro parameter specially if it's thought to contain a condition code. The reference '%+1' is identical to '%1' except that it will perform an initial sanity check to see if the parameter in question is a condition code; more usefully, the reference '%-1' will produce the opposite condition code to the one specified in the parameter. G
  2154. This allows for things such as a conditional-MOV macro to be defined: Q
  2155.  %macro movc 3
  2156.         j%-1 %%skip
  2157.         mov %2,%3
  2158.         %%skip:
  2159.  %endmacro
  2160.  movc ae, ax, bx
  2161. Which will expand to something like: .
  2162.  jnae ..@1234.skip
  2163.  mov ax,bx
  2164.  ..@1234.skip:
  2165. Note that '%+1' will allow CXZ or ECXZ to be passed as condition codes, but '%-1' will of course be unable to invert them. T
  2166. Parameters can also be defaulted: you can define a macro which, for example, said: E
  2167.  %macro strange 1-3 bx,3
  2168.         < some expansion text >
  2169.  %endmacro
  2170. This macro takes between 1 and 3 parameters (inclusive); if parameter 2 is not specified it defaults to BX, and if parameter 3 is not specified it defaults to 3. So the calls: 1
  2171.  strange dx, si, di
  2172.  strange dx, si
  2173.  strange dx
  2174. Would be equivalent to: ;
  2175.  strange dx, si, di
  2176.  strange dx, si, 3
  2177.  strange dx, bx, 3
  2178. Defaults may be omitted, in which case they are taken to be blank. -
  2179. '%endm' is a valid synonym for '%endmacro'. 
  2180. The specification for the number of macro parameters can be suffixed with '.nolist' if you don't want the macro to be explicitly expanded in listing files: :
  2181.  %macro ping 1-2+.nolist
  2182.         ; some stuff
  2183.  %endmacro
  2184. preprocessor
  2185. screen
  2186.  The preprocessor - standard macros
  2187. NASM defines a set of standard macros, before the input file gets processed; these are primarily there in order to provide standard language features (such as structure support). 
  2188. However, it's conceivable that a user might want to write code that doesn't have the standard macros defined; you can achieve this by using the preprocessor directive '%clear' at the top of your program, which will undefine everything that's defined by the preprocessor. 
  2189. In particular, NASM defines the symbols '__NASM_MAJOR__' and '__NASM_MINOR__' to be the major and minor version numbers of NASM. %
  2190. preprocessor
  2191. screen
  2192.  The preprocessor - conditional assembly
  2193. Similarly to the C preprocessor, the commands '%ifdef' and '%endif' may be used to bracket a section of code, which will then only be assembled if at least one of the identifiers following '%ifdef' is defined as a single-line macro. 
  2194. The command '%ifndef' has opposite sense to '%ifdef', and '%else' can be placed between the '%if' and the '%endif' to work as expected. 
  2195. Since there is no analogue to C's '#if', there is no precise 'elif' directive, but '%elifdef' and '%elifndef' work as expected. 
  2196. There is another family of '%if' constructs: '%ifctx', '%ifnctx', '%elifctx' and '%elifnctx', which operate on the context
  2197. stack. %
  2198. preprocessor
  2199. screen
  2200.  The preprocessor - file inclusion
  2201. You can include a file using the '%include' directive. Included files are searched for in the current directory, and then in all directories specified in the Directories dialog box. 
  2202. This, again, works like C: '%include' is used to include a file. Of course it's quite likely you'd want to do the normal sort of thing inside the file: `
  2203.  %ifndef MY_MACROS_FILE
  2204.  %define MY_MACROS_FILE
  2205.          < go and define some macros >
  2206.  %endif
  2207. and then elsewhere: D
  2208.  %include "my-macros-file"
  2209.  < some code making use of the macros >
  2210. So that it doesn't matter if the file accidentally gets included more than once. %
  2211. preprocessor
  2212. screen
  2213.  The preprocessor - the context stack
  2214. This is a feature which adds a whole extra level of power to NASM's macro capability. The context stack is an internal object within the preprocessor, which holds a stack of 'contexts'. }
  2215. Each context has a name - just an identifier-type token - and can also have labels and '%define' macros associated with it. R
  2216. Other macros can manipulate the context stack: this is where the power comes in. 
  2217. To start with: the preprocessor command '%push' will create a new context with the given name, and push it on to the top of the stack. R
  2218. '%pop', taking no arguments, pops the top context off the stack and destroys it. 
  2219. '%repl' renames the top context without destroying any associated labels or macros, so it's distinct from doing '%pop' followed by '%push'. 
  2220. Finally, '%ifctx' and '%ifnctx' invoke conditional assembly based on the name of the top context. The alternative forms '%elifctx' and '%elifnctx' are also available. 
  2221. As well as the '%%foo' syntax to define labels specific to a macro call, there is also the syntax '%$foo' to define a label specific to the context currently on top of the stack. ^
  2222. '%$$foo' can be used to refer to the context below that, or '%$$$foo' below that, and so on. r
  2223. This lot allows the definition of macro combinations that enclose other code, such as the following big example: ?
  2224.  %macro if 1
  2225.         %push if
  2226.         j%-1 %$ifnot
  2227.  %endmacro
  2228.  %macro else 0
  2229.         %ifctx if
  2230.               %repl else
  2231.               jmp %$ifend
  2232.         %$ifnot:
  2233.         %else
  2234.              %error "expected `if' before `else'"
  2235.         %endif
  2236.  %endmacro
  2237.  %macro endif 0
  2238.         %ifctx if
  2239.         %$ifnot:
  2240.         %pop
  2241.         %elifctx else
  2242.         %$ifend:
  2243.         %pop
  2244.         %else
  2245.         %error "expected 'if' or 'else' before 'endif'"
  2246.         %endif
  2247.  %endmacro
  2248. This will cope with a large 'if/endif' construct or an 'if/else/endif', without flinching. So you can code: 
  2249.  cmp ax,bx
  2250.  if ae
  2251.     cmp bx,cx
  2252.     if ae
  2253.         mov ax,cx
  2254.     else
  2255.         mov ax,bx
  2256.     endif
  2257.  else
  2258.     cmp ax,cx
  2259.     if ae
  2260.        mov ax,cx
  2261.     endif
  2262.  endif
  2263. Which will place the smallest out of AX, BX and CX into AX. Note the use of '%repl' to change the current context from 'if' to 'else' without disturbing the associated labels '%$ifend' and '%$ifnot'; also note that the stack mechanism allows handling of nested IF statements without a hitch, and that conditional assembly is used in the 'endif' macro in order to cope with the two possible forms with and without an 'else'. Note also the directive '%error', which allows the user to report errors on improper invocation of a macro and so can catch unmatched 'endif's at preprocess time. %
  2264. preprocessor
  2265. screen
  2266.  Output formats
  2267. The current output formats supported by NASM-IDE are flat-form binary (COM executable file and SYS device driver), 16 bit Object Module Format (DOS 16 bit object file and OS/2 object file), and Common Object File Format (Win32 32 bit object file). For information on how to change the output format see Assembler
  2268. options. E
  2269. This sections provides an overview of the supported output formats. Q
  2270.  Flat-form
  2271. binary
  2272. Object
  2273. Module
  2274. Format
  2275.  Common
  2276. Object
  2277. Format
  2278. Programming
  2279. screen
  2280.  Output formats - flat-form binary
  2281. This is the only output format that generates instantly runnable code, all of the others produce object files that need linking before they become executable. |
  2282. Binary output files contain no red tape at all: they simply contain the binary representation of the exact code you write. G
  2283. The binary format supports a format-specific directive, which is ORG. 
  2284. The binary format defines the section names '.text', '.data' and '.bss'. The layout is that '.text' comes first in the output file, followed by '.data', and notionally followed by '.bss'. 
  2285. So if you declare a BSS section in a flat binary file, references to the BSS section will refer to space past the end of the actual file. 
  2286. The '.data' and '.bss' sections are considered to be aligned on four-byte boundaries: this is achieved by inserting padding zero bytes between the end of the text section and the start of the data, if there is data present. 
  2287. Of course if no SECTION directives are present, everything will go into '.text', and you will get nothing in the output except the code you wrote. 
  2288. Binary output silently ignores GLOBAL directives, and will also not complain at EXTERN ones. You only get an error if you actually reference an external symbol. 1
  2289. Binary output defaults to 16-bit assembly mode. "
  2290. Output
  2291. formats
  2292. screen
  2293.  Output formats - common object file format
  2294. The COFF format generates standard Unix COFF object files, which can be fed to (for example) the DJGPP linker. 
  2295. The Win32 format generates Microsoft Win32 (Windows 95 or Intel-platform Windows NT) object files, which nominally use the COFF standard, but in fact are not compatible. 
  2296. Win32 defines extensions to basic COFF, such as a mechanism for importing symbols from dynamic-link libraries at load time. NASM may eventually support this extension in the form of a format-specific directive. However, as yet, it does not. >
  2297. The COFF output formats do not have any specific directives. 
  2298. The Microsoft linker also has a small blind spot: it cannot correctly relocate a relative CALL or JMP to an absolute address. Hence all PC-relative CALLs or JMPs, when using the Win32 format, must have targets which are relative to sections, or to external symbols. 
  2299. For example, you can't do: 
  2300.  call 0x123456
  2301. Even if you happen to know that there is executable code at that address. The linker simply won't get the reference right; so in the interests of not generating incorrect code, NASM will not allow this form of reference to be written to a Win32 object file. h
  2302. Note also that Borland Win32 compilers reportedly do not use this object file format: while Borland linkers will output Win32-COFF type executables, their object format is the same as the old DOS OBJ format. So if you are using a Borland compiler, don't use the Win32 object format, just use the 16 bit object format and declare all your segments as 'USE32'. 
  2303. COFF supports, in addition to the three standard section names '.text', '.data' and '.bss', the ability to define your own sections. Currently (this may change in the future) you can provide the options 'text' (or 'code'), 'data' or 'bss' to determine the type of section. 
  2304. Win32 also allows 'info', which is an informational section type used by Microsoft C compilers to store linker directives. So you can do: <
  2305.  section .mysect code      ; defines an extra code section
  2306. Or to pass directives to the MS linker: v
  2307.  section .drectve info     ; defines an MS-compatible directive section
  2308.  db '-defaultlib:LIBC -defaultlib:OLDNAMES '
  2309. COFF defaults to 32-bit assembly mode. #
  2310. Output
  2311. formats
  2312. screen
  2313.  Output formats - 16 bit object module format
  2314. The 'obj' format generates 16-bit Microsoft object files, suitable for feeding to 16-bit versions of Microsoft C, and probably TLINK as well (although that hasn't been tested). %
  2315. The Use32 extensions are supported. 
  2316. The object module format defines no special segment names: you can call segments what you like. Unlike the other formats, too, segment names are actually defined as symbols, so you can write: 
  2317.  segment CODE
  2318.  mov ax, CODE
  2319. And get the segment address of the segment, suitable for loading into a segment register. ^
  2320. Segments can be declared with attributes, see the Assembler
  2321. directives for more information. a
  2322. To avoid getting tangled up in NASM's local label mechanism, segment and group names have leading periods stripped when they are defined. Thus, the directive 'SEGMENT .text' will define a segment called 'text', which will clash with any other symbol called 'text', and you will not be able to reference the segment base as '.text', but only as 'text'. 
  2323. Common variables in OBJ files can be 'near' or 'far': currently, NASM has a horribly grotty way to support that, which is that if you specify the common variable's size as negative, it will be near, and otherwise it will be far. The support isn't perfect: if you declare a far common variable both in a NASM assembly module and in a C program, you may well find the linker reports "mismatch in array-size" or some such. The reason for this is that far common variables are defined by means of two size constants, which are multiplied to give the real size. Apparently the Microsoft linker (at least) likes both constants, not merely their product, to match up. This may be fixed in a future release. 
  2324. If the module you're writing is intended to contain the program entry point, you can declare this by defining the special label '..start' at the start point, either as a label or by EQU (although of course the normal caveats about EQU dependency still apply). U
  2325. 16 bit object format has an unusual handling of assembly modes: instead of having a global default for the whole file, there is a separate default for each segment. Thus, each SEGMENT directive carries an implicit BITS directive with it, which switches to 16-bit or 32-bit mode depending on whether the segment is a Use16 or Use32 segment. 
  2326. If you want to place 32-bit code in a Use16 segment, you can use an explicit 'BITS 32' override, but if you switch temporarily away from that segment, you will have to repeat the override after coming back to it. 
  2327. If you're trying to build a .COM application by linking several .OBJ files together, you need to put 'resb 0x100' at the front of the code segment in the first object file, since otherwise the linker will get the linking wrong. 9
  2328. OS/2 uses an almost exactly similar file format to DOS, with a couple of differences, principally that OS/2 defines a pseudo-group called FLAT, containing no segments, and every relocation is made relative to that (so it would be equivalent to writing 'label WRT FLAT' in place of 'label' throughout your code). 
  2329. Since this would be inconvenient to write code for, NASM implements the OS/2 variant on 16 bit object format, which provides this FLAT group itself and automatically makes the default relocation format relative to FLAT. #
  2330. Output
  2331. formats
  2332. screen
  2333.  Common problems
  2334. This information is taken directly from the NASM documentation written by Simon Tatham. 
  2335. NASM's design philosophy of generating exactly the code the programmer asks for, without second-guessing or re-interpreting, has been known to cause confusion in a couple of areas. 
  2336. Firstly, several people have complained that instructions such as 'add esp, 4' are assembled in a form that allocates a full four-byte offset field to store the '4' in, even though the instruction has a shorter form with a single-byte offset field which would work in this case. 
  2337. The answer is that NASM by design doesn't try to guess which one of these forms you want: if you want one, you code one, and if you want the other, you code the other. The other form is 'add esp, byte 4'. 
  2338. Secondly, and similarly, I've had repeated questions about conditional jumps. The simple 'jne label', in NASM, translates directly to the old 8086 form of the conditional jump, in which the offset can be up to 128 bytes (or thereabouts) in either direction. NASM won't automatically generate 'je $+3 / jmp label' for labels that are further away, and neither will it generate the 386 long- offset form of the instruction. E
  2339. If you want the 386-specific conditional jump that's capable of reaching anywhere in the same segment as the jump instruction, you want 'jne near label'. If you want an 8086-compatible 'je' over another 'jmp', code one explicitly, or define a macro to do so. NASM doesn't do either of these things for you, again by design. (
  2340. Programming
  2341. screen
  2342.  Credits
  2343. The following credit list covers all those whose code has been used in some shape or form in the NASM-IDE package. r
  2344.  Simon Tatham & Julian Hall   - main programmers of the
  2345.                                 Netwide Assembler (NASM)
  2346.  Ralph Brown (SPAWNO unit)    - the DOS shell routines that
  2347.                                 provide memory to allow NASM
  2348.                                 to be run from within NASM-IDE
  2349.  Blake Watson                 - the 'Programming with Turbo Vision'
  2350.                                 book is an excellent source of
  2351.                                 information
  2352.  Version information
  2353.  This is version 1.1 of NASM-IDE.
  2354.  NASM-IDE is free of charge.
  2355.  NASM-IDE is copyright (c)1997 Robert Anderton.
  2356. contents
  2357. screen
  2358. ' '!'"'#'$'%'&''')'t'u'v'w'x'y'z'{'|'}'~'
  2359.