1 Replies - 2124 Views - Last Post: 16 November 2012 - 05:57 AM

#1 StNtMaN  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 09-December 11

Pep/8 Input Count Flip Program Issue

Posted 15 November 2012 - 08:55 PM

Create a program that will input a sentence and push each character onto the stack all the while counting the number of characters. Then pop off each character and print them backwards (natural with a stack) and print the length. Like so:

I like burgers!

!sregrub ekil I

The number of characters is 15

Note, don't count the '\n' nor push it onto the stack. The stack should be empty when finished. Use an ".equate" to define a label to reference the top of the stack (can be any name but when you pop off the character, you need to use that label defined by the equate).

Note: Do NOT have a branch at the top like with the textbook examples. Place your data and the END of the program (before ".END") and have your program start at location 0 (WITHOUT the first branch). I'll ding you a point if you do.

Here is what I have so far...


ch:       .equate  1
count:   .equate   2
tos:     .equate   3
count2:  .equate   4
         lda      0,i 
         chari    ch,d 
         ldbytea  ch,d
for:     cpa      '\n',i
         breq    count  
         stbytea  -1,s
         subsp    1,i
         lda      count,d 
         adda     1,i
         sta      count,d

         charo    tos,s 
         addsp    1,s
         lda      count2,d 
         suba     1,i
         sta      count2,d
         stop
         .end


I really don't have much expertise with assembly and pep/8. Any help would be appreciated! Thanks!

Is This A Good Question/Topic? 1
  • +

Replies To: Pep/8 Input Count Flip Program Issue

#2 turboscrew  Icon User is offline

  • D.I.C Addict

Reputation: 100
  • View blog
  • Posts: 615
  • Joined: 03-April 12

Re: Pep/8 Input Count Flip Program Issue

Posted 16 November 2012 - 05:57 AM

Pep/8 is news to me.
Thanks for bringing it up.

Does your code really start from 0?
So where is "ch" located?

Where is this supposed to branch to?
breq count
Into the middle of the first instruction?

Any idea where I could find some description of the architecture and assembly
of this Pep/8?
Google only found some small fragments.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1