[CMPE 310 Home] | [Syllabus] | [Homework] | [Projects] | [Labs] | [Lecture Notes] | [Printable all notes] | [Files] | [NASM resource] |

CMPE 310 Projects

Contents

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

     The project is to be submitted on  linux.gl.umbc.edu  as 
       submit cmpe310 proj1 convert.asm
       submit cmpe310 proj2 math_64.asm
       submit cmpe310 proj3 plotc_64.asm
              cmpe310 proj4 run CIS in lab
              cmpe310 proj5 run Allegro in lab
       submit cmpe310 proj6 or paper or email
              cmpe310 proj7 demo in lab
    
     To see what is submitted
       submitls cmpe310 proj1
    
     To delete a file that was submitted
       submitrm cmpe310 proj1 convert.asm
    
     Once graded by automation, not graded again.
    
    

    Getting Started

    Using UMBC computer linux.gl.umbc.edu or Lab ITE 375

    From anywhere you can reach the internet:
    
      ssh  your-username@linux.gl.umbc.edu  # or use putty, etc.
      your-password
    
    

    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_64.asm"
    might be helpful.
    
    You start with two constants in the  .data  section
    
    dec1:  db  '1','2','6','.','3','7','5',0
    bin1:  dq  01010110110111B ; 10101101.10111 note where binary point should be
    
    You convert dec1 to a string of characters that is
    the binary representation of 126.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.10111.
    Print your characters (string) with printf or a kernel call.
    
    You may use any method of your choice, and you may print results
    as four numbers: '1','2','6' as 1's and 0's, binary.
    '.','3','7','5' as '.' 1's and 0's binary.
    010101101 as a decimal number, integer
    .10111 as a decimal number, .dddd decimal fraction.
    
    
    submit your file, when it is working correctly,
      submit cmpe310 proj1 convert.asm
    
    Your file must assemble with no errors and execute
    with the commands:
    
       nasm -f elf64 convert.asm  # or add to Makefile_nasm1
       gcc -m64 -o convert  convert.o
       ./convert                  # ./ needed if '.' not first in PATH
    
    Then   submit cmpe310 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'.
    
    '1','2','6' is 1*100 + 2*20 + 6 = 126, binary in a register.
    
    See horner_64.asm for sample loops.
    and loopint_64.asm another sample.
    You do not have to use loops, you can solve just specific problem.
    
    It is OK to process and print one character or digit at a time.
    A snippet of sample code for printing in Nasm:
    
    dec1:	  db  '1','2','6','.','3','7','5', 0
    fmt_char: db "%c",0		; no '\n' thus no 10
    fmt_dig:  db "%1ld",0           ; print just one digit, e.g. 0 or 1
    fmt_end:  db 10, 0              ; just end line
    	
    	mov	rdi,fmt_char	; print a single character
    	mov	al, [dec1]	; byte into bottom of rax
    	mov	rsi, rax	; must go 64-bit to 64-bit
    	mov	rax, 0		; no float
            call    printf
    	
    	mov	rdi,fmt_dig	; print a single character as digit
            mov     rax, 0          ; be safe, zero all rax
    	mov	al, [dec1+1]	; next byte into bottom of rax
    	sub	rax, 48		; change character digit to number
    ;       imul    rax, 10         ; '2' is 20  need to add up 1*100+2*10+4
    	mov	rsi, rax	; must go 64-bit to 64-bit
    	mov	rax, 0		; no float
            call    printf
    
    	mov	rdi,fmt_end	; print end of line
    	mov	rax, 0		; no float
            call    printf
    
    Note:   and     rax,1           ; print with %1ld, prints bottom bit as 0 or 1
                                    ; shr  rax  to get the bit you want
    
    
    Hint, C code, for converting .375 to .011
    frac_bin.c
    frac_bin.out
    Beware rounding when storing double as integer.
    May need  fld, fld, compp  as in ifflt_64.asm
    
    
    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
    
      
    

    Project 2, Convert "C" math code to NASM

    Write and submit NASM assembly language functions
    that implement the given "C" functions in math_64.c
    The main program test_math_64.c
    that does not know how the functions are implemented.
    
    The program you code in NASM is math_64.c
    The .h file with function prototypes is math_64.h
    Your correct output should be test_math_64.chk
    
    Note: There is zero credit when  math_64.asm  does not compile without errors.
    
    Your file must assemble with no errors and execute on linux.gl.umbc.edu
    with the commands:
    
       nasm -g -f elf64  math_64.asm  
       gcc -g3 -m64 -o test_math_64 test_math_64.c  math_64.o
       ./test_math_64 > test_math_64.out
       cat test_math_64.out
    
    Then    submit cmpe310 proj2 math_64.asm
    
    For debugging due to segfault:
        gdb test_math_64
        break main
        run
        step
        step  keep stepping until segfault, thus see where you have a bug
    
        nexti  use in place of   step   to step one instruction at a time
    
    
    

    Your project is to convert math_64.c to math_64.asm

    You may use pre_math_64.asm renamed to math_64.asm as a start. Compile and run to be sure compilation and execution are working, then add project code. All referenced files may be copied to your directory using: Replace xxx.x with the file you want. cp /afs/umbc.edu/users/s/q/squire/pub/download/xxx.x . Read and understand code in fltarith_64.asm e.g. mov rax, [x] ; address of callers x array in rax fld qword [rax] ; to get first floating point value 2.0 fmul qword [rax+8] ; to multiply by floating point 3.0 fstp qword [sum] ; to save sum locally

    Project 3, plot cos(x)

    
    You are to write a program that does not use "C" functions or libraries.
    This project is based on lecture 8.
    
    You may use system calls or BIOS calls from Lecture 9 to implement the program.
    See hellos_64.asm for compiling, _start
    
    To compile and run your program, use:
    nasm -f elf64 plotc_64.asm
    ld -o plotc_64 plotc_64.o
    ./plotc_64
    
    You only need to print one character at a time, rdx, 1 in syscall.
    Print 10, '\n' at end of each line.
    Or, add one column filled with  10, and print lines=rows.
    
    Your program is to make a simple character plot of  cos(x)
    for x from -Pi to Pi, -3.14159 to 3.14159 in 41 steps, dx = 0.15708
    
    Use 21 rows, middle row for cos(0.0) = 1.0,
    top row for cos(Pi/2) = 0.0, bottom row for cos(-Pi)=cos(Pi) = -1.0
    For each column plotting an '*' at  row k = int(20.0 - (y+1)*10.0)
    
    
    A very small version of the plot would look like:
          *                     9 columns, 7 rows
         * * 
       
        *   *  
     
       *     *
      *       *
    
    Compute cos(x) in your program  y = cos(x) =
    1 - x^2/2! + x^4/4! - x6^/6! + x^8/8!
    OK to use code from horner_64.asm float
    af: dq 1.0, 0.0, -0.5, 0.0, 0.041667, 0.0, -0.001389, 0.0. 0.000025 
    N:  dq 8
    XF: x=0, x=x+dx   dx = 0.15708 
    This computes YF = cos(XF)
    	mov	rcx,[N]		; loop iteration count initialization, n
    	fld	qword [af+8*rcx]; accumulate value here, get coefficient a_n
    h5loop:	fmul	qword [XF]	; * XF
    	fadd	qword [af+8*rcx-8] ; + aa_n-i
    	loop	h5loop		; decrement rcx, jump on non zero
    	fstp	qword [Y]	; store Y
    
    Then compute kf = 20.0 - (Y+1.0)*10.0  floating point
    Then store k as integer:   fistp  qword [k]
    Then compute double subscript, integer, k*ncol+j  in rax
    Then store star:
          mov  bl, [star]
          mov  [a2+rax], bl  
    
    Note: For printing  mov  rsi, rax // syscall (rcx for  int) 
                        add  rsi, a2  // not [a2+rax] need address
    
    If it runs to your satisfaction,
    Then    submit cmpe310 proj3 plotc_64.asm
    
    The program in "C" is 
    See plotc_64.c for possible method
    See plotc_64.outc "C" output
    See plotc_64.chk Nasm output
    See hornerc_64.asm for computing cos(x)
    
    // plotc_64.c  simple plot of cos(x)
     #include <stdio.h>>
    
     #define ncol 41
     #define nrow 21
     int main(int argc, char *srgv[])
     {
       char points[nrow][ncol]; // char == byte
       char point = '*';
       char space = ' ';
       long int i, j, k;
       double af[] = {1.0, 0.0, -0.5, 0.0,
                      0.041667, 0.0, -0.001389, 0.0, 0.000025};
       long int n = 8;
       double x, y;
       double dx = 0.15708; // 6.2832/40.0
    
       // clear points to space ' '
       for(i=0; i=0; i--) y = y*x + af[i];
         k = 20 - (y+1.0)*10.0; // scale 1.0 to -1.0, 0 to 20
         printf("x=%f, y=%f, k=%d \n", x, y, k);
         fflush(stdout);
    
         points[k][j] = point;
         x = x + dx;
       }
    
       // print points
       for(i=0; iNasm code for loops to clear and print array of characters
    
    array2_64.asm sample code
    array2_64.out output
    
    snippet of code, double loop, to clear array
    (ultra conservative, keeping i and j in memory)
    
    These 3 lines of "C" code become many lines of assembly
       // clear points to space ' '
       for(i=0; i<nrow; i++)
         for(j=0; j<ncol; j++)
           points[i][j] = space;
    
    	
    	section .bss            ; ncol=7, nrow=5 for demo
    a2:	resb 	21*41		; two dimensional array of bytes
    i:	resq 	1		; row subscript
    j:	resq 	1 		; col subscript
    k:      resq    1               ; row subscript computed
    
            SECTION .text           ; Code section. just snippet
    
    ; clear a2 to space
    	mov 	rax,0		; i=0  for(i=0;
    	mov	[i],rax
    loopi:
    	mov	rax,[i]         ; reload i, rax may be used
    	mov 	rbx,0		; j=0  for(j=0;
    	mov	[j],rbx
    loopj:
    	mov	rax,[i]         ; reload i, rax may be used
    	mov	rbx,[j]         ; reload j, rbx may be used
    	imul 	rax,[ncol]	; i*ncol
    	add  	rax, rbx	; i*ncol + j
    	mov 	dl, [spc]	; need just character, byte
    	mov 	[a2+rax],dl	; store space
    
    	mov	rbx,[j]
    	inc 	rbx		; j++
    	mov	[j],rbx
    	cmp 	rbx,[ncol]      ; j<ncol
    	jne 	loopj
    
    	mov	rax,[i]
    	inc 	rax		; i++
    	mov	[i],rax
    	cmp	rax,[nrow]	; i<ncol
    	jne 	loopi
    ; end clear a2 to space
    
            ; j = 0;
            ; xf = X0;
    
    From horner_64.asm  use
    
    cos:	mov	rcx,[N]		; loop iteration count initialization, n
    	fld	qword [af+8*rcx]; accumulate value here, get coefficient a_n
    h5loop:	fmul	qword [XF]	; * XF
    	fadd	qword [af+8*rcx-8] ; + aa_n-i
    	loop	h5loop		; decrement rcx, jump on non zero
    	fstp	qword [Y]	; store Y
    
            ; k = 20.0 *(Y+1.0)*(-10.0)  fistp qword [k]
            ; rax  gets  k * ncol + j
            ; put "*" in dl, then dl into [a2+rax]
    
            ; XF = XF + DX0;
            ; j = j+1;
            ; if(j != ncol) go to cos
    
            ; copy clear a2 to space
            ; in jloop renamed, use  syscall print from hellos_64.asm
            ; add rax,a2   replaces  dl stuff
            ; mov rsi, rax (moved up) replaces  mov rsi, msg
            ; replace any  len  with  1 
    
            ; after jloop insert line feed  lf: db  10
            ; mov rsi, lf  in lpace of mov  rsi, rax
    
            ; use  exit code from  hellos_64.asm
            ; no push or pop  rbx
    
    in  .data  
    af:	dq	1.0, 0.0, -0.5  ; coefficients of polynomial, a_0 first
    	dq	0.0, 0.041667, 0.0, -0.001389, 0.0, 0.000025
    XF:	dq	0.0		; computed
    Y:	dq	0.0		; computed
    N:	dq	8		; power of polynomial
    X0:	dq	-3.14159	; start XF
    DX0:	dq	0.15708		; increment for XF  ncol-1  times
    one:    dq      1.0
    nten:   dq      -10.0
    twenty  dq      20.0
    
    
    Your  plotc_64.asm  can not use printf or any "C" functions.
    Thus you use   global _start   and  _start:  in place of
                   global main     and  main:
    
    ; compile using   nasm -g -f elf64 plotc_64.asm
    ;                 ld -o plotc_64  plotc_64.o        # not  gcc
    ;                 ./plotc_64  >  plotc_64.out
    ;                 cat  plotc_64.out
    
    
    
    
    
    
    
    

    Project 4, LAB

    This is an individual project. TA's will be here to help.
    9 components to place
    
    You are to place an 8086    processor
            place three LS373   latches
             place two  LS245   transceivers
             place two  CY7C199 RAM
               and one  8255    interface
    
    connect power VCC and ground GND. 
    Unused terminals get NC, not connected.
    Optional, yet useful, chrystal and clock circuits
    
    See Lecture 17, slides 1, 2, 3 and
    see textbook Page 314 hard copy, Page 333 web .pdf
    Connect 8086 to 373 and 245 as shown:
    
                                373             199
    One   CY7C199 connects   A1 .. A15  to  A0  .. A14 
                                245             199
              and connects   D0 .. D7   to  IO0 .. IO7 even byte
                                373             199
    other CY7C199 connects   A1 .. A15  to  A0  .. A14
                                245             199 
              and connects   D8 .. D15  to  IO0 .. IO7  odd byte
    
              and BHE, RD, WR, MIO etc
    
    OK to skip 244, just straight through
    
    8255 see data sheet and book page 397
    Just port A and B needed.
    
    Project 4 is complete when you have the net list.
    
    We will not be making the board.
    
    Step 1: Use cadence CIS capture application
    
    

    CIS capture application

    Cadence capture CIS

    Cadence CIS

    8086 chip lecture

    See slide 2 and slide 13

    8086 package

    CY7C199 SRAM package

    8255 interface package

    74LS373 latch (2)

    74LS245 octal bus

    Page 314 in textbook page 333 on 8086 web .pdf Use CIS to place components and connect pins The last step is to output the net list

    Project 5, LAB
    
    Step 2: Use Allegro application
    
    

    8086_footprints_allegro.pdf

    8086_footprints_allegro.zip

    Board layout application

    Allegro PCB Designer

    8086 package

    CY7C199 SRAM package

    8255 interface package

    74LS373 latch (2)

    74LS245 octal bus

    data sheets

    Project 6, LAB

    Do writeup on Project 5 and project 6
    This can be submitted electronically as a .pdf or on paper.
    Include screen shots of CIS and Allegro results.
    
    Typical lab report:
      Objective
      Plan
        Tasks
        Tools
      Results
    
    
    
    
    
    

    Project 7, LAB

    Big change! 11/25/15

    project1_Statement.docx

    SampleCode.asm

    Toturial_umbc_8086.pdf

    trainer_board_compile_tutorial.pdf

    use scp to copy UMBC-8086.zip to Downloads

    from /afs/umbc.edu/users/s/q/squire/download/UMBC-8086.zip download into PC Downloads then 7 zip unzip this file. Have your proj7.asm in Downloads before using DosBox. Print any 2 numbers and their sum on the board display in lab. e.g - Say, you have chosen 3 and 5 compute sum 8 You should write an assembly language program to display following on the display -  First Number : 3, Second Number : 5 Addition : 8 (Remember, having a binary number, for example 8, in AL, add AL,48 to make it a character for printing. More complicated to do conversion if other than 1 to 9.) OK to start by editing Part1.asm ; Part1.asm not for NASM ; Make the LCD display my name BITS 16 CPU 8086 section CONSTSEG USE16 ALIGN=16 CLASS=CONST Data: myName: db " my name " nameLen: equ $ - myName section PROGRAM USE16 ALIGN=16 CLASS=CODE ..start name: mov ax, 1 ; code for display mov bx, myName ; string address mov cx, nameLen ; string length mov dx, 0 ; code mov si, ds ; address space int 10H ; call BIOS Remember: Be sure to give your-user-id and password twice when logging in. Click on gl.umbc.edu you should be able to see your GL files Running assembler in DosBox (Very different from NASM) all programs DosBox v0.74 mount D "C:\users\your-user-id\Downloads" D: run.dat part1 (already there part1.asm is test code no errors) run.dat proj7 Notepad proj7.hex to check assembled

    Files to download and other links

    Course links

    Go to top

    Last updated 12/4/2015