COP3402,  Fall 2000, Assignment 2

Due Tuesday 10/3 at the start of class

Upload two separate files: symbol table/flags, and the series program. Submitting homework on-line.

I want you to upload and print two things for this assignment. Upload each of the following, and hand in a printout of each.

  1. The typed version of questions 1  and 2. Do not upload word processor documents, be sure they are saved as text.
  2. The .ASM file for the program.

Short Answer (10 points)

  1. Consider the following data segment. Please don't use the debugger or masm to answer this question. Work the answer out for yourself. Of course, you can use the debugger or masm to check your work.
    	.data
    king	db	"Arthur",0dh,0ah,"$"
    dozen	=	12
    ports	dw	0cdh,0ab34h,34h
    base	equ	16
    total	dd	3 dup(0deh)
    
    
    1. (3 points) What would be the symbol table for this data segment?
    2. (3 points) What would be the contents of memory? Represent the contents of memory as a linear array of hex values.
  2. (4 points) Create the following program. Then debug the executable.
    		.model	small
    		.stack	100h
    		.data
    		.code
    main	proc
    		mov		ax,@data
    		mov		ds,ax
    
    		mov		ah,0
    		mov		bh,0
    		add		ah,7Dh	
    		add		ah,7Ch	;ah=   S=   C=   O=   Z=
    		add		ah,7 	;ah=   S=   C=   O=   Z=
    		add		ah,82h	;ah=   S=   C=   O=   Z=
    		add		ah,7Eh	;ah=   S=   C=   O=   Z=
    		
    		mov		ax,4c00h
    		int		21h
    main	endp
    		end		main
    

    Assuming the executable is named prog1.exe, then use this command to start the debugger:
    debug prog1.exe
    Then trace the program and verify that your answers are correct.
    Hand in the table indicating the value of ah and the four flags after each of the four indicated instructions is executed.

Programs (10 points)

Download the file ASM_IO.INC to the directory where your ASM file is. Add the following statement between the .code directive and the main proc directive.

	.code
include	ASM_IO.INC
main	proc

You can now print the value in AX as an unsigned number by the following call

call print_unsigned
  1. (10 points) Write a program that does the following. Make your output readable by printing spaces bewteen the numbers, and blank lines between the two series. Also display descriptions for each series in the output.
    1. Display on the screen a sequence of numbers that is equal to sum of the even numbers up to that point. Do not declare these values in the data segment, generate them using registers and a loop. The range is from 1 - 156, shown here in decimal
      	2 6 12 20 30 42 56 72 90 110 132 156 
    2. Display on the screen the well-known Fibonacci number series. Each number in the series after the number 1 is the sum of the previous two numbers:

      1 1 2 3 5 8 13 21 34 55 ...

      Generate and display the first 24 numbers in the Fibonacci series, beginning with 1 and ending with 46,368. Do not declare these values in the data segment, generate them using registers and a loop. Display 8 Fibonacci numbers per line. Hint: Use three separate loops, one for each line of Fibonacci numbers.