Jump to content
GDMike

Assy math routine help needed

Recommended Posts

I've worked out a counter that, at the moment places 2 hex numbers on the screen - side by side that if they were in the MSB of R1 would allow me to display the char value to the display. My prob is, how can I get the two side by side numbers that are on my screen to live in MSB? 

Ex: >41       

But I need to collect this"41" into MSb of R1

Thx..

Share this post


Link to post
Share on other sites

Hmm. wondering how you got the numbers there to start with?

If you know the screen location of the chars. in question.

Use VSBR:

set R0 with the screen table read addr.. R1 should return the value in the MSB.

Then SWPB and subtract >30.

first result... 4

hmm, dont know if I've done this before...

shift left 4 bit positions...

save result...

repeat for second VDP byte... w/o shifting

result... 1

add the two results.

Swap back to MSB.

... hope I'm "together" in my reasoning!

Sound good... it's still early in the morning here...:sleep:
 

  • Thanks 1

Share this post


Link to post
Share on other sites

Thx .yeah, I have a routine that reads ram, places the value on the screen in hex, but another part of my prog needs to place the char value under the hex value...

R0 changes. But I have a way to insert code before it's pos change. Ok ..I knew itd be some kinda bit rotate kinda thing..I'm not good at that..

I can't wait to try your math!! 

 

Thx!! I'll let ya know.. hopefully with a video.

Share this post


Link to post
Share on other sites

I ended up trying to convert the >41, 42, 43 and 44 on the screen.

I ended up putting 1  2  3 4 on the screen in the correct positions. 

I'll have to go over the code again to see why.

Share this post


Link to post
Share on other sites
3 hours ago, GDMike said:

I've worked out a counter that, at the moment places 2 hex numbers on the screen - side by side that if they were in the MSB of R1 would allow me to display the char value to the display. My prob is, how can I get the two side by side numbers that are on my screen to live in MSB? 

Ex: >41       

But I need to collect this"41" into MSb of R1

Thx..

 

Not too sure what you are doing here. You say “2 hex numbers on the screen - side by side”. “Two numbers” implies two independent numbers, containing any number of digits each. I am thinking you intend “2 hex digits” of the same number?

 

...lee

  • Thanks 1

Share this post


Link to post
Share on other sites

I tried a SB R1,R4 prior because I'm pretty sure if I do a SB R4,R1 that my results should go to MSB of R1? Or I thought so..but swapping that around didn't help me..

Share this post


Link to post
Share on other sites

What you might want to consider is displaying both hex data and ASCII on the same screen, something like below. Very useful for spotting text strings within the data.

 

eprom_3.gif

 

(Noticed a little typo in your video - HEXIDECIMAL should be HEXADECIMAL)

  • Haha 1

Share this post


Link to post
Share on other sites
6 hours ago, GDMike said:

I tried a SB R1,R4 prior because I'm pretty sure if I do a SB R4,R1 that my results should go to MSB of R1? Or I thought so..but swapping that around didn't help me..

If SB uses the MSB of both R1 and R4, your LI R4,>30 needs to be LI R4,>3000 to put the >30 into the MSB?

  • Like 1

Share this post


Link to post
Share on other sites

Hi, I'm back!:lol:

 

SB operates on the wrong byte after the swap, you could use S instead.
AI can't handle 2 registers, you could use A(add) instead, also the second operand is the destination of the result.

 

(untested)

BLWP @VSBR
SWPB R1
AI   R1,->30  AI can be used to subtract... this evaluates to adding >FFDO to >R1... causing a rollover past >FFFF
SLA  R1,4
MOV  R1,R4
*now we have handled the "4" but still need to concatenate the "1"
*here I dont know where the digit is on screen, I assume to the right of the "4" so... INC R0... if to the left... DEC R0
INC  R0
BLWP @VSBR
SWPB R1
AI   R1,->30
A    R4,R1
SWPB R1

:)

Edited by HOME AUTOMATION
some errors
  • Like 1

Share this post


Link to post
Share on other sites

I'm actually hacking it out in explorer...

