Jump to content
IGNORED

Assembly code samples


GDMike

Recommended Posts

On 6/30/2020 at 10:15 PM, HOME AUTOMATION said:

       AORG >CBD4           *DELETE
TEST   TEXT 'COMEFINDMEBRO' *DEL
       AORG >7D00           *DEL
QUERI  TEXT 'COMEFINDMEBRO' *SET THIS LINE UP IN YOUR PROGRAM, DELETE FROM HERE
       DATA 0               *THIS SHOULD FOLLOW YOUR BUFFER SPACE, DELETE FROM HERE
VALID  DATA 0
ENTRY  LI   R4,>A000        *SET THIS VALUE UP IN YOUR PROGRAM, DELETE FROM HERE
       LI   R6,>0000        *SET THIS VALUE UP IN YOUR PROGRAM, DELETE FROM HERE
SEARCH LI   R3,QUERI        *THIS IS THE LINE TO BL TO!
CMPARE CB   *R3,*R4+
       JEQ  NEXT
       C    R4,R6
       JNE  CMPARE
OUTNO  RT
NEXT   MOV  R4,R5
CONT   CB   *R3,@VALID
       JEQ  OUTYES
       C    R4,R6
       JEQ  OUTNO
       INC  R3
       CB   *R3,*R4+
       JEQ  CONT
RESTAR MOV  R5,R4
       JMP  SEARCH
OUTYES MOV  R5,R4
       DEC  R4
       RT
       END

Here, I removed the testing lines for you. I hope I did it right.

VALID  DATA 0
SEARCH LI   R3,QUERI        *THIS IS THE LINE TO BL TO!
CMPARE CB   *R3,*R4+
       JEQ  NEXT
       C    R4,R6
       JNE  CMPARE
OUTNO  RT
NEXT   MOV  R4,R5
CONT   CB   *R3,@VALID
       JEQ  OUTYES
       C    R4,R6
       JEQ  OUTNO
       INC  R3
       CB   *R3,*R4+
       JEQ  CONT
RESTAR MOV  R5,R4
       JMP  SEARCH
OUTYES MOV  R5,R4
       DEC  R4
       RT
       END


Set up a buffer labeled QUERI, make sure to fill it with all zeros, before overlaying your search term.

This buffer should have an extra 1 or 2 zeros after it's max. length! This will indicate the search completed successfully, when found by my program.

 

R4=Where to start searching from.
R6=Where to stop searching.

BL @SEARCH

 

This should find the first occurrence, before returning to your program.


R4 will be set to the starting address of the found term.

or

R4 will be equal to R6 if nothing was found.


 Adding the length of the search term to R4, then BL-ing back to SEARCH, should allow you to find the next occurrence.

 

Good luck, you might need it.

:)
 

  EDIT:

 

I hope these comments make more sense to you, than they do to me!:lol:

 


VALID  DATA 0               TERM FOUND, COMPARATOR.
SEARCH LI   R3,QUERI        R3=SEARCH TERM'S ADDRESS. *THIS IS THE ENTRY ADDRESS!
CMPARE CB   *R3,*R4+        COMPARE 1st LETTER OF SEARCH TERM, TO THE LETTERS IN THE SPECIFIED RANGE, ONE LETTER AT A TIME.
       JEQ  NEXT            DO THEY MATCH? YES! CHECK IF SECOND LETTERS MATCH. NO! CONTINUE.
       C    R4,R6           HAVE WE REACHED THE END OF THE SEARCH RANGE YET?
       JNE  CMPARE          NO! CHECK NEXT LETTER IN THE SPECIFIED RANGE. YES! CONTINUE.
OUTNO  RT                   BYE, NOTHING FOUND.
NEXT   MOV  R4,R5           SAVE THE POSITION OF THE NEXT POSSIBLE FIRST LETTER MATCH ...TO RESTART FROM IN CASE THE SECOND LETTER DOESN'T MATCH, OR TO INDICATE WHERE AN OCCURRENCE WAS FOUND LATER.
CONT   CB   *R3,@VALID      HAVE WE ALREADY MATCHED ALL CHARACTERS?
       JEQ  OUTYES          YES! MATCH FOUND! NO! CONTINUE.
       C    R4,R6           HAVE WE REACHED THE END OF THE SEARCH RANGE YET?
       JEQ  OUTNO           YES! EXIT(NO OCCURRENCE(S)) FOUND. NO! CONTINUE.
       INC  R3              ADVANCE TO THE NEXT LETTER OF THE SEARCH TERM.
       CB   *R3,*R4+        COMPARE ADDITIONAL LETTERS, ONE AT A TIME.
       JEQ  CONT            YES! CHECK 3RD AND UP, LETTERS. IF A LETTER DOESN'T MATCH, CONTINUE.
