Jump to content
GDMike

Assembly code samples

Recommended Posts

I can't edit my last post, I can't upload a photo I Made. I'm rebooting my phone..one sec

Share this post


Link to post
Share on other sites
Posted (edited)

Now I don't want to BL to this routine, but Im trying to figure out how to enter and keep my R4 alive.

So I'm stuck rt here at the moment..

IMG_20200714_214904518.jpg

Edited by GDMike

Share this post


Link to post
Share on other sites

My super awesome random number generator!

 

First, you need to initialize the 9901 counter at the start of your application:

 

* Set up 9901 counter
       CLR  R12                        * CRU base of the TMS9901
       SBO  0                          * Enter timer mode
       LI   R1,>3FFF                   * Set counter
       INCT R12                        * Address of bit 1
       LDCR R1,14                      * Load value
       DECT R12
       SBZ  0                          * Exit clock mode, start decrementer 

Then, the following routines will generate either a 16-bit word size random value, or any value from 0 to max-1. I've set them up to have their own workspace but you don't need to do this if you don't want to.

* Random number generator (Range in R3, Result in R4)
* Returns 0 to R3-1
RNDNUM DATA VWS,RAND2
RAND2  BL   @RNDGEN
       MOV  @>0006(R13),R3
       CLR  R4
       DIV  R3,R4
       MOV  R5,@>0008(R13)
       RTWP
* Random number generator 16-bit (Result in R4)
* returns 0-65535
RANDOM DATA VWS,RAND1
RAND1  BL   @RNDGEN
       MOV  R4,@>0008(R13)
       RTWP
* Random number generation
RNDGEN LI   R4,23729                   * Load with 15-bit value
       MPY  @RSEED,R4                  * Multiply by the random seed
       AI   R5,31871                   * Add a 15-bit value to the lower word
       CLR  R12                        * CRU base of the TMS9901
       SBO  0                          * Enter timer mode
       STCR R0,15                      * Read current value (plus mode bit)
       SRL  R0,1                       * Get rid of mode bit
       SBZ  0                          * Exit clock mode, decrementer continues
       ANDI R0,>000F                   * Filter to 0-15
       JEQ  RNDGN1                     * If zero, skip
       SRC  R5,0                       * Rotate seed based on clock value
RNDGN1 MOV  R5,@RSEED                  * Copy back to RSEED
       RT

 

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Fantastic!!! Now I see what I was hunting for..here

* returns 0-65535
Edited by GDMike

Share this post


Link to post
Share on other sites
Posted (edited)

Where is that? Are you seeing double, double mr.Roboto

Robocall

But I have a million uses for that generator! Very very cool. Thank you!!

Edited by GDMike

Share this post


Link to post
Share on other sites
Posted (edited)

Yup. If I do a BL @ search and a rt occurs, doesn't or won't that put me at SEARCH again?

IMG_20200714_222126637.jpg

Edited by GDMike

Share this post


Link to post
Share on other sites

I'm just trying to line up the address in R4 with the word on the screen..

Share this post


Link to post
Share on other sites
Posted (edited)
2 hours ago, GDMike said:

IMG_20200714_205253475.jpg

looking at LI R0, LI R1, LI R0, LI R1... you realize that the last two prevail?

Edited by HOME AUTOMATION
  • Like 1

Share this post


Link to post
Share on other sites

I was trying to make sure that my word that I'm searching for that I actually put on the screen wasn't being found later by the search program

Share this post


Link to post
Share on other sites

All right I'm going to give you the code that I've got I keep coming up with a hit and I shouldn't be hitting

Share this post


Link to post
Share on other sites
Posted (edited)
3 hours ago, GDMike said:

IMG_20200714_205241648_HDR.jpg

LIBAD7

SHP

S32P1

LBWRD  TEXT 'SEARCH'

             DATA 0  *These are the zeros that need to follow the search term!

SRCHF

Edited by HOME AUTOMATION
oops ... had DATA 0, in the LABEL field!

Share this post


Link to post
Share on other sites

Here's the updated code test

I'm putting an "A" at pos 0 on the screen if it's a bad search. If it's a good search, then I'm placing an asterisk on the word. I'm having to convert the address in R6 to the screen location. But I didn't have any luck, I tried inct in my loop and just a Inc but I always seem to place an asterisk at the position it shows now.

And I'm always hitting a positive search no matter what my search word is.

 

IMG_20200714_230823247_HDR.jpg

IMG_20200714_230828368_HDR.jpg

IMG_20200714_230850972.jpg

IMG_20200714_230854748_HDR.jpg

IMG_20200714_230858211_HDR.jpg

IMG_20200714_230901894.jpg

IMG_20200714_230906982_HDR.jpg

IMG_20200714_230911037.jpg

Share this post


Link to post
Share on other sites

I can't see straight..I'm going to dream about getting a great result. I'll wake up and it'll hit me..or something will..

 

Share this post


Link to post
Share on other sites
Posted (edited)

I changed my search word a couple times, first it was"SEARCH" and it was a positive hit, then changed to Mike, it too was a positive hit.

I wanted to make sure that I wasn't placing the search word into my copied screen page, as I thought that was happening. But I don't think it was.

Is it ok if I crash? At this moment im starting to screw with things and I'm messing it up. I'll read notes in a couple hours 😊😁

Edited by GDMike

Share this post


Link to post
Share on other sites
15 minutes ago, GDMike said:

IMG_20200714_230850972.jpg

I explained this wrong...

 

LIBCLR was moving WORDs starting in ROM @>0000.

 

...Now it's just copying  the WORD @>0000, repeatedly.

 

anyhow... no need to do this.

  • Like 1

Share this post


Link to post
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.

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...