Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem wit assignment with jump instructions 1

Status
Not open for further replies.

neo3522

Programmer
Nov 17, 2007
1
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
 
Haven't read properly, but a few (probably misguided) thoughts:
(1) what is LENGTHOF doing? Charactercount is a value (10 in your case, but presumably due to become 80).
(2) think about which way mov al, [esi] works. Which is source and which is destination?
(3) when you call WriteChar for the first time, what is it going to write?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top