RESTAR MOV  R5,R4           RESTORE NEXT POSSIBLE FIRST LETTER MATCH ADDRESS.
       JMP  SEARCH          KEEP SEARCHING FOR NEXT FIRST LETTER MATCH.
OUTYES MOV  R5,R4           RETRIEVE POSITION OF THE PREVIOUS NEXT POSSIBLE FIRST LETTER MATCH.
       DEC  R4              SET R4 TO THE POSITION OF THE FIRST CHARACTER OF THE MATCHED TERM.
       RT                   OCCURRENCE FOUND
       END                  FEELS SO GOOD!

:)

I'm going back, back to this code and I'll try to adapt it. 

I gave my own code a try and had good results, but too good, apparently. Because I would find words like, seven when seven didn't exist, but the word even was there in my page that I was searching and so I was picking up words that had similar characters.

I found all the words I was searching for, but I can't seem to shake the errors like above mentioned.

So im going to try to adapt your sweet code again.

 

Edited by GDMike
Link to comment
Share on other sites

On 6/30/2020 at 10:15 PM, HOME AUTOMATION said:

       AORG >CBD4           *DELETE
TEST   TEXT 'COMEFINDMEBRO' *DEL
       AORG >7D00           *DEL
QUERI  TEXT 'COMEFINDMEBRO' *SET THIS LINE UP IN YOUR PROGRAM, DELETE FROM HERE
       DATA 0               *THIS SHOULD FOLLOW YOUR BUFFER SPACE, DELETE FROM HERE
VALID  DATA 0
ENTRY  LI   R4,>A000        *SET THIS VALUE UP IN YOUR PROGRAM, DELETE FROM HERE
       LI   R6,>0000        *SET THIS VALUE UP IN YOUR PROGRAM, DELETE FROM HERE
SEARCH LI   R3,QUERI        *THIS IS THE LINE TO BL TO!
CMPARE CB   *R3,*R4+
       JEQ  NEXT
       C    R4,R6
       JNE  CMPARE
OUTNO  RT
NEXT   MOV  R4,R5
CONT   CB   *R3,@VALID
       JEQ  OUTYES
       C    R4,R6
       JEQ  OUTNO
       INC  R3
       CB   *R3,*R4+
       JEQ  CONT
RESTAR MOV  R5,R4
       JMP  SEARCH
OUTYES MOV  R5,R4
       DEC  R4
       RT
       END

Here, I removed the testing lines for you. I hope I did it right.

VALID  DATA 0
SEARCH LI   R3,QUERI        *THIS IS THE LINE TO BL TO!
CMPARE CB   *R3,*R4+
       JEQ  NEXT
       C    R4,R6
       JNE  CMPARE
OUTNO  RT
NEXT   MOV  R4,R5
CONT   CB   *R3,@VALID
       JEQ  OUTYES
       C    R4,R6
       JEQ  OUTNO
       INC  R3
       CB   *R3,*R4+
       JEQ  CONT
RESTAR MOV  R5,R4
       JMP  SEARCH
OUTYES MOV  R5,R4
       DEC  R4
       RT
       END


Set up a buffer labeled QUERI, make sure to fill it with all zeros, before overlaying your search term.

This buffer should have an extra 1 or 2 zeros after it's max. length! This will indicate the search completed successfully, when found by my program.

 

R4=Where to start searching from.
R6=Where to stop searching.

BL @SEARCH

 

This should find the first occurrence, before returning to your program.


R4 will be set to the starting address of the found term.

or

R4 will be equal to R6 if nothing was found.


 Adding the length of the search term to R4, then BL-ing back to SEARCH, should allow you to find the next occurrence.

 

Good luck, you might need it.

:)
 

  EDIT:

 

I hope these comments make more sense to you, than they do to me!:lol:

 


VALID  DATA 0               TERM FOUND, COMPARATOR.
SEARCH LI   R3,QUERI        R3=SEARCH TERM'S ADDRESS. *THIS IS THE ENTRY ADDRESS!
CMPARE CB   *R3,*R4+        COMPARE 1st LETTER OF SEARCH TERM, TO THE LETTERS IN THE SPECIFIED RANGE, ONE LETTER AT A TIME.
       JEQ  NEXT            DO THEY MATCH? YES! CHECK IF SECOND LETTERS MATCH. NO! CONTINUE.
       C    R4,R6           HAVE WE REACHED THE END OF THE SEARCH RANGE YET?
       JNE  CMPARE          NO! CHECK NEXT LETTER IN THE SPECIFIED RANGE. YES! CONTINUE.
