neo3522
Programmer
- Nov 17, 2007
- 1
- 0
- 0
Hi here is my code I tried so hard and can't figure out the problem that I have. For the carriage I am trying to use cmp but I think that what I am trying to compare is wrong anybody to try to correct my code will be so nice.
Code:
TITLE MASM Template (main.asm)
COMMENT "
Write a program that reads a string of individual characters from the keyboard. The characters are stored in
a byte type (size) buffer 81 decimal bytes in length. The keyboard input can be terminated either when the buffer is full
(i.e., 81 characters have been entered) or when the user enters a carriage return character, whichever occurs first.
Use a loop, indirect addressing, the cmp instruction,and conditional jump instructions in your program.
Display a count of the total number of characters, excluding the carriage return, that were entered.
After displaying the count call the WaitMsg procedure. See page 146 in the text for usuage of WaitMsg
Submit a Source File, .asm extension, a listing file and an .exe file.
* Maintain a count of the number of lower case letters entered and the number of uppercase letters entered
* In addition to displaying a count of the total number of characters, display counts for the number
of lowercase characters and uppercase characters entered. (Your program should display three counts).
* After displaying each count pause exectution of the program by calling the WaitMsg procedure.
"
INCLUDE Irvine32.inc
CHARACTER_COUNT = 10
CR = 0Dh ;Carriage Return
.data
str1 BYTE "Enter a string:",0
str2 BYTE "End of the string:",0
str3 BYTE "No carriage found normal stop",0
carryOrEndArrayOfChar BYTE "End of the string of individual characters.",0
Chararray BYTE CHARACTER_COUNT+1 DUP(' ') ;81 bytes uninitialized
bufSize DWORD ?
.code
main PROC
mov edx, OFFSET str1 ; display Enter a String
call WriteString
;pushad
mov edx, OFFSET Chararray
mov ecx, LENGTHOF CHARACTER_COUNT
L1:
call WriteChar
call readChar
mov esi, Chararray
mov al, [esi]
inc esi
;mov ebx, 0dh
cmp al, 0Dh
je found
loop L1
call Crlf
;add ebx, 2
jmp notFound
found:
;movsx eax,WORD PTR [ebx]
mov edx, OFFSET carryOrEndArrayOfChar
call WriteString
jmp quit
notFound:
mov edx, OFFSET str3
call WriteString
jmp quit
quit:
call Crlf
call WaitMsg
exit
ret
exit
main ENDP
END main