| Electronics > Beginners |
| Assembly code Help! PIC16F57 |
| << < (9/32) > >> |
| Ian.M:
You still need PAGESEL and/or LCALL, LGOTO to cross baseline page boundaries. (or use manual BSF/BCF instead of PAGESEL and save instructions when one of the page address bits STATUS<6:5> doesn't need changing). The original slot machine code uses minimal BSF/BCF STATUS for page management which doesn't help readability. Cleaning it up to use PAGESEL and LCALL would vastly help future maintainability. Each page is 512 (0x200) instruction words. The bottom half is accessible by CALL, the top half is not. i.e. If the most significant digit of the hex address is odd, CALL cant reach it. If adding code pushes a subroutine label over a half-page boundary, you need to rename the label (e.g. append 'x') and find somewhere in the bottom half of the same page to add: <label> GOTO <label>x to provide an entry point CALL can reach. |
| KL27x:
--- Quote ---Each page is 512 (0x200) instruction words. --- End quote --- Ah, ok. Thanks. I totally spaced that. I guess it's essentially the same as the midrange if lcall and pagesel work. Except you also have the half page thing AND the super small pages going on. Good thing you posted that, else OP would have had issues with my half-baked solution, carelessly moving a subroutine. OP, I'm now happy with my latest addendum. But you know what they say about last words. :) So anyhow, if I had moved dummy to the next page, page 3, (or if you had done this already) it should require this change to work, properly: exdummy ;which is located on page 0 bsf status,6 ;CALL SUBROUTINE IN PAGE 400-5FF ; this is page 2, originally. call dummy ;but this would be located on page 3, if you moved it to far side of org 600 bcf status,6 change this to: exdummy bsf status,6 bsf status,5 call dummy bcf status,6 bcf status,5 or exdummy pagesel dummy call dummy pagesel $ or exdummy lcall dummy ;beware this expands to two instructions when assembled (in midrange, this is how it always works for me but maybe I'm wrong?) ;in case you are using relative jumps or btfss type instruction in front of it. pagesel $ ;pagesel for some reason on midrange seems to only take one instruction??? Maybe I'm wrong, though. So well, OP you have options to try. |
| Electrofinn:
Oh crap I think I getting lost here, really sorry KL27x. trouble is the time of day here and when I get chance to get on this. so am I working from your latest addendum? scratch that, having read it again, I think I know what I need to do! |
| Electrofinn:
As I came back to this after all the posts I did not do the step 5 you said to omit, so did not do the correction you mentioned in your last post about exdummy. step 6 really confused me though! ;) testing now, so far so good! |
| Electrofinn:
Ok had two instances in 30mins of playing that it run approx half the "pattern2" sequence on a win. Don't know whether this is relevant but I decided to plug the speaker in to test whether that was also effected and it is, it does half the amount of beeping along with half the "pattern2". Just wondered if code for peizo speaker could be stopping this from working properly maybe? I think its only doing this when I have a two reel win (when first two reels match and any on the third gives a 10 pence win) which is 2 five pence pieces since this machine only takes 5p's, this by the way is 4 servo actuations (1 actuation collects coin from coin stack and another actuation pays it into collection tray) so 4 all together for 2 coins. it seems to do this properly even if half the "pattern2" and half the beeps are run. but everything else is fine though. There Is a real chance that somehow I messed up in the instructions but I don't think I did, I was going to suggest uploading my code, but I don't want to give you the extra task of having to go through mine as well. Or if I try your edited code? would that be easier? you have already worked so hard on this for me, I don't want to give you anything extra to do, unnecessarily. really appreciate this, you're not just creating code you're creating dreams. :-+ **edit played for an hour before it did it again. at least the changes haven't broke anything else. |
| Navigation |
| Message Index |
| Next page |
| Previous page |