CSc 343
Computer Organization and Programming
Spring Quarter 1998
Programming Assignment #1 (Due: 24 April 1998, Friday)
Assignment Objectives:
Problem Description:
Write an assembler program that will compute the number of vowels, consonants and spaces in a sentence stored in a string which is internally defined in the data segment of your program as follows:
SENTENCE DB 'I hope to finish this assignment in time so that I do ' DB 'not get a late penalty for this assignment.'You may assume that the sentence contains only vowels, consonants and spaces and always ends with a period. The period is not used in any of the counts. The sentence may be big enough that it may not fit in one line as shown in the example. Your program should work for any sentence that is defined in the data segment of your program. The output of the program should look like the following (centered on the screen):
Name: Raj Sunderraman This program executed on 10/06/1997 at 15:10:32 16 x Number of vowels = 464 16 x Number of consonants = 768 16 x Number of spaces = 304 16 x Total sentence length = 1536The 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 remaining lines of the output should appear exactly as shown (except for the answers, which would be different depending on the time you ran your program and the sentence you include in the data segment). 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 count.asm and count.exe by the deadline and submit a hard copy printout of the program listing of count.asm.
Hints:
tasm /zi /l sum tlink /v sum
MOV AH,2CH ; get system time INT 21HAfter 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 21HAfter the interrupt, DH contains the month (01 - 12), DL contains day (01 - 31) and CX contains year (1980 - 2099).
DIV TENwould 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 10are rejected by the assembler.
MOV CL,04H SHL AX,CLThe contents of AX register are multiplied by 16.
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
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
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
MOV AH,10H INT 16H