CSc 343 Computer Organization and Programming
Fall Quarter 1997
Programming Assignment #1 (Due: 17 October 1997, Friday)

Assignment Objectives:

  1. To become familiar with Turbo Assembler and Turbo Debugger.
  2. To gain experience with several basic features of assembly lnaguage, including stack segment, data segment, and code segment; the DB, DW, .MODEL, .CODE, .DATA, .STACK and PROC directives; the MOV, ADD, SUB, DIV, and INT instructions.
  3. To write your first assembly language program.

Problem Description:

Write an assembler program that will compute the sum of N numbers which are internally defined in the data segment of your program as follows:

N     DW     8
NUMS  DW     25,15,35,10,10,55,45,25,50,50
and produce an output that looks like the following (centered on the screen):
    Name: Raj Sunderraman
    This program executed on 10/06/1997 at 15:10:32
    The input numbers are: 25,15,35,10,10,55,45,25
    The sum is:         220
The first line of the output should contain your name. The second line of the output should contain the date and time of execution of the program in the format indicated. You would have to obtain the system date and time to accomplish this. The third line of the output should contain the list of numbers (which are defined in the data segment). The final line of output should contain the sum of the numbers. Your program should work for any value of N. The output of your program should match, in every detail, the format illustrated above. Points will be deducted for any variation. The program should wait for user to press any key before terminating.

Submission Instructions: Electronically submit sum.asm and sum.exe by the deadline and submit program listing of sum.asm.

Hints:

  1. To assemble the program use the /l and /zi options and use the /v option while linking as follows:
    tasm /zi /l sum
    tlink /v sum
  2. To determine the system time and date use the DOS interrupt 21H as follows:
        MOV   AH,2CH ; get system time
        INT   21H
    After the interrupt, CH contains the hour (00 - 23), CL contains minutes (00 - 59) and DH contains seconds (00 - 59).
        MOV   AH,2AH ; get system date
        INT   21H
    After the interrupt, DH contains the month (01 - 12), DL contains day (01 - 31) and CX contains year (1980 - 2099).
  3. After getting the system date and time, you need to convert the various components from numeric to character form by extracting digits one by one, adding 30H to each (to convert to ASCII), and storing the resulting character in a buffer. To extract a digit from a number n, just divide n by 10; the remainder is n's rightmost digit.
  4. To divide a word by a byte, use the DIV instruction. For example,
      DIV  TEN
    would divide AX by 10 (assuming TEN has been declared as a byte containing 10). After the instruction has executed, AL will contain the quotient and AH will contain the remainder. Notice that the instruction does not mention a register, since division is always done in the AX register. Warning: Instructions such as
       DIV  10
    are rejected by the assembler.
  5. To print the information on the screen, use the DOS interrupt 21H as follows:
    MSG   DB  'Hello!','$'  ; message string to be displayed
                            ; notice dollar symbol at end.
       ...
       ...
       MOV   AH,09H  ; request display
       LEA   DX,MSG  ; load address of message
       INT   21H     ; DOS interrupt
  6. To clear the screen, use BIOS interrupt 10H as follows:
       MOV   AX,0600H ; AH 06 (scroll), AL 00 (full screen)
       MOV   BH,30    ; Attribute: color setting 
       MOV   CX,0000  ; upper left row:column
       MOV   DX,184FH ; lower right row=24,column=79
       INT   10H      ; interrupt call to BIOS
  7. To set the cursor at a particular location on screen use BIOS interrupt 10H as follows:
       MOV  DL,10   ; column 10
       MOV  DH,5    ; row 5
       MOV  BH,0    ; page 0
       MOV  AH,02H  ; request set cursor
       INT  10H     ; interrupt call to BIOS
  8. To wait for user to press any key before terminating use DOS interrupt 16H as follows:
       MOV   AH,10H
       INT   16H



Raj Sunderraman
Mon Oct 6 21:56:13 PDT 1997