V22.0201, Machine Organization I, Yap: Sample Programs

####
V22.0201.002, Machine Organization I
Fall 1997

###
Samples: Programs, Old Exams, Comments on Lecture.

1. BATCH FILES: Batch programs can be used to organize your live in DOS. Here are two samples that I find useful. bat.bat, clean.bat.
   Another useful one that I use is called ``mypath.bat'' which is used to set the path variable to include the Turbo Assembler directory as well as your own directory containing your own executables (such as clean.bat!). See FAQ for information on how to do this. (Basically, type ``path > mypath.bat'' and then edit mypath.bat accordingly.)
2. OLD MIDTERM AND SOLUTION: These files, mid.ps and mids.ps, are postscript files. See FAQ for how to print them.
3. mask.asm: sample program from class lecture illustrating the shift/rotate functions.
4. outhex.asm: sample program from class lecture (Oct 29) containing a procedure to print the contents of register BH in hex. This is essentially question 9 of midterm.
5. readstring.asm: program from lecture of Nov 3, illustrating (1) function 10, int 21h, and (2) string representation.
6. Programs used in Nov 5 lecture: prm12_3.asm, prm12_2.asm, and prm12_1.asm are taken from the text (chap.12), and illustrates basic keyboard interrupts and text video mode.
7. Program used in Nov 10 lecture on mouse interrupt: mse-2.asm.
8. Programs used on Nov 19 lecture: this is the timeout.asm program that waits for up to N (=50) ticks for any keyboard response (and prints ``timed out'' or ``in time'', accordingly). It uses setupint.asm and tick.asm from the text, and macro file mac.asm. The bat file timeoutX.bat is also provided for your convenience. This example illustrates several important concepts, all useful for your final project:
   - the setting up of interrupts,
   - the use of the timer_tick interrupt function
   - checking if the keyboard buffer is empty (int 16h, fcn=1)
   - the use of modules in assembling (EXTRN, PUBLIC)
   It does this more simply than the book's example, which requires the use of TSR and .COM programming.
9. For your convenience, here are the TSR clock programs from chapter 15: p15_3.asm p15_3a.asm p15_3b.asm p15_3c.asm. Remember that this is how you assemble this into a .COM file under TASM:

       	tasm p15_3+p15_3b+p15_3c+p15_3a
       	tlink /t p15_3+p15_3b+p15_3c+p15_3a

   That is, p15_3 is first and p15_3a is last, and you need the /t flag for tlink.
10. Random number generator program that must be assembled into a .com file. Here is a simple test routine for the random number generator.
11. Here is a directory containing large number of routines for EGA and VGA graphics. The routines are in the subdirectory asm and I have written some test programs in the subdirectory progs (see below). To download all the files in asm, just get the file asm.tar.gz (this is a tar file that has been gzipped). Rename it to asm_tar.gz (it may already have this name) on your Win95 system before calling winzip to unpack its contents. These routines are from a diskette accompanying the following "vga-book": Programmer's Guide to EGA/VGA, from Simon & Schuster, Inc (1988).
12. Programs discussed in Nov 26 Lecture: vgaclear.asm, vgabox.asm, vgaline.asm. These programs simply calls the procedures from the vga-book mentioned above. Please download the latest version of my macro file to use in conjunction with these programs. NOTE: vgabox1.asm is a variation of vgabox.asm.
13. Lecture on Dec 1: basically discussed the "Bit Block Transfer" routine _BitBlt found in prog087.asm. A program that exercises this function is found in vgablt.asm. We also discussed the passing of arguments in high level languages such as C, as illustrated by the function _BitBlt. A trivial variation of mse-2.asm program above is mse3.asm, using mode 12h.
14. Lecture on Dec 3: Here is information on TLIB, the Turbo Library Facilities. Here are notes on memory models, especially how to use extra data segments.
15. Lecture on Dec 8:

        	1.  Here is the information on how on how to use
        		PCX files, its
        		format, etc.
        	1. mse2.asm illustrates how
        		you can define your own mouse cursor icon.
        	2. mse3.asm illustrates how to track
        		the mouse position for manipulating displays.

16. Lecture on Dec 10:
    Here is the list of topics required for the final exam.
    Here is the postscript file containing the sample final exam (with answers). Click here for instructions for printing postscript files.