![]() |
![]() |
#1 |
Posts: n/a
|
![]()
I need help in displaying a random 8 digit octal number on the seven segments using 68k assembly language.
I'm designing a software of reaction timer but the first problem come to me is in generating random octal number. Your help is highly appreciated. ![]() ![]() ![]() |
![]() |
#2 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Do you mean that you want to generate 8 random digits of base 8?
Code:
Randomize lea State(pc), a0 lea Digits(pc), a1 move.l (a0), d0 moveq #8-1, d2 loop ; generate a random value move.l d0, d1 lsl.l #2, d1 eor.l d1, d0 move.l d0, d1 lsr.l #7, d1 eor.l d1, d0 move.l d0, d1 lsl.l #7, d1 eor.l d1, d0 ; extract a base 8 digit and store as one byte moveq #7, d1 and.b d0, d1 move.b d1, (a1, d2.w) dbf d2, loop move.l d0, (a0) rts ; initialize this 32-bit value to non 0 when program starts State ds.l 1 ; Digits will contain 8 bytes, each being a number from 0 to 7 Digits ds.b 8 Last edited by Leffmann; 27 July 2010 at 12:48. |
![]() |
![]() |
#3 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
Quote:
Code:
start bsr rng rts rng lea digits,a0 move.l #$11111111,d0 move.l state,d1 moveq #0,d2 moveq #7,d6 moveq #7-1,d7 ;Number of digits-1. .loop add.l d0,d2 rol.l #7,d1 add.l d2,d1 move.l d1,d3 and.l d6,d3 ;Need ascii? Add ascii value of "0" to d3. move.b d3,(a0)+ .next dbra d7,.loop move.l d1,state rts state dc.l $52896594 ;Seed value. Set to anything. digits dc.b 7 even |
|
![]() |
![]() |
#4 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Hm I did the same test just now and it looks perfectly uniform, and it also passed almost all tests in the Diehard test suite. But let's keep the random-insanity in the other thread, I think sheryn88 was just looking for something simple to test his 7-segment display with.
|
![]() |
![]() |
#5 |
Posts: n/a
|
Thanks!!! But i found that the random numbers generated are actually uniform. The group of numbers generated each time i run the program are actually the same. Is it ought to be uniform like this?
|
![]() |
#6 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
Quote:
Code:
start bsr randomize bsr rng rts randomize lea $bfe001,a0 add.b $400(a0),d0 lsl.l #4,d0 add.b $500(a0),d0 lsl.l #4,d0 add.b $600(a0),d0 lsl.l #4,d0 add.b $700(a0),d0 move.l d0,state rts rng lea digits,a0 move.l #$11111111,d0 move.l state,d1 moveq #0,d2 moveq #7,d6 moveq #7-1,d7 ;Number of digits-1. .loop add.l d0,d2 rol.l #7,d1 add.l d2,d1 move.l d1,d3 and.l d6,d3 ;Need ascii? Add ascii value of "0" to d3. move.b d3,(a0)+ .next dbra d7,.loop move.l d1,state rts state dc.l 0 digits dc.b 7 even |
|
![]() |
![]() |
#7 |
Posts: n/a
|
Thanks a lot for the help!!!
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
random number generation (in asm) | meynaf | Coders. General | 183 | 29 November 2010 19:48 |
retro sound generator | gimbal | Retrogaming General Discussion | 1 | 30 September 2008 07:45 |
landscape generator | twizzle | MarketPlace | 0 | 04 May 2006 22:47 |
Landscape generator | DDNI | request.Apps | 30 | 04 May 2006 18:18 |
A nice quick small random numbers routine? | Photon | Coders. General | 2 | 20 December 2004 21:56 |
|
|