(Too bad it doesn't do spell check) joke

Im running it through explorer..

Yeah, a lot I do understand regarding MSB vs LSB in subtracting and adding/moving etc ..so that's a good thing..I just get confused during the SLA...let me see what we have here.. compiling

Edited by GDMike

Share this post


Link to post
Share on other sites

I've been assuming you have "41" on screen and want to get that into the MSB of R1.

 

I think Stuart is thinking you have "34" and "31" on screen and want to get "41" into the MSB of R1.

:ponder:

  • Like 1

Share this post


Link to post
Share on other sites

BTW, it doesn't matter on what hex value is on the screen as I aim to read the 2 values and be able to place the ASCII value into R1. 

This test gave me ASCII letter "S"

 

Edited by GDMike
Missing the info

Share this post


Link to post
Share on other sites

BTW, it doesn't matter on what hex value is on the screen as I aim to read the 2 values located on the screen. Then be able to place the ASCII value into R1. 

This test gave me ASCII letter "S" it should have given ASCII "*" after I made sure AI R1,>3000 instead of >30 was in place, as I just went with the text provided..(I changed it after the video).

 

Share this post


Link to post
Share on other sites

BTW, it doesn't matter on what hex value is on the screen as I aim to read the 2 values located on the screen. Then be able to place the ASCII value into R1. 

This test gave me ASCII letter "S" it should have given ASCII "*" after I made sure AI R1,>3000 instead of >30 was in place, as I just went with the text provided..(I changed it after the video).

 

Share this post


Link to post
Share on other sites

I analyzed your vid.... very difficult as I'm on an older laptop and your vid. is way too HQ.

The only issue is that you are adding instead of subtracting...

 

AI ->32  (negative >32)

 

:party:

Edited by HOME AUTOMATION
  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, HOME AUTOMATION said:

I analyzed your vid.... very difficult as I'm on an older laptop and your vid. is way too HQ.

The only issue is that you are adding instead of subtracting...

 

AI ->32  (negative >32)

 

AI  >30  (positive  >30) adding >30

AI ->30  (negative >30) subtracting >30

 

:party:

hmm, correct the above from "32" to "30" ...why did I do that.

  • Like 1

Share this post


Link to post
Share on other sites

Ok..thanks..I got confused (I do that), I initially was subtracting, but for some reason I thought I was supposed to be adding? Duh..I'll run it back though explorer.. and see if it will nail down.

It's tough for me to use this platform for Trouble shooting like this. And my phone keeps going nuts on this site..as it was fine on here a couple weeks ago and lately its not allowing me to edit, select picture or video files..etc...so I'm usually rushed to get a subject up then to find out I didn't explain my situation well.

Thx for the assistance!!

 

 

 

 

Share this post


Link to post
Share on other sites

I notice that you have the following code:

     MOV R11,@SAVRTN

     some code...

     MOV @SAVRTN,R11

     RT *R11

 

A couple of points:

RT is a "pseudo instruction." When assembled, RT becomes B *R11. The additional *R11 is treated as a comment - if you wrote RT *R4 it would still assemble as B *R11

You only need to save R11 if you will be doing a BL instruction which puts the return address into R11

Depending on your register usage, you can MOV R11,R10 and then B *R10 to return. 

I have always used B *R11 instead of RT - for me that helps avoid confusion

 

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Ahhhh...great tip of the day. Ya know, as you can probably tell, I just started learning assy. After learning a lot about TF. There is still a lot to lean here. Especially SLA,R,and around and around..

And Lee always points out my spelling errors,  I think last time he caught my DATA >FC46   >DE34 ahhh no comma..

And again the spelling of The word HexIdecimal. Lol... where is QA when ya need em... right! 

I do appreciate the help, really..I hope Lee isn't pissed off at me for making these stupid mistakes.... yikes...

Thanks so much again!!!

Share this post


Link to post
Share on other sites

Ahhhh...great tip of the day. Ya know, as you can probably tell, I just started learning assy. After learning a lot about TF. There is still a lot to lean here. Especially SLA,R,and around and around..

And Lee always points out my spelling errors,  I think last time he caught my DATA >FC46   >DE34 ahhh no comma..

And again the spelling of The word HexIdecimal. Lol... where is QA when ya need em... right! 

I do appreciate the help, really..I hope Lee isn't pissed off at me for making these stupid mistakes.... yikes...

Thanks so much again!!!

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