Dmitriy78 0 Newbie Poster
;Dmitriy Potemkin 816 Assignment 3
      BR      main        
retVal:  .Equate 2

printMes:STRO    msg1,d      
         CHARO   '\n',i
         STRO    msg2,d      
         CHARO   '\n',i     
         STRO    msg3,d      
         CHARO   '\n',i
         STRO    msg4,d
         CHARO   '\n',i  
         DECI   retVal,s
         RET0
;*******************************************************************  second procedure
str1:    .Equate 0
rett2:   .Equate 3
max2:    .Equate 5
sent2:   .Equate 7
retVal2: .Equate 9

secPro:  SUBSP   1,i
         LDA     rett2,s
         CPA     1,i
         BREQ    c1
         LDA     rett2,s
         CPA     2,i
         BREQ    c2
         LDA     rett2,s
         CPA     3,i
         BREQ    c3
         LDA     rett2,s
         CPA     4,i
         BREQ    c4


c1:      STRO    msgIn,d
         LDA     0,i
         STA     retVal2,s
         CHARO   '\n',i      ;This part is present in every procedure, just to see what has been passed to the procedure.
         CHARO   sent2,s
         CHARO   '\n',i
         DECO    rett2,s
         CHARO   '\n',i
         DECO    max2,s
         CHARO   '\n',i
while:   CHARI   str1,s
         LDBYTEA str1,s
         CPA     sent2,s
         BREQ    ender
         LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         LDA     retVal2,s   ;Here we check if the number of chars entered is at the max or more, if yes then it returns the maximum number.
         CPA     max2,s
         BRGE    ender
         br      while

c2:      STRO    msgIn,d
         LDA     0,i
         STA     retVal2,s
         CHARO   '\n',i
         CHARO   sent2,s
         CHARO   '\n',i
         DECO    rett2,s
         CHARO   '\n',i
         DECO    max2,s
         CHARO   '\n',i
while1:  CHARI   str1,s
         LDBYTEA str1,s
         STA     str1,s
         LDBYTEA str1,s
         CPA     sent2,s
         BREQ    ender
         LDBYTEA str1,s
         CPA     'a',i
         BREQ    ca
         CPA     'e',i
         BREQ    ce
         CPA     'i',i
         BREQ    ci
         CPA     'o',i
         BREQ    co
         CPA     'u',i
         BREQ    cu
ca:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         br      while1
ce:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         br      while1
ci:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         br      while1
co:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         br      while1
cu:      LDA     retVal2,s
         ADDA    1,i
         STA     retVal2,s
         LDA     retVal2,s
         CPA     max2,s
         BRGE    ender
         br      while1

c3:      STRO    msgIn,d
         LDA     0,i
         STA     retVal2,s
         CHARO   '\n',i
         CHARO   sent2,s
         CHARO   '\n',i
         DECO    rett2,s
         CHARO   '\n',i
         DECO    max2,s
         CHARO   '\n',i 
while3:  CHARI   str1,s
         LDBYTEA str1,s
         STA     str1,s
         LDBYTEA str1,s
         CPA     sent2,s
         BREQ    ender
         LDA     str1,s
         CPA     'a',i
         BREQ    while3
         LDA     str1,s
         CPA     'e',i
         BREQ    while3
         LDA     str1,s
         CPA     'i',i
         BREQ    while3
         LDA     str1,s
         CPA     'o',i
         BREQ    while3
         LDA     str1,s
         CPA     'u',i
         BREQ    while3
         LDA     retVal2,s
         adda    1,i
         STA     retVal2,s
         LDA     retVal2,s
         CPA     max2,s
         BRGE    ender
         br      while3

c4:      STRO    msgIn,d          
         LDA     0,i
         STA     retVal2,s
         CHARO   '\n',i
         CHARO   sent2,s
         CHARO   '\n',i
         DECO    rett2,s
         CHARO   '\n',i
         DECO    max2,s
         CHARO   '\n',i
while4:  CHARI   str1,s      
         LDBYTEA str1,s
         CPA     'z',i
         BRGT    ender
         LDBYTEA str1,s
         CPA     'A',i
         BRLT    ender
         LDA     retVal2,s
         adda    1,i
         STA     retVal2,s
         LDA     retVal2,s
         CPA     max2,s
         BRGE    ender
         br      while4


ender:   CHARO   'E',i       ;prints out end and returns to main procedure where the number of chars is printed
         CHARO   'n',i
         CHARO   'd',i
         CHARO   '\n',i
         RET1    



;*******************************************************************  main
sent1:   .EQUATE 0
max1:    .Equate 1
returned:.Equate 3
junk:    .Equate 5

main:    subsp   5,i
         STRO    msgEnd,d
         CHARI   sent1,s
         CHARI   junk,s
         STRO    msgLim,d
         DECI    max1,s
         subsp   2,i ;for return value and parameters only.
         CALL    printMes
         addsp   2,i
         LDA     -2,s
         STA     returned,s

         LDA     returned,s
         STA     -7,s

         LDA     max1,s
         STA     -5,s

         LDBYTEA sent1,s
         STBYTEA -3,s

         subsp   7,i
         CALL    secPro
         addsp   7,i

         LDA     -1,s
         STA     returned,s
         DECO    returned,s

         addsp   5,i


         STOP     

msgTotal:.ASCII  "The total number of Chars is. \x00"           
msgIn:   .ASCII  "Input your sentence. \x00"
msgEnd:  .ASCII  "Enter the sentinel character to use. \x00"
msgLim:  .ASCII  "Enter the max amount of characters to use. \x00"
msg1:    .ASCII  "1. Total number of characters\x00"     
msg2:    .ASCII  "2. Number of vowels\x00"    
msg3:    .ASCII  "3. Number of consonents\x00"   
msg4:    .ASCII  "4. Number of non-alphabetic characters\x00"   

         .END      

This program is supposed to take in a sentinel character and a maximum number of characters and then choose one of 4 options (counting the vowels, consonents, etc.). Whenever it starts counting though in "secPro:" it enters an endless loop where it compares the input character to god knows what (the value in the accumulator is odd). Please help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.