[CMSC 313 Home] | [Syllabus] | [Homework] | [Projects] | [Lecture Notes] | [Printable all notes] | [Files] | [NASM resource] |

CMSC 313 Projects

Contents

  • Project 1
  • Project 2
  • Project 3
  • Project 4
  • Project 5
  • Submitting your Project

     The project is to be submitted on GL as 
       submit cs313_0101 proj1 convert.asm
       submit cs313_0101 proj2 list.asm
       submit cs313_0101 proj3 boot.asm
       submit cs313_0101 proj4 proj4.vhdl
       submit cs313_0101 proj5 proj5.vhdl
    
    

    Getting Started

    Using UMBC computer

    From anywhere you can reach the internet:
    
      ssh  your-username@linux.gl.umbc.edu  # or use putty, etc.
      your-password
    
      mkdir cs313   # or whatever directory name you want
      cd cs313
    
                    # Get some sample files.
      cp  /afs/umbc.edu/users/s/q/squire/pub/../download/hello.asm  .
      cp  /afs/umbc.edu/users/s/q/squire/pub/../download/intarith.asm .
      cp  /afs/umbc.edu/users/s/q/squire/pub/../download/boot1.asm .
    
                    # be sure to type the final   space dot 
    
                    # test compile  hello.asm
    
      nasm -f elf hello.asm
      gcc -o hello  hello.o
      hello
      ls -ltr                 # see files you have
    
      If this did not work, see Help Desk, T.A. or instructor
    
    

    Project 1, Number Conversion

    Write and submit a NASM assembly language program
    "convert.asm" that implements the number conversions
    that you did for Homework 1.  The file  "intarith.asm"
    might be helpful.
    
    You start with two constants in the  .data  section
    
    dec1:  db  '1','2','3','.','3','7','5',0
    bin1   dd  01010110111101B ; 10101101.11101
    
    You convert dec1 to a string of characters that is
    the binary representation of 123.3750 with a binary point
    and three bits to the right of the binary point.
    Print your characters (string) with printf or a kernel call.
    
    You convert bin1 to a string of characters that is
    the decimal representation of  10101101.11101.
    Print your characters (string) with printf or a kernel call.
    
    submit your file, when it is working correctly,
      submit cs313_0101 proj1 convert.asm
    
    Your file must assemble with no errors and execute
    with the commands:
    
       nasm -f elf convert.asm
       gcc -o convert  convert.o
       ./convert                  # ./ needed if '.' not first in PATH
    
    Then   submit cs313_0101 proj1 convert.asm
    
    Note: '1' is an ASCII character. Subtract 48 from an ASCII
          character to get a binary number. Add 48 to a binary
          number in the range 0 to 9 to get the ASCII character
          '0' to '9'.
    
    See horner.asm for sample
    conversion loops.
    
    Partial credit: 25% for decimal integer to binary
                    25% for decimal fraction to binary
    		25% for binary integer to decimal
    		25% for binary fraction to decimal
    Zero points if your convert.asm does not compile,
                if your convert.asm just prints the answers without
                   doing the conversion.
                if two or more convert.asm are copied
    
    (after Spring 2004 semester:
     You can only use %s, not %d, %e, %f, %g, etc. in printf.
     You can not use floating point instructions.)
      
    

    Project 2, Convert "C" linked list to NASM

    Write and submit NASM assembly language functions
    that implement the given "C" functions in list.c
    or the pointer version listp.c
    
    The test program, with function prototypes, is test_list_str.c
    
    Your correct output should be test_list_str.chk
    
    Note: There is zero credit when  list.asm  does not compile without errors.
          There is 25% credit when 'clear' 'push_back' and 'print' work.
          There is 50% credit when three 'push_back' also work.
          There is 75% credit when two lists and 'push_front' also work.
          There is 90% credit when 'pop_front' and 'pop_back' also work.
          There is 100% credit when all of test_list_str works.
    
    Your file must assemble with no errors and execute on linux.gl.umbc.edu
    with the commands:
    A possible starter file list_part.asm for list.c
    A possible starter file listp_part.asm for listp.c
    
       nasm -f elf list.asm
       gcc -o test_list_str test_list_str.c  list.o
       test_list_str
    
    Then    submit cs313_0101 proj2 list.asm
    
    For anyone who has not had linked list:
    
    
    

    Project 3, Write a bootable program

    Write and submit a NASM program that can be written
    to a floppy that boots and runs without using an
    operating system.
    
    This program must read the primary hard drive 80h and
    do a hexadecimal dump of two sectors. (If you have a non
    standard system, or find it safer, it is ok to read from
    00h, the floppy. This has the advantage that you see your
    own program.)
    
    A sample hexadecimal dump program in "C" is hdump.c
    You can code this into 16 bit NASM boot code or do your own.
    The hexadecimal dump must be a subroutine and must be called
    twice. Once for each disk sector.
    
    You are to use available BIOS calls.
    (There is no 'printf', no operating system is running!)
    See BIOS ref
    Interrupt Services But, not INT 21h, you do not have DOS running.
    
    Required: first column address, in hexadecimal, four hex digits are enough.
    Next 16 columns, two hex digits per byte. (at least one space between)
    Final column, cleaned up 16 characters, use '.' for not printable.
     
    Your output format should be something like this:
    
    ADDR   0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F  ASCII  printable
    0000  8D 36 25 7C B4 0E 8A 04  3C 00 74 05 CD 10 46 EB  .6%|....<.t...F.
    0010  F5 B4 00 CD 16 B8 40 00  8E D8 C7 06 72 00 00 00  ......@.....r...
    0020  EA 00 00 FF FF 57 65 6C  63 6F 6D 65 2C 20 49 20  .....Welcome, I 
    0030  68 61 76 65 20 63 6F 6E  74 72 6F 6C 20 6F 66 20  have control of 
    0040  74 68 65 20 63 6F 6D 70  75 74 65 72 2E 0D 0A 50  the computer...P
    0050  72 65 73 73 20 61 6E 79  20 6B 65 79 20 74 6F 20  ress any key to 
    0060  72 65 62 6F 6F 74 2E 0D  0A 28 61 66 74 65 72 20  reboot...(after 
    0070  72 65 6D 6F 76 69 6E 67  20 74 68 65 20 66 6C 6F  removing the flo
    0080  70 70 79 29 0D 0A 00 0F                           ppy)....        
    
    Hints:  "al" has four bits, add 48, compare to 57,
            if less or equal you have '0' to '9', else add 7,
            to get 'A' to 'F'
            Code sample:
                   mov  al,[edi]  ; get a byte
                   shr  al,4      ; get upper 4 bits
                   add  al,48     ; change to ASCII digit
                   cmp  al,57     ; '9'
                   jle  ovr
                   add  al,7      ; makes ASCII 'A' to 'F"
            ovr:                  ; 'al' now has a printable ASCII hex character
                                  ; store it or print it
    
                   mov  al,[edi]  ; get byte again
                   and  al,15     ; get lower 4 bits
                   add  al,48     ; change to ASCII digit
                   cmp  al,57     ; '9'
                   jle  ovr2
                   add  al,7      ; makes ASCII 'A' to 'F"
            ovr2:                 ; 'al' now has the next printable ASCII hex
                                  ; store it or print it
    
            Replace non printable characters with '.'
            compare with 32, if less then print '.'
            compare with 126, if more then print '.'
            else print character
            Code sample:
                   mov  al,[edi]  ; get a character
                   cmp  al,32     ; eliminate control characters
                   jge  pok
                   mov  al,'.'
            pok:   cmp  126       ; eliminate DEL and ant top bit
                   jle  uok
                   mov  al,'.'
            uok:                  ; now have printable character in 'al'
    
            Disk read: es is already zero, bx<-8000h, buffer
                       dl<-00h or 80h, drive 00h, 01h, 80h or 81h
                       dh<-0, head 0 to 15
                       ch<-0, track 0 to 255 (plus upper two bits of ch)
                       cl<-1, sector 1 to 128
                       ah<-02h, function code to read
                       int 13h, call BIOS disk services
    
    A sample bootable program is boot1.asm
    A more complete bootable program with hints for this project, is:
    bootreg.asm , but remove printer stuff!
    
    Only the first 512 byte sector is loaded by the BIOS at 7C00.
    Read your own remaining program into buffer 7E00, etc. 
    if your program is more that 512 bytes.
    
    (for this project, stay in the first 64K bytes, 0000 to FFFF,
     16 bit addresses with all segment registers set to zero)
    
    Change or create file name to boot.asm
    
    Compile using            nasm -f bin -o boot.bin boot.asm
    Write to floppy with     dd if=boot.bin of=/dev/fd0
    Shut down and reboot to execute
    
    If it runs to your satisfaction,
    
    Then    submit cs313_0101 proj3 boot.asm
    
    
    (If you have a printer connected to your parallel port,
     you might try INT 17h to see if you can print the same
     bytes that you sent to the display. int 17h replaces
     int 10h and you need a 'wait' loop. Add the FF, form feed.)
    
    
    For students using Microsoft Windows, you need to
    download   rawrite.exe  a Windows
    binary executable program. (Use "save link as" on the link)
    
    Run by typing just  rawrite
    Follow on screen instructions. (have boot.bin ready)
    
    
    For students without an Intel PC of their own:
    No UMBC OIT machine can be booted from a floppy drive,
    thus an alternate form of this project is allowed.
    
    You may read your binary executable program from the file
    system rather than from the floppy drive.
    
    For compiling:
         nasm -f elf -l boot.lst boot.asm
         gcc -o boot -nostartfiles -nostdlib boot.o
         ./boot
    
    The starter file that reads your own executable program is:
    boot.asm
    Use this code with the above commands.
    You have to program the hex dump output as shown above,
    see comments in the source code file  boot.asm  for more information.
    
    If it runs to your satisfaction,
    
    Then    submit cs313_0101 proj3 boot.asm
    
    

    Project 4, Digital Logic

    Use proj4.vhdl as the start of
    project 4. Everything has been provided to build and test a
    4-bit times 4-bit unsigned parallel multiply. In order to have
    less VHDL, a "madd4" entity was created. The multiplier can now
    be built from exactly four of the "madd4" entities.
    (Slightly different from multiplier used in the lecture.)
    
    The first "madd4" is in the file. You must code the three
    remaining "madd4" and code the "dot" merge of "cout" with
    the top three bits of the "sum", and the product bits "p".
    
    
    Notes: Each box is a  madd4  entity.
    
           The boxes should be labeled a0:, a1:, a2: and a3:.
    
           The  cout  signals are named  c(0), c(1), c(2) and c(3).
           The  sum   signals are named  s0, s1, s2, p(6 downto 3).
           The dot where three wires join the cout wire is
           coded in VHDL as  s0s <= c(0) & s0(3 downto 1);
    
           The  s0s  4-bit signal goes into the  madd4  'b' input.
           The first 'b' input must be four zero bits, signal zero4.
    
           The low order product bit, p(0) is the bottom bit
           of  s0  and is coded in VHDL as  p(0) <= s0(0);
    
    

    Using Cadence VHDL on GL machine

      First: You must have an account on a GL machine. Every student
             and faculty should have this.
             Either log in directly to linux.gl.umbc.edu or
             Use   ssh  linux.gl.umbc.edu
    
             Be in your login directory, else files must be changed.
             You can copy many sample files to your working directory using:
             cp /afs/umbc.edu/users/s/q/squire/pub/../download/cs411.tar  .
             There are many files available.
    
      Next:  Follow instructions exactly or you figure out a variation.
      1)     Get this tar file into your home directory (on /afs  i.e.
             available on all GL machines.)
             cs411.tar   and then type commands:
             cp /afs/umbc.edu/users/s/q/squire/pub/../download/cs411.tar  .
             tar -xvf cs411.tar
             cd vhdl
             mv Makefile.cadence Makefile
             source vhdl_cshrc
             make
             more add32_test.out
             make clean              # saves a lot of disk quota
    
             Then do your own thing with Makefile for other VHDL files
    
      2)     The manual, step by step method (same results as above)
             Be in your home directory.
             mkdir vhdl                 # for your source code  .vhdl  .vhd
             cd vhdl
             mkdir vhdl_lib             # your WORK library, keep hands off
             
             You now need to get the following 6 files into you  vhdl  directory:
             vhdl_cshrc
             cds.lib      change $HOME to your path if needed
             hdl.var
             Makefile.cadence    for first test
             add32_test.vhdl     for first test
             add32_test.run       for first test
    
    
             mv Makefile.cadence  Makefile
             # Run the test run:
             source  vhdl_cshrc
             make                        # should be no error messages
             more  add32_test.out        # it should have VHDL simulation output
             make clean
    
             You are on your own to write VHDL and modify the Makefile.
             Remember each time you log on:
             cd vhdl
             source vhdl_cshrc
             make                        # or do your own thing.
    
    Now work project 4:
      Run the following commands:
      cp /afs/umbc.edu/users/s/q/squire/pub/../download/proj4.vhdl  .
      cp /afs/umbc.edu/users/s/q/squire/pub/../download/proj4.run  .
      cp /afs/umbc.edu/users/s/q/squire/pub/../download/proj4.chk  .
      cp /afs/umbc.edu/users/s/q/squire/pub/../download/proj4.make  .
    
      You should get some results from the command
      make -f proj4.make
    
      Lots of "U" until you insert the VHDL for the project.
    
      Now, work the project.
    
      You do the submit,  submit cs313_0101 proj4 proj4.vhdl
      when the following command gives no difference in product values:
      diff -w proj4.out proj4.chk
    
    
    

    Project 5, Digital Logic

    Finish up the design and finish up the implementation
    of a maximal length shift register generator feeding
    a spin lock.
    
    You are given a starter VHDL file proj5.vhdl
    that has all the structure and entities and printout finished.
    You will be adding "signal" definitions after the line:
        signal one: std_logic := '1';
    
    You will be adding circuit VHDL statements after the line:
      xor1: x1 := a0 xor a1;
    
    The design of the shift register generator is:
    
    
    
    The input signals "one" "clear" and "clk" are defined in
    the starter file proj5.vhdl
    The signals a4, a3, a2, a1 and a0 are defined for the outputs
    of the D flip flops in the shift register generator.
    The signals x1 and x2 are available for outputs of the xor gates.
    
    The output signal "rcvr" is to be the input signal "rcvr"
    in the spin lock. The output signal from the spin lock "activate"
    has a signal declaration yet must be computed by the circuit
    that you design and implement in VHDL.
    
    The spin lock is given by
    
    
    If you use names A, B, C, D, E, F for the spin lock, there
    is debug print in proj5.vhdl that can be uncommented for testing.
    Initialize A to '1' using "clear" on the set input.
    Initialize all other D flip flops to '0' using "clear" on the reset input.
    The other set or reset gets the signal "one".
    Be sure to compute "activate" along with the Ain, Bin, etc.
    
    The entity dff1 that is used by the shift register generator
    and spin lock is ready to use in proj5.vhdl. The circuit symbol is:
    
    
    Your project is to finish the VHDL code for the shift register
    generator and design and code the digital logic circuit for
    the spin lock. See lecture notes Lect 23
    for method of converting a sequential circuit to digital logic.
    The lecture notes have legal VHDL statements, e.g Ain <= ... ; 
    
    Having the digital logic design, label the diagram with signal
    names of your choice, add the
            signal your-names: std_logic;
    lines into proj5.vhdl
    
    Code the digital logic in VHDL and add the VHDL statements
    into proj5.vhdl
    
      Run the following commands:
      cp /afs/umbc.edu/users/s/q/squire/pub/../download/proj5.vhdl  .
      cp /afs/umbc.edu/users/s/q/squire/pub/../download/proj5.run  .
      cp /afs/umbc.edu/users/s/q/squire/pub/../download/proj5.chk  .
      cp /afs/umbc.edu/users/s/q/squire/pub/../download/proj5.make  .
    
      You should get some results from the command
      make -f proj5.make
    
      Lots of "U" until you insert the VHDL for the project.
    
      Now work project 5.
    
      Your results should be the same as proj5.chk
      Check using the command:  diff -w proj5.out proj5.chk
    
      Then    submit cs313_0101 proj5 proj5.vhdl
    
    

    Files to download and other links

    Course links

    Go to top

    Last updated 4/28/04