home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Gthorne / reopsahl / howtotsr.txt < prev    next >
Text File  |  2000-05-25  |  35KB  |  792 lines

  1.                           [The 80x86Assembly Page]
  2.  
  3.  (this image was created by Dima Samsonov, the greatest guy in the world !)
  4.  
  5.     You are visitor number: 107734 since September 17th 1995, welcome !
  6.  
  7.                   [Image] [The freaks use it...AsmEdit !]
  8.  
  9.                                   [Image]
  10.  
  11.  In this document: (Click here to see the table of contents completely !)
  12.  
  13. These are sections of this same document and thus already loaded and
  14. quickly accesable.
  15.  [Image] Me                         [Image] My own creations
  16.  
  17.  [Image] How to browse this page    [Image] Sources
  18.  
  19.  [Image] What's [ NEW ] ?           [Image] Books
  20.  
  21.  [Image] Beginners corner           [Image] Protected Mode [ NEW ]
  22.  
  23.  [Image] Questions & Answers        [Image] Links
  24.  
  25.  [Image] How To ...                 [Image] Windows without GUI [ NEW ]
  26.  
  27.  [Image] Contributing               [Image] Thanks to...
  28.  
  29. Also take a look at:
  30.  
  31. These are some external, but related. documents, which may take some longer
  32. to load.
  33.  
  34.  [Image] The load statistics of this page      [Image] My (useless)
  35.                                                Porsche page
  36.  [Image] The Professional Programmers' Pages
  37.                                                [Image] Maarten's Home Page
  38.  (Asm, vb and Pascal)
  39.  
  40.                              [---------------]
  41.                                 Back to the top
  42.  
  43.                              [---------------]
  44.  
  45. Me
  46.  
  47. [Image]  Hi !
  48.  
  49. I'm Jannes Faber, student Computer Science at the University of Utrecht in
  50. the Netherlands (Europe !). As a job, I'm a programmer, mainly Assembly and
  51. some Basic. My greatest hobby (besides programming) is Quaking (used to be
  52. DooMing) !
  53.  
  54. You can mail me at Faber@fys.ruu.nl
  55.  
  56. You can also try to talk to me, if I'm on-line, using: talk
  57. faber@ruunat.fys.ruu.nl. I'm now OFFLINE !
  58.  
  59. ---------------------------------------------------------------------------
  60.                              [Back to the top]
  61. ---------------------------------------------------------------------------
  62.  
  63. Mail Me
  64.  
  65.  [Image]Before you really mail me, please note the following:
  66.  
  67.  [Image]Have you seen Tore's Assembly Tutorial yet ? (for all your
  68.         graphics stuff too !!!)
  69.  [Image]Do not mail me with questions about graphics programming or
  70.         protected mode things ! I simply don't know much about them !
  71.  [Image]I get too much mail, so make sure you check the following thing
  72.         before you ask me ! Don't think 'what the fuck, I'll just ask him,
  73.         that's much easier !'.
  74.  [Image]It can take up till a month or so before you get a reply !
  75.  [Image]I don't do your homework and I'm real good at spotting homework
  76.         assignments, so don't even think about it !
  77.  [Image]Make sure that the reply address in your browser is set to your
  78.         email address ! In NetScape for example, check
  79.         Options|Preferences|Mail and News ! I get quite a lot of mail with
  80.         an invalid return address !
  81.  [Image]Please also include your address in the mail itself, just to make
  82.         sure !
  83.  [Image]If you have anything to contribute, please read this first !
  84.  [Image]If you have some question, please read my How To get technical
  85.         info section first !
  86.  [Image]Before you ask me something about interrupts or hardware, make
  87.         sure you have checked HelpPC and The Interrupt List of Ralph Brown
  88.         (see the Links section) ! (and if you don't have them yet, just
  89.         get them anyway, no real programmer can live without them !!)
  90.  
  91. [Image] Thank you kindly for all your reactions !
  92.  
  93. If you've read the stuff above, you can mail me at: faber@fys.ruu.nl
  94.  
  95. ---------------------------------------------------------------------------
  96.                              [Back to the top]
  97. ---------------------------------------------------------------------------
  98.  
  99. Contributing
  100.  
  101. Do you have:
  102. [Image] Sources
  103. [Image] Technical information
  104. [Image] Addresses of other WWW pages or FTP-sites
  105. [Image] .... ?
  106.  
  107. Please let me know ! I will put it on my page, with your name and email
  108. address and a link to your own WWW-page if you like.
  109.  
  110.                  [How To Upload Stuff] [How To Contact Me]
  111. ---------------------------------------------------------------------------
  112.                              [Back to the top]
  113. ---------------------------------------------------------------------------
  114.  
  115.  [Image]What's new ?
  116.  
  117. [Image] I get way too much mail, so I have changed a few things in the
  118. conditions in which you can mail me. So please read them carefully before
  119. you mail me !
  120.  
  121. New/updated sections
  122.  
  123.      [Image] The Mail Me section has been updated, since I get too much
  124.      mail !
  125.      [Image] I set up a Mailing List on Protected Mode ! Join now !
  126.      [Image] Updated some info in the Books section.
  127.  
  128. New/updated sources
  129.  
  130. New/updated links
  131.  
  132.      [Image] Link to The AsmEdit page
  133.      [Image] Link to Pentium Optimization page
  134.  
  135. New/updated other things
  136.  
  137.      [Image] New header image (made by Dima Samsonov !) and some other
  138.      minor improvements.
  139.  
  140. My plans for the near future !
  141.  
  142.      [Image] I'm thinking about a total redesign for my page, adding a lot
  143.      more info, links etc.
  144.  
  145. ---------------------------------------------------------------------------
  146.                              [Back to the top]
  147. ---------------------------------------------------------------------------
  148.  
  149. How to browse this page
  150.  
  151. Screen resolution
  152.  
  153.         o Made in: 1024x768x256
  154.         o Checked and approved: 800x600 and 1024x768
  155.         o Also possible (not as good!): 640x480
  156.  
  157. Number of colors
  158.  
  159.         o Best: 256 colors; all real images are in 256 colors (not more!).
  160.           Only some dummy images are 16 colors to make them smaller and
  161.           thus faster to load. If you really wanna use 16 colors, you
  162.           better switch off the background picture !
  163.  
  164. Which browser
  165.  
  166.         o Made using: Netscape 1.2b6 for Windows95
  167.         o Adviced: Netscape 1.2 or newer
  168.         o Probably bad results: Mosaic, Cello, lynx (text based)
  169.         o Why: I used special html-codes (table e.g.) and Netscape is much
  170.           faster loading and easier to use.
  171.         o Text mode: So far I haven't put any effort in trying to make it
  172.           look acceptable in text mode, I think I will someday. Let me know
  173.           if you want it !
  174.  
  175. How to read this page
  176.  
  177.      I decided to put (almost) all information in one document, for ease of
  178.      use and higher performance. Although loading such a large document,
  179.      with all its' images at once, takes some time, in the end you will
  180.      find it much quicker and easier.
  181.      Every time you click a link to another document, all sorts of
  182.      communication is required with the host. And even if the document and
  183.      its' images are in cache, the whole document needs to be rebuild. By
  184.      combining everything in one document, the only thing you essentially
  185.      do is scrolling up and down.
  186.      I did provide a way to quickly jump from section to section though:
  187.         o After the initial load, you start at the top with the
  188.           Assembly-image. Click on 'In this document' to make the screen
  189.           scroll down a little. You now have 'In this document' as the
  190.           first line and beneath it the complete table of contents.
  191.         o Choose the section you would like to see, you will jump right to
  192.           it (no extra loading). If the section you chose wasn't loaded
  193.           yet, you will end up at the start of the document. Simply press
  194.           'In this document' again and choose another section or try again.
  195.         o Read the section, scrolling down somewhat when needed.
  196.         o Clicking 'Back to the top' (beneath every section) brings you
  197.           back in the table of contents (again, no loading).
  198.                   Do not press the back-button of NetScape ! This
  199.            [Image]will cause the document to be rebuild completely
  200.                   (from cache or not), which is much slower !
  201.  
  202. ---------------------------------------------------------------------------
  203.                              [Back to the top]
  204. ---------------------------------------------------------------------------
  205.  
  206. Questions & Answers
  207.  
  208. In this sections I'll put all interesting questions and, as soon as I have
  209. them, the answers to them. If you have a question or an answer, please mail
  210. me: faber@fys.ruu.nl.
  211.  Question          Answer
  212.  
  213.                    I think this would be a nice thing to keep endless
  214.  Now that          discussions about. My opinion (and you may disagree if
  215.  Windows95 is      you want !) is that Assembly certainly not dead yet ! I
  216.  available, is     don't think DOS is dead yet either. It probably won't
  217.  Assembly language take much longer now, but it really isn't yet ! And
  218.  still useful ?    then there will be the possibility to write Assembly
  219.                    routines for Windows-programs, although I have no
  220.                    experience with that !
  221. ---------------------------------------------------------------------------
  222.                              [Back to the top]
  223. ---------------------------------------------------------------------------
  224.  
  225. Books
  226.  
  227.         This section contains information on lots of books (for beginners
  228.         and more advanced programmers !). I read some of them, others I
  229.         only have heared about. Of course I'm not responsible for any
  230.  [Image]mistakes, but if you find one, please let me know !
  231.  
  232.         If you know any good books, please let me know ! Please mail me a
  233.         somewhat detailed description.
  234.  
  235. For Beginners
  236.  
  237. The Waite Group's Microsoft Macro Assembler Bible 2nd edition by Barkakati
  238. and Hyde.
  239. ISBN: 0-672-30155-5
  240. Descr.: instructions (+ encoding & timing), MASM 6.0. Basicly:beginners
  241. course on Assembly
  242.  
  243. Assembly Language Programming and Organization of the IBM PC by Ytha Yu,
  244. Charles Marut
  245. ISBN: 0-07-072692-2
  246. Mitchell-McGraw Hill, 1992
  247. Descr.: A very very basic guide to Assembler of the 80x86.
  248.  
  249. Jeff Duntemann "ASSEMBLY LANGUAGE Step By Step"
  250. If you haven't programmed before this is a great book. Jeff assumes you
  251. don't know anything and give you the basics, starting with how computers
  252. think and then going into the numbering systems. He has a very good
  253. approach, with a slight bent toward humor, making for an interesting
  254. learning experience. (Steve Fox)
  255. ISBN: 0-471-57814-2 (paper : alk. paper)
  256. Publisher: John Wiley & Sons, Inc.
  257.  
  258. For intermediate and advanced programmers:
  259.  
  260. Programmer's technical reference: The processor and coprocessor by R.L.
  261. Hummel.
  262. ISBN:1-56276-016-5
  263. Descr.: architecture and programming of intel's 80x86 and 80x87 (not
  264. pentium), 32-bit mode, complete instruction sets.
  265.  
  266. Assembly language for real programmers only ! by M. Johnson (SAMS
  267. publishing).
  268. ISBN: 0-672-48470-6
  269. Descr.: Windows programming, 32-bit prot.mode, CodeView etc., MASM 6.1
  270.  
  271. C programmer's guide to serial communications 2nd edition by J. Campbell
  272. ISBN: 0-672-30286-1
  273. Descr.: contains 2 parts: 1st part is serial comm. in general (no C yet!),
  274. 2nd part contains C sample programs.
  275.  
  276. PCintern by Micheal Tischer (Abacus)
  277. ISBN: 1-55755-145-6
  278. Descr.: covers writing TSRs, device drivers, multitasking, DPMI/VCPI,
  279. programming network-applications.
  280.  
  281. PCintern 4 by Micheal Tischer (Abacus) (I only know about the Dutch version
  282. !!!)
  283. ISBN: 90-5167-027-3
  284. Descr.: Systeem programmeren: TSRs, device drivers, multitasken, DPMI/VCPI,
  285. netwerken, CDROM, Soundblaster.
  286.  
  287. PC INTERN Edition 5 by Michael Tischer
  288. ISBN: 1-55755-282-7
  289. Price: $59.95 USA (including CD ROM)
  290. Descr.: unknown (same as above, just newer/more ?)
  291.  
  292. Pentium Processor optimization tools by Michael L. Schmit, published by AP
  293. Professional
  294. ISBN: 0-12-627230-1
  295. Descr.: The book (primarily) contains info on how to optimize code for the
  296. Pentium (also the 486). The disk includes a copy of PentOpt, a Pentium
  297. optimization tool, DEBUG32 (a DPMI debugger) and a library of routines for
  298. timing your code.
  299. Descr. by: Mike Schmit himself !
  300.  
  301. UNDOCUMENTED DOS by Andrew Shulman, Raymond J. Michaels, Jim Kyle, Tim
  302. Patterson, David Maxey, and Ralf Brown. 1990, Addison-Wesley Publishing
  303. Company, Inc.
  304. ISBN: 0-201-57064-5
  305. Descr.: a Programmer's Guide to reserved MS-DOS functions and Data
  306. Structures (Covers DOS 5) .
  307.  
  308. ADVANCED MS-DOS PROGRAMMING, Second Edition by Ray Duncan. 1988, Microsoft
  309. press
  310. ISBN 1-55615-157-8
  311. Descr.: The Microsoft Guide for Assembly Language and C Programmers.
  312.  
  313. Developing your own 32-bit Operating System by Richard A. Burgess (SAMS
  314. publishing)
  315. ISBN: 0-672-30655-7
  316. Descr.: Very detailed log of how he wrote his own OS, includes a CDROM with
  317. (C and ASM) source etc.
  318.  
  319. PC UNDERGROUND by: B. Bertelsons & M. Rasch
  320. ISBN: 1-55755-275-4
  321. Price: $34.95 USA (includes CD ROM)
  322. Descr.: unknown
  323.  
  324. The PC programmers bible by Peter Norton, Peter Aitken and Richard Wilton
  325. ISBN: 1-55615-555-7
  326. Price: around $30 (USA)
  327. Descr.: Covers 8088 - Pentium
  328. EISA and Micro Channel
  329. Sound Cards, Modems, Net Adapters, and Printers
  330. MS-DOS 6.0, MS Windows 3.1, and NT, OS/2 2.0
  331.  
  332. Books and/or description unknown to me:
  333.  
  334. Zen of code optimization by Michael Abrash
  335. Programmers Guide to the IBM PC by Peter Norton
  336. 80386 Programming Guide by Lance Leventhal
  337. C with Assembly Language by Steven Holzner (beginner !)
  338.  
  339. For more information on a lot of books check out the Macmillan Information
  340. SuperLibrary and another Assembly site, that also contains (among other
  341. things) book info.
  342. ---------------------------------------------------------------------------
  343.                              [Back to the top]
  344. ---------------------------------------------------------------------------
  345.  
  346. My own creations
  347.  
  348. Here are the sources and executables of programs and routines that I wrote.
  349. See also: 'Sources'
  350.  Name         KBDescription
  351.  
  352.  Hercules.zip 28Some great Hercules routines that allow you to use 2
  353.                 monitors at the same time ! Great for debugging etc. !
  354.  
  355.  TraceInt.zip 1 Sample program that uses my Hercules routines to trace
  356.                 ints (simple TSR).
  357.                 Program that continually copies the VGA
  358.  VGAColor.zip 1 color-attribute-bytes onto the Hercules screen as
  359.                 characters (simple TSR).
  360.  
  361.     cdrom.zip 3 Little program that opens and closes your cd-rom from the
  362.                 command line.
  363.  
  364.  newcdrom.zip 2 Newer version of the cdrom-program above (auto-detects
  365.                 cdrom-driver name).
  366.  
  367.    cdrom3.asm 2 Version 3: smaller, better programmed and compiles with
  368.                 MASM and TASM !
  369.  
  370.  TSRsampl.zip 1 Sample program of how to make a TSR. Also see How To make
  371.                 a TSR..
  372. ---------------------------------------------------------------------------
  373.                              [Back to the top]
  374. ---------------------------------------------------------------------------
  375.  
  376. [Image] Links
  377.  
  378. The following table contains all kinds of links related to Assembly
  379. programming. Please tell me if you have an URL or FTP-address that could be
  380. of interest to the others reading this page !
  381.                                           Other Assembly World Wide Web pages
  382.  
  383.  The Assembly pages of rrose               Another Assembly page                 Great site with a lot of link of
  384.                                                                                  Arzie !
  385.  DOS and BIOS clones, with source          Operating Systems                     Web site of NuMega (great debuggers!)
  386.  Randall Hyde                              Plug & Play BIOS specification 1.0a   Joe's Assembly Language Links Page
  387.  Chris' Programming Page                   Tore's Assembly Tutorial              Peter's PMode Page
  388.  Cameron's Programming Pages               A complete Asm course !               Ard Oerlemans' Assembly Page !
  389.  Yahoo's(the search engine) 80x86 Assembly
  390.  Page                                      A complete Assembly book online !!    The AsmEdit page
  391.  Pentium Optimization Page
  392.                                                       News groups
  393.  alt.msdos.programmer                      comp.lang.asm.x86                     comp.os.msdos.programmer
  394.  comp.os.ms-windows.programmer             comp.os.ms-windows.programmer.controlscomp.os.ms-windows.programmer.drivers
  395.  comp.os.ms-windows.programmer.graphics    comp.os.ms-windows.programmer.memory  comp.os.ms-windows.programmer.misc
  396.  comp.os.ms-windows.programmer.multimedia  comp.os.ms-windows.programmer.networkscomp.compilers
  397.  comp.compression.research                 comp.os.msdos.desqview                comp.programming
  398.  comp.os.ms-windows.programmer.ole         comp.os.ms-windows.programmer.tools   comp.os.ms-windows.programmer.win32
  399.  comp.os.ms-windows.programmer.winhelp     rec.games.programmer
  400.                                                          FAQ's
  401.  FAQ of newsgroup comp.os.msdos.programmer comp.os.ms-windows.programmer.vxd FAQ x86 Assembly Language FAQ
  402.                                       ftp sites with lots of Assembly directories
  403.  Macmillan Information SuperLibrary        ftp.cdrom.com                         x2ftp.oulu.fi
  404.  zfja-gate.fuw.edu.pl/user/net/ka9q/guest/
  405.                                                 Technical docs and info
  406.  Ralph Brown's Interrupt List              A list of all possible ints !
  407.  HelpPC                                    A very complete technical info database
  408.  Intel Secrets                             What Intel Doesn't Want You To Know !
  409. ---------------------------------------------------------------------------
  410.                              [Back to the top]
  411. ---------------------------------------------------------------------------
  412.  
  413. Sources
  414.  
  415. This section contains the sources of programs of several contributors. See
  416. also: 'My Own Creations'
  417.  Name               KB Description
  418.  
  419.     Chk_Date.zip    2  Little routine to let programs only run once a dat
  420.                        in batch files !
  421.       xms.zip       15 Example of how to use xms-memory in Assembly.
  422.  
  423.       dos.zip       3  A few great routines to use in your VBDOS
  424.                        programs. From one of my contributors.
  425.  
  426.     key_code.zip    2  Little tool that tells you the scancodes with the
  427.                        key you pressed.
  428.  
  429.      dialer.zip     18 GREAT resident phone dialer, includes complete
  430.                        database. Only 4.5 K when resident !.
  431.     envfind.zip     2  Great little util for searching files !.
  432.  
  433.     helloos2.zip    2  Example of making an OS/2 application using MASM
  434.                        6.11.
  435.      qcopy.zip      11 Fast diskcopy program (written in Pascal !).
  436.  
  437.      qb_ipx.zip     100Not assembly, but it explains a lot about using
  438.                        IPX (network protocol).
  439.  
  440.        df.zip       12 Not assembly, but shows how to format disks in C
  441.                        and Pascal (from the book PC Intern 4).
  442.     bootsec.zip     2  Describes how to create your own bootsector code.
  443.     win95ex.zip     27 Sample of making Win95 programs in Assembly.
  444.     dma_info.zip    10 Information on DMA programming !
  445.                        TSR and EXEC sample program, not finished yet,
  446.  [Image]savscrn.zip 13 download it if you think you can help the maker !!
  447.                        (includes asm source!)
  448. ---------------------------------------------------------------------------
  449.                              [Back to the top]
  450. ---------------------------------------------------------------------------
  451.  
  452. How To ?
  453.  
  454.  programing stuff    my page                    internet
  455.  
  456.  How to make a TSR   How to browse this page    How to find technical
  457.                                                 information
  458.  Run Windows without
  459.  GUI                 How to contact me          Find files on the Net
  460.                      How to send me
  461.                      sources/info etc.
  462. ---------------------------------------------------------------------------
  463.                              [Back to the top]
  464. ---------------------------------------------------------------------------
  465.  
  466. How to make a TSR
  467.  
  468.      Making a TSR (Terminate and Stay Resident) program is somewhat
  469.      different than making a normal program. It isn't very difficult though
  470.      ! In this section I'll try to explain the basics of a TSR.
  471.  
  472.      A TSR program is basicly just a piece of code that remains in memory
  473.      when the program is terminated. 'But when is it executed if the
  474.      program already quit', you might ask. The main program has set up
  475.      (before it quit) the Interrupt Vector Table (IVT) so that one (or
  476.      more) of the interrupts points towards the piece of resident code.
  477.      This way every time that interrupt occurs, your piece of code (the
  478.      Interrupt Service Routine or ISR !) gets executed.
  479.  
  480.      Interrupts can be generated in two ways: by hardware or by software.
  481.      An example of an hardware interrupt is the one from a serial port or
  482.      from the keyboard. The ISR is responsible for handling the cause that
  483.      generated the interrupt (receiving a byte e.g.). Software interrupts
  484.      are for example interrupts to BIOS or DOS routines, you probably use
  485.      them all the time in your programs by using the INT instruction.
  486.  
  487.      Hoe do we set the IVT ? The IVT is just a piece of memory at address
  488.      0000:0000 (with 256 4-byte FAR pointers to ISRs) in memory and you
  489.      could just alter the values there. Another (more compatible) way is to
  490.      use the DOS routines for it. See my example code lateron.
  491.  
  492.      What to do when my ISR is executed ? What you exactly do in your ISR
  493.      depends on which interrupt you hook on to, but there are a few general
  494.      guide lines:
  495.         o The interrupt-flag is normally disabled (preventing other
  496.           interrupts to occur) at beginning of your ISR. Good behaviour
  497.           tells you to enable it ASAP (using the STI-instruction).
  498.         o Save all registers you're planning to use on the stack, unless
  499.           you really want them to be changed after you ISR is done. When
  500.           you have hooked a hardware interrupt, you definitely don't want
  501.           to change any registers.
  502.         o You do not need to save the FLAGS-register, this was
  503.           automatically done when the interrupt occured. Just use IRET to
  504.           exit your ISR instead of the normal RET. You can also use RET 2
  505.           (for skipping 2 bytes on the stack, the FLAGS-bytes !) when you
  506.           do want to change the FLAGS ! Again, you can't do that in a
  507.           hardware ISR !
  508.         o Remember that you do not really know when and where the interrupt
  509.           occured, so the only register you know is CS. This is not really
  510.           true in software interrupts, you could demand the caller to setup
  511.           some registers as parameters. But do not use DS if you thinks it
  512.           points towards your own DATA (or CODE)-segment. If you need data
  513.           in your own segment, use MOV AX, CS and MOV DS, AX (after PUSHing
  514.           AX) or: PUSH CS and POP DS.
  515.         o Very often you need to call the old ISR (the one that was
  516.           installed before yours was !) when you're done, or the interrupt
  517.           was not mend for you. Thus you need to remember the old address
  518.           before you install your own ISR and use CALL CS:OldHandler to
  519.           call the old one.
  520.         o Remember when you're pushing things on the stack, you're not
  521.           working on your own stack, but on the stack of the program that
  522.           was running when the interrupt occured ! Do not push more than a
  523.           few registers !
  524.         o Another tricky thing about TSRs: you probably can't call DOS and
  525.           BIOS routines because they are not reentrant (can be active only
  526.           once at a time) and suppose the interrupt just interrupted one of
  527.           these routines ! If you really do need to calll a DOS or BIOS
  528.           routine, also hook those interrupts and maintain a flags for when
  529.           they're active and when not.
  530.  
  531.      Time for an example ! (You can also download this example by cliking
  532.      on this word !)
  533.  
  534.      ; This sample code will hook the timer interrupt (hardware, called 18.2 times a sec.).
  535.              .MODEL  TINY
  536.              .386
  537.              .CODE
  538.              .STARTUP
  539.  
  540.              jmp     Install                 ; Jump over data and resident code
  541.  
  542.      ; Data must be in code segment so it won't be thrown away with Install code.
  543.      OldHandler      DWORD   ?               ; Address of original timer routine
  544.  
  545.      NewHandler      PROC   FAR
  546.              push    bx              ; these two registers will be changed
  547.              push    ds
  548.  
  549.              mov     bx, 0B800h      ; 0B800h is the address of the VGA display
  550.              mov     ds, bx
  551.  
  552.              mov     bx, 1           ; the color attirbute of the first character of the screen
  553.              inc     [bx]            ; increase it (color will change 18.2 times a sec.)
  554.  
  555.              pop     ds              ; restore the registers
  556.              pop     bx
  557.  
  558.              jmp     cs:OldHandler   ; this is the same as CALL CS:OldHandler + IRET
  559.      NewHandler      ENDP
  560.  
  561.      Install PROC
  562.              mov     ax, 351Ch       ; Request function 35h
  563.              int             21h             ; Get vector for timer (interrupt 08)
  564.              mov             WORD PTR OldHandler[0], bx      ; Store address of original
  565.              mov             WORD PTR OldHandler[2], es      ;   timer interrupt
  566.              mov             ax, 251Ch       ; Request function 25h
  567.              mov             dx, OFFSET NewHandler   ; DS:DX points to new timer handler
  568.              int             21h             ; Set vector with address of NewHandler
  569.  
  570.              mov             dx, OFFSET Install      ; DX = bytes in resident section
  571.              mov     cl, 4
  572.              shr             dx, cl  ; Convert to number of paragraphs
  573.              inc             dx              ;   plus one
  574.              mov             ax, 3100h       ; Request function 31h, error code=0
  575.              int     21h             ; Terminate-and-Stay-Resident
  576.      Install ENDP
  577.  
  578.              END
  579.  
  580.      The only way to really learn TSR programming is to just experiment a
  581.      lot. If you want to see more samples, check out My Own Creations and
  582.      Sources.
  583.  
  584.                       [Back to How To index] [Back to Top]
  585.  
  586. How to run Windows without GUI
  587.  
  588.      Running Windows (3.x or 95) gives you a great DOS-multitasker without
  589.      the boot-time and overhead (on CPU, memory, disk, VGA-adaptor etc) of
  590.      graphics. To see how to start Windows without the GUI, check this
  591.      dedicated page.
  592.  
  593.                       [Back to How To index] [Back to Top]
  594.  
  595. How to find technical information
  596.  
  597.      [Image] See these sections of my page: 'My Own Creations', Sources',
  598.      'Question & Answers', 'Links', 'Books' and 'How To'.
  599.      [Image] Download HelpPC and The Interrupt List, these are really great
  600.      databases full of tech info !!! See the Links section.
  601.      [Image] Use various search engines on the WWW (click Directory |
  602.      Internet Search in Netscape). Other great search engines: Alta Vista
  603.      or Yahoo.
  604.      [Image] Take a look at the FAQ's that are in my Links-section.
  605.      [Image] Use FTP and look in directories like
  606.      /pub/msdos/programming/.....
  607.      [Image] Ask me
  608.  
  609.                       [Back to How To index] [Back to Top]
  610.  
  611. How to send me sources/info etc.
  612.  
  613. If you have sources or other files that you want to send to me so that I
  614. can put them on my page, you can do that in several ways:
  615. [Image] Upload it using FTP to ruunat.fys.ruu.nl place it in the /uploads/
  616. directory and then mail me telling me the name of the file(s) you just
  617. uploaded.
  618. [Image] Attach the file(s) to an email (please, only do this if you cannot
  619. use FTP!).
  620.  
  621. Anyway, always include a description of the files, your email address and
  622. the URL of your home page (if you have one and want a link to it on my
  623. page).
  624.  
  625.                     [Back to How To index] [Back to Top]
  626.  
  627. How to find files on the Net
  628.  
  629. You want to search for a specific file somewhere on one of the billion
  630. ftp-sites ? That's what archie is for ! Type in (part of) the name of the
  631. file you need and press Enter to get a list of all ftp-sites that have such
  632. a file.
  633.  
  634. Try this online Archie Gateway [SORRY ! This CGI-script seems to be
  635. disabled, I'm working on this !].
  636.  
  637. You can also try to find some info at Search engines like:
  638.    o Alta Vista
  639.    o Yahoo
  640.    o Infoseek
  641.  
  642.                     [Back to How To index] [Back to Top]
  643.  
  644. ---------------------------------------------------------------------------
  645.                              [Back to the top]
  646. ---------------------------------------------------------------------------
  647.  
  648. Protected Mode
  649.  
  650. And finally it's here ! The Protected Mode Mailing List !
  651.  
  652. I set up a free mailing list on protected mode programming and everything
  653. that has anything to do with it. The list depends on people like you that
  654. are interested in the subject. You ask a question others try to help you on
  655. it. Someone else asks a question, you try to help him/her !
  656.  
  657. I do need to warn you: personally I do not know enough about protected mode
  658. to really answer questions or ask them. I will try to keep the list alive
  659. and I'm the one that set it up and maintains it (in my free time, so no
  660. complaints ! :). I need you to really give the list a meaning !
  661.  
  662. If you want to subscribe simply send an email to majordomo@fys.ruu.nl with
  663. the following in the body:
  664.  
  665. subscribe pmode-l
  666.  
  667. (this is PMODE-L, not pmode-1 !!) Send it from your own email account, so
  668. that the majordomo scripts can get your email address. You'll automatically
  669. get an email saying you you are subscribed.
  670.  
  671. ---------------------------------------------------------------------------
  672. A little tutor (which is not mine) !
  673.  
  674. [Image] NEW: I created a page on how to start MS Windows without the GUI,
  675. and thus use it as DOS-multitasker !
  676.  
  677. [Image] NEW TOO: Check out Peter's PMode Page !
  678.  
  679. ---------------------------------------------------------------------------
  680.                              [Back to the top]
  681. ---------------------------------------------------------------------------
  682.  
  683. Beginners corner
  684.  
  685. Welcome Assembly novice !
  686.  
  687. Assembly language programming is programming the computer at the lowest
  688. level possible, it is essentially writing direct processor instructions.
  689. Unlike in other programming languages, where you write a series of commands
  690. (often multiple on a single line) and then let the compiler translate your
  691. program into machine code (where every high-level-command is often hundreds
  692. of actual processor instructions). Assembly language is a literal
  693. translation of real machine code (series of bytes) in a more readable (to
  694. humans!) form.
  695.  
  696. Assembly programming is often found more difficult than high-level
  697. programming, because you have to think like the computer and need a lot of
  698. instructions for a simple task. This also makes maintaining or even
  699. understanding the code difficult. But why do people still program in
  700. Assembly language then ? That's because, when you program right, you can
  701. get the fastest and/or smallest code possible and you can simply program
  702. everything that can be done with a computer.
  703.  
  704. But there is a way to combine the advantages of both Assembly and
  705. high-level languages: use only small Assembly routines that are used by the
  706. body of the high-level program. These Assembly routines perform tasks that
  707. really need to be fast or just can't be done from within the high-level
  708. language, but the main part of the program is in plain and simple high
  709. level language. If you rewrite a high-level routine, that takes about 90%
  710. of the running time, into Assembly and thereby triple its execution speed,
  711. you get a program that runs well over twice as fast ! This is of course a
  712. little rare example, but it does illustrate my point.
  713.  
  714. An often used routine, for example, is one that writes a string directly to
  715. the screen (also see my own Hercules routines for an example !), instead of
  716. via the DOS or BIOS routines (that most high-level languages use). Those
  717. DOS and BIOS routines are quite slowly: keeping a simple counter on the
  718. screen may slow down the process significantly, try it ! The solution is
  719. making a routine that simply places the characters of the string directly
  720. in the video memory (somewhere in RAM). This is really a lot quicker and
  721. can significantly speed up programs with a lot screen output. This method
  722. does make your program a little less compatible, but it'll still work on
  723. normal PC's (about 99.99 %!). Of course there are some disadvantages, for
  724. one: you loose the ability to redirect the output (MYPROG > OUTPUT.TXT),
  725. but in todays programs that's hardly a breakdown !
  726.  
  727. I get questions from people that want to learn or just start experimenting
  728. with Assembly quite often. Here are the Frequently Asked Questions (FAQ):
  729.  
  730. I need to make executable files out of my assembly sources, how do I do
  731. that ?
  732.      What you need is an Assembler, a program that translates your Assembly
  733.      source into real processor instructions.
  734.  
  735. Where do I get an Assembler ?
  736.      There are a lot of Assembler in use to day. You have the choice
  737.      between a commercial, a shareware or a freeware Assembler.
  738.  
  739.      Commercial Assemblers: Microsoft Macro Assembler (MASM), Borland Turbo
  740.      Assembler (TASM). There are more though !
  741.      Shareware Assemblers: A86 (and its debugger D86). See 'Links' to find
  742.      some ftp-sites where you can get them.
  743.      Freeware Assemblers:
  744.  
  745. Where do I find a tutoral or a good book on Assembly ?
  746.      I give some information on good books in the section 'books'. Tutorals
  747.      and helpfiles can be found on several ftp-sites and BBSes, I have some
  748.      links to several of them in the 'Links' section.
  749.  
  750. I need a complete overview of all available interrupts and instructions !
  751.      There are several technical databases available on the Net (The
  752.      Interrupt List from Ralph Brown and HelpPC e.g.), check out the
  753.      section 'Links'.
  754.  
  755. I need information on how to program '....' (the mouse e.g.) !
  756.      See the section 'Links' for information on The Interrupt List and
  757.      HelpPC (technical databases) and links to ftp-sites with sample codes.
  758.      Maybe I have one or more sample programs on this, see the section
  759.      'Sources', 'My Own Creations', 'Questions & Answers' and 'Books'.
  760.  
  761. I'm having trouble writing a TSR !
  762.      See the section 'How To program a TSR'.
  763.  
  764. I wish you lots of luck with Assembly-programming !
  765. ---------------------------------------------------------------------------
  766.                              [Back to the top]
  767. ---------------------------------------------------------------------------
  768.  
  769. Thanks to...
  770.  
  771. At this point I would like to thank (in random order):
  772.  
  773.    * [Image] Dima Samsonov for the header image !
  774.    * all contributors that have given me a lot of sources, tips, info etc.
  775.    * you for visiting my page !
  776.  
  777.              Put on the web:   September 1st 1995 (updated a lot since!)
  778.  
  779.                  Created by:   Jannes Faber
  780.  
  781.                       Email:   faber@fys.ruu.nl
  782.  
  783.                         URL:   http://www.fys.ruu.nl/~faber/Amain.html
  784.  
  785.   Copyright ⌐ 1995, 1996 by:   Jannes Faber
  786.  
  787.               Thank you for:   dropping by, please do it again sometime !
  788.  
  789. ---------------------------------------------------------------------------
  790.                              [Back to the top]
  791. ---------------------------------------------------------------------------
  792.