×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problem wit assignment with jump instructions

Problem wit assignment with jump instructions

Problem wit assignment with jump instructions

(OP)
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
Replies continue below

Recommended for you

RE: Problem wit assignment with jump instructions

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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close