OUTNO  RT                   BYE, NOTHING FOUND.
NEXT   MOV  R4,R5           SAVE THE POSITION OF THE NEXT POSSIBLE FIRST LETTER MATCH ...TO RESTART FROM IN CASE THE SECOND LETTER DOESN'T MATCH, OR TO INDICATE WHERE AN OCCURRENCE WAS FOUND LATER.
CONT   CB   *R3,@VALID      HAVE WE ALREADY MATCHED ALL CHARACTERS?
       JEQ  OUTYES          YES! MATCH FOUND! NO! CONTINUE.
       C    R4,R6           HAVE WE REACHED THE END OF THE SEARCH RANGE YET?
       JEQ  OUTNO           YES! EXIT(NO OCCURRENCE(S)) FOUND. NO! CONTINUE.
       INC  R3              ADVANCE TO THE NEXT LETTER OF THE SEARCH TERM.
       CB   *R3,*R4+        COMPARE ADDITIONAL LETTERS, ONE AT A TIME.
       JEQ  CONT            YES! CHECK 3RD AND UP, LETTERS. IF A LETTER DOESN'T MATCH, CONTINUE.
RESTAR MOV  R5,R4           RESTORE NEXT POSSIBLE FIRST LETTER MATCH ADDRESS.
       JMP  SEARCH          KEEP SEARCHING FOR NEXT FIRST LETTER MATCH.
OUTYES MOV  R5,R4           RETRIEVE POSITION OF THE PREVIOUS NEXT POSSIBLE FIRST LETTER MATCH.
       DEC  R4              SET R4 TO THE POSITION OF THE FIRST CHARACTER OF THE MATCHED TERM.
       RT                   OCCURRENCE FOUND
       END                  FEELS SO GOOD!

:)

Here's my code, I'll supply a video soon

 

IMG_20200712_081319891_HDR.jpg

IMG_20200712_081356170_HDR.jpg

IMG_20200712_081407238.jpg

  • Like 1
Link to comment
Share on other sites

Here are the values:

Libad7 is the string that the user keys in, it can be a length of 16 characters. 

S32P1 is page 1 of my 16 pages in cpu,(nice find, Automation) RAM. It's 860 bytes in length. Located in lower ram, but not all of my pages are in lower ram, and not all pages are consecutive, meaning, 1 page does not follow another, necessarily.

Pages are identified as S32P1,S32P2,S32P3,S32P4,S32P5,S32P6,S32P7,S32P8,S32P9,S32PA,B,C,D,E,F,G

PAGE contains the number 1-16 this is later passed to the program, I'm setting it solid here as I already know I'm dealing with page 1, so I'm safe setting this. This represents the current search word and where it was found, page 1? Page 2? Etc..

RRA2 contains the word length of the word that the user keyed in. If the user typed TI-99 then RRA2 contains a 5.

Note: libad7 is cleared prior to the user entry data. It's cleared with >20, spaces, all 16 characters before the user typed the word that is to be searched.

 

Edited by GDMike
Link to comment
Share on other sites

Here's my video.

I can search, and if the word I found, then I manually tell it to pull up page 1 in the last part of code, but it's finding even instead of eleven. 

And not landing on the first found word, but here it's likeif the first word I'm looking for is located on the first line then it puts the cursor on the work if it's on the second line and it puts it a line behind it and if it's the third line it puts it like two lines behind it so far so on but it still pulls up to page regardless which is cool meaning it found the word.

Edited by GDMike
Link to comment
Share on other sites

NO! CHECK NEXT LETTER IN THE SPECIFIED RANGE. YES! CONTINUE.
OUTNO  RT                   BYE, NOTHING FOUND

I'm not understanding how the BL to search works If it's only finding one character in the string and returning to my program? Why do I need the BL routine? And how do I know I have a word match, because outyes is a rt.?

Anyway, the BL is confusing me. Lol

I'll keep adjusting and see what I can come up with. Yayhoooo

Edited by GDMike
Link to comment
Share on other sites

22 hours ago, GDMike said:

Haha...^^^ ^^^^^^this server is sooo silly...:lol:

 

7 hours ago, GDMike said:On 6/30/2020 at 11:15 PM, HOME AUTOMATION said:

...

R4 will be set to the starting address of the found term.

or

R4 will be equal to R6 if nothing was found.

...


This search program, as intended, will check the entire string before RETURNing to the calling program. I'm only showing it as a subroutine for convenience ...both since, that seemed to be what you have been doing and since, I envisioned that you might want to use it dynamically, and perhaps from farther away than JMPs would allow for.:ponder:

 

