Acorn Arcade forums: Programming: EQUB
|
EQUB |
|
andrew (12:07 11/4/2004) cterran (12:35 11/4/2004) andrew (14:35 11/4/2004) Phlamethrower (15:18 11/4/2004) andrew (19:42 11/4/2004) Loris (12:52 19/4/2004) adrianl (23:52 19/4/2004) cterran (01:09 20/4/2004) andrew (17:17 20/4/2004)
|
|
Andrew |
Message #53347, posted by andrew at 12:07, 11/4/2004 |
Handbag Boi
Posts: 3439
|
If I want to store a number of bytes in assembler using EQUB how do I suppress the addresses being printed on screen. This is just a test program: DIM CODE% 1000 FOR PASS=0 TO 2 STEP 2 P%=CODE% [OPT PASS .lookup ] FOR eq%=1 TO 10 [ OPT PASS EQUB0 ] NEXT eq% NEXT PASS PRINT?lookup What am I doing wrong? Also shouldn't I need to use ALIGN at the end of the eq% loop?
One final thing, I usually try to reserve plenty of memory for the assembler code. However recently I only reserved 512 bytes for what looked like at least several K yet the program worked - I would have expected a crash!
[Edited by andrew at 13:08, 11/4/2004] |
|
[ Log in to reply ] |
|
Chris |
Message #53348, posted by cterran at 12:35, 11/4/2004, in reply to message #53347 |
Member
Posts: 163
|
Listing: Put the OPT next to the [ as here:
[OPT PASS
ALIGN: yes, you should use it (unless you specifically want the next item to be contiguous). If the next item is a normal assember statement it happens automatically though.
Reserving memory: BASIC doesn't remember the size of a DIMmed memory area, it just delivers the start address. It doesn't check the end. If you want to check for code overflow you need to set the L% variable and set OPT appropriately.
Best, Chris |
|
[ Log in to reply ] |
|
Andrew |
Message #53351, posted by andrew at 14:35, 11/4/2004, in reply to message #53348 |
Handbag Boi
Posts: 3439
|
Thanks for the help Chris, it's working as I wanted now. With regards to the DIMmed area, I need to make this large enough to accomodate the EQUB'd area as well I assume?
Didn't there used to be an 'O%' as well?
[Edited by andrew at 15:36, 11/4/2004] |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #53352, posted by Phlamethrower at 15:18, 11/4/2004, in reply to message #53351 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Thanks for the help Chris, it's working as I wanted now. With regards to the DIMmed area, I need to make this large enough to accomodate the EQUB'd area as well I assume? Yes, you need to make sure it's large enough for both.
Didn't there used to be an 'O%' as well? Yes, that's used with offset assembly. There's some more info at the bottom of http://www.soup-kitchen.net/armcode/4/article.html |
|
[ Log in to reply ] |
|
Andrew |
Message #53360, posted by andrew at 19:42, 11/4/2004, in reply to message #53352 |
Handbag Boi
Posts: 3439
|
Ah yes I remember now when you make stand-alone 'absolute' code. I'm sure when I originally read about it, it didn't explain it like this though. I'd have to have a look at the Mike Ginn's book. If I'd used one of the pre-made random number generators I wouldn't have had all this trouble generating lookup tables as the number generator I came up with seems to be too slow to run on the fly in BASIC and, since its got SIN and COS, then most probably not in assembler. As it is I'm creating a lookup table where the values (1 or 0) are going to be stored as bits. Hopefully this'll be faster than storing and retrieving as bytes, not to mention less wasteful |
|
[ Log in to reply ] |
|
Tony Haines |
Message #53603, posted by Loris at 12:52, 19/4/2004, in reply to message #53360 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
If what you want are random bits, then why don't you just use one of the standard assembly random-number generators? It'll probably be quicker, and definitely smaller.
There is a 2 instruction sequence which will generate a good pseudo-random bit per cycle. (I have this stored somewhere if you can't find it - it was in the ARM cookbook). If you want a repeatable sequence you can just retain the seed. |
|
[ Log in to reply ] |
|
Adrian Lees |
Message #53618, posted by adrianl at 23:52, 19/4/2004, in reply to message #53603 |
Member
Posts: 1637
|
Two instructions?! There's a well-known 5 instruction example in the "Acorn Risc Machine Family Data Manual" from the days of ARM2/3:
; Enter with seed in R0 (32 bits), R1 (1 bit in R1 lsb) ; Uses R2 TST R1,R1,LSR 1 ; Top bit into carry MOVS R2,R0,RRX ; 33 bit rotate right ADC R1,R1,R1 ; Carry into lsb of R1 EOR R2,R2,R0,LSL 12 ; (Involved!) EOR R0,R2,R2,LSR 20 ; (Whew!) ; New seed in R0, R1 as before
BTW, whilst having a repeatable sequence may seem to defeat the point of a pseudo-random number generator it can be very useful when debugging |
|
[ Log in to reply ] |
|
Chris |
Message #53619, posted by cterran at 01:09, 20/4/2004, in reply to message #53618 |
Member
Posts: 163
|
If you're using the BASIC assembler, that example will need #s after the LSLs and LSRs (eg LSL #12). Otherwise you'll rotate by whatever is in R12.
There's a two-instruction 'random' bit generator in PRM4, p75:
One register is used as a multi-tap shift register, loaded with a seed value; the second is loaded with an XOR bit mask constant (&1D872B41). The sequence produced has a length of 4294967295. The random carry bit setting by the simple code fragment outlined below allows conditional execution on carry set (or cleared):
MOVS R8,R8,LSL #1 ; set random carry EORCS R8,R8,R9 xxxCC ; do this... yyyCS ; ...or alternately this
Best, Chris
[Edited by cterran at 02:15, 20/4/2004]
[Edited by cterran at 02:17, 20/4/2004] |
|
[ Log in to reply ] |
|
Andrew |
Message #53640, posted by andrew at 17:17, 20/4/2004, in reply to message #53603 |
Handbag Boi
Posts: 3439
|
If what you want are random bits, then why don't you just use one of the standard assembly random-number generators? It'll probably be quicker, and definitely smaller. There is a 2 instruction sequence which will generate a good pseudo-random bit per cycle. (I have this stored somewhere if you can't find it - it was in the ARM cookbook). If you want a repeatable sequence you can just retain the seed. Yes in retrospect it might have been better as I say but I like the pattern I've got, perhaps it's not too random is why I know about the assembler manual pseudo-random number generator and somebody sent me one as well. Also I could have used RND(N) and generated the lookup from that. If my lookup isn't fast enough then I'll have to come back to the assembler generator. |
|
[ Log in to reply ] |
|
|
Acorn Arcade forums: Programming: EQUB |