flat assembler
Message board for the users of flat assembler.
Index
> Main > need help with rand function. |
Author |
|
LocoDelAssembly 20 Mar 2007, 19:52
To avoid infinite loop you could try getting "AL := AL MOD ('9'-'0'+'Z'-'A'+2)" and then mapping AL to the appropiate char (AL < 10 then AL := AL+'0' else AL := AL + 'A')
|
|||
20 Mar 2007, 19:52 |
|
DOS386 20 Mar 2007, 20:16
Quote: avoid infinite loop you could try getting "AL := AL MOD ('9'-'0'+'Z'-'A'+2)" AL := AL MOD 36 Quote: and then mapping AL to the appropiate char (AL < 10 then AL := AL+'0' else AL := AL + 'A') Right ... but there seem to be more problems: Code: mov bx, BiosClockTick mov al, [bx] Will this read from correct address at all ? And: even if you fix 2 previous problems, there is one more left: the complete "randomness" depends of one single byte, you will get mostly only 256 different "random" names Repeated reading from BiosClockTick will almost never give new values ... the code will be far too fast as soon as you get rid of the infinite loop You should use 2 bytes from BiosClockTick (the 2 highest bytes are bad as well - mostly 0), read from there one time only ... yeah ... only 65536 names possible ... _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
20 Mar 2007, 20:16 |
|
Hayden 21 Mar 2007, 12:45
Thanks very much for giving me some direction guys. I acctualy expected the code not to work when I wrote it.
I think I should use mov 0:[bx] , or an overide segment set to zero. I have thought about doing a rand 0 -> 25 + 'a' approach. but that would limit name sto smallcase. |
|||
21 Mar 2007, 12:45 |
|
DOS386 22 Mar 2007, 05:46
Quote: to create a random 8.3 mode compatable filename Quote: doing a rand 0 -> 25 + 'a' approach. but that would limit name sto smallcase. 1. From 8.3, I assumed DOS - and DOS filenames are always UPPERCASE. 2. You randomness is insufficient already for (A...Z)&(0...9), you should forget about lowercase for now. _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug |
|||
22 Mar 2007, 05:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.