If R4<>R6 you've found a match(entire string)!

 

         P.S. I have yet to review your code/download video.;-)

 

         P.P.S. I should have set this up, in a working example for you.
                  However, I am burdened with many responsibilities right now!:roll::thumbsdown:

 

  • Thanks 1
Link to comment
Share on other sites

Good to know an answer to that, probably obvious to most, but I really thought so originally, but then started thinking, and that's where I got in trouble.

Ok, I need to get rid of the BL and I do need it in a jump format, for it's driving me crazy, I cannot seem to make it work when I threw out the bl, I also tried it with keeping the BL and since I'm doing a BL to get to this, I did what Lee said, just remember r11 prior to the BL and be sure to ret back before returning to the original BL. So I tried that and found that the lockup routine I created worked but nothing else, so I've reverted back to your original code minus the BL and put it as a regular in line process to my calling BL

And just removed my old program instead. But it's lock up again.

So I'm made jumps back to search where you have RT and the program comes back saying it found the string, Even the string I don't have in memory.

But no more locking up. I've been playing with yes and no routines because I don't know where to look for a successful word find.

Thx for taking some time out of your day - no hurry automaniac man, it can wait for your next vodka. I'm just going to go play with the cb radio on skip.. lol

  • Haha 1
Link to comment
Share on other sites

Yup. I said that earlier I believe. There's a difference. Oh, I hope I didn't say vdp RAM, did I? Naaaa... really? Hmmm

Oh well. Must of been having one of those days..

Did you see my code? It actually finds the words searched, but it's got some kind of problem. It's very close to working I believe.

"I'm stuck in the middle with you"

 

Link to comment
Share on other sites

Ok, I fudged and fudge and yeah, I can't get a positive or correct negative on a find. Sorry, I've exhausted my structure in your code, I'm not getting Wonderful and exciting conclusions, just wonderful confusion. Sorry. 

I've got to wait until you have time again.

I'm already doing a BL to my search routine, I call findw. It looks like this:

FINDW mov R11,@SAVRTN

               LI R9, LIBAD7 * contains my search word plus 2 zeros

LI R10,S32P1 * my page with cool stuff, like boat payment structure, future house budget, etc.

RRA2= the length of libad7, without zeroes padded

 

Take care, gotta go do my hair

 

 

 

Link to comment
Share on other sites

It's been a while since you uploaded any code. It might help, if I could see how your managing R4, R6...
If you're searching paged memory. How this is being translated into VDP memory.

 

Coming up with insightful examples is difficult w/o knowing your work environment. You wont tell me if you have/use a MINIMEMORY cartridge! That's often my first choice for development! Maybe if you familiarized yourself, by running the code's example somewhat, before... trying to adapt it... might yield better results.

:pirate:

Edited by HOME AUTOMATION
  • Like 1
Link to comment
Share on other sites

I did think about just cutting your code as a standalone and throwing it in a EA test sandbox, but then talked myself out of it, because I figured you'd have something to account for my not getting r4 or r6 values as they should produce.

Nonetheless, I will definitely give that a try tommorow, and I'm glad you reminded me to do that, I just was caught up in the distraction 

But that sounds like a super duper idea to me.

And funny, I usually do that, as I did that with the division problems and the hmm I forget, but something else that you sent me.

Thx for guiding me. Stupid me, I should have done that.

In a good note, I fixed my lawnmower that has been fighting me for 4 days.

Ehh.. don't think about even looking at it in your mind as it will break on a dime!!

Ehh . Don't do it!!!

I got it rt where it'll run.

Ok. Thx again for the exciting times! I can't wait to try tommorow. Well, were watching the Vikings series at this time, gotta go for now.

 

 

Edited by GDMike
Link to comment
Share on other sites

Btw.  I use e/a, explorer

But seldom use explorer unless I can't understand a value.

I'll be using it in my sandbox 

I'll setup a blank page 1 with some text

I'll setup a search word on libad7 padded with 18 zeros, and as my search word is, in this scenario, 7 characters long.

And I suppose I have to do a BL to search, but you left a couple of rt for tests true and false, I like to setup a savrtn prior to the BL and returning to savrtn..

Can I trust just a rt?

I'll test that too in explorer

It's Happening

 

Edited by GDMike
Link to comment
Share on other sites

For what it's worth, I have never used RT. To me, B *R11 is unambiguous as to what is happening.

Also, if a subroutine calls another subroutine you can:

 

SUBRT1 MOV R11,R10   (store return address)

             Do some stuff

             BL @SUBRT2 (which returns with B *R11

             Do some more stuff

             B *R10   (return)  (you don't have to move R10 back to R11 and then RT)

  • Thanks 1
Link to comment
Share on other sites

Well, I think it's good for people like me that tend to forget stuff, I like to see where I'm coming from and going to.. until I get better versed.

Here I've set up a test example, hoping I can see how the search will work. This is all the code I've done.

It's setting up S32P1 as a page of data.

It sets up a search word, the word is "SEARCH" in uppercase.

It is located on page 1.

See video and code pictures

Next I'll import automation's code

 

IMG_20200714_205241648_HDR.jpg

IMG_20200714_205246654_HDR.jpg

IMG_20200714_205249745_HDR.jpg

IMG_20200714_205253475.jpg

IMG_20200714_205256488_HDR.jpg

IMG_20200714_205259843_HDR.jpg

IMG_20200714_205303800.jpg

Edited by GDMike
Link to comment
Share on other sites

2 hours ago, GDMike said:

explorer

M.G. explorer?

 

2 hours ago, GDMike said:

but you left a couple of rt for tests true and false,

VALID  DATA 0               TERM FOUND, COMPARATOR.
SEARCH LI   R3,QUERI        R3=SEARCH TERM'S ADDRESS. *THIS IS THE ENTRY ADDRESS!
CMPARE CB   *R3,*R4+        COMPARE 1st LETTER OF SEARCH TERM, TO THE LETTERS IN THE SPECIFIED RANGE, ONE LETTER AT A TIME.
       JEQ  NEXT            DO THEY MATCH? YES! CHECK IF SECOND LETTERS MATCH. NO! CONTINUE.
       C    R4,R6           HAVE WE REACHED THE END OF THE SEARCH RANGE YET?
       JNE  CMPARE          NO! CHECK NEXT LETTER IN THE SPECIFIED RANGE. YES! CONTINUE.
OUTNO  RT                   BYE, NOTHING FOUND.
NEXT   MOV  R4,R5           SAVE THE POSITION OF THE NEXT POSSIBLE FIRST LETTER MATCH ...TO RESTART FROM IN CASE THE SECOND LETTER DOESN'T MATCH, OR TO INDICATE WHERE AN OCCURRENCE WAS FOUND LATER.
CONT   CB   *R3,@VALID      HAVE WE ALREADY MATCHED ALL CHARACTERS?
       JEQ  OUTYES          YES! MATCH FOUND! NO! CONTINUE.
       C    R4,R6           HAVE WE REACHED THE END OF THE SEARCH RANGE YET?
       JEQ  OUTNO           YES! EXIT(NO OCCURRENCE(S)) FOUND. NO! CONTINUE.
       INC  R3              ADVANCE TO THE NEXT LETTER OF THE SEARCH TERM.
       CB   *R3,*R4+        COMPARE ADDITIONAL LETTERS, ONE AT A TIME.
       JEQ  CONT            YES! CHECK 3RD AND UP, LETTERS. IF A LETTER DOESN'T MATCH, CONTINUE.
RESTAR MOV  R5,R4           RESTORE NEXT POSSIBLE FIRST LETTER MATCH ADDRESS.
       JMP  SEARCH          KEEP SEARCHING FOR NEXT FIRST LETTER MATCH.
OUTYES MOV  R5,R4           RETRIEVE POSITION OF THE PREVIOUS NEXT POSSIBLE FIRST LETTER MATCH.
       DEC  R4              SET R4 TO THE POSITION OF THE FIRST CHARACTER OF THE MATCHED TERM.
       RT                   OCCURRENCE FOUND
       END                  FEELS SO GOOD!

No, it's not a test!:twisted: When I'm testing you, you'll KNOW!:grin:

 

You're looking at this in an over complicated way...

 

...I believe I have traveled far enough, that I have earned the right to use as many RTs in my subs, as I please!:D  When you think about it... they're all going to the same place... so subprograms can really only have 1 return address. Even with more entry points... it would still only be 1 subprogram.

 

probably the best thing to do is:

 

upon return, C    R4,R6, as I do above, to see if the search has reached the end of the "search space".

This should never be "true" if a match was found. so, JNE to the section of your program that handles matches, or perhaps, JEQ to the section of your program that handles mismatches.

:)

  • Like 1
Link to comment
Share on other sites

Ok, this is similar to what I'm doing in my program up to this point, except how I'm getting "SEARCH" into LIBAD7. But I'm still reading the screen like this and vmbr into LIBAD7 in both programs.

I believe it's padded with zeros.

I'll now add your code to this Hollywood production.

I'm not interested in adding any BL routines to aid me in my kscans or clear screens, this is just a test.

Edited by GDMike
  • Haha 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...