This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - Xeda112358
Pages: 1 ... 47 48 [49] 50 51 ... 317
721
« on: October 21, 2013, 08:11:39 am »
I updated the 80-bit floating point multiplication routine. It is a bit larger now, but I used a modified approach from the last version and it is now much faster. From ~32000 t-states, I brought it down to ~24000 2 days ago, and last night, I brought it down to <16000 t-states. Now it is more accurate and provides a wider range of numbers and it is faster than the OS. Division on the other hand is still pretty slow (the OS does it faster).
As well, I have a squareroot routine for the 24-bit floats that works, but I want to make it faster. I haven't added that to the routines list yet.
722
« on: October 20, 2013, 03:53:19 pm »
Here is a sqrtL routine:
SqrtL: ;Inputs: ; L is the value to find the square root of ;Outputs: ; C is the result ; B,L are 0 ; DE is not changed ; H is how far away it is from the next smallest perfect square ; L is 0 ; z flag set if it was a perfect square ;Destroyed: ; A ld bc,400h ; 10 10 ld h,c ; 4 4 sqrt8Loop: ; add hl,hl ;11 44 add hl,hl ;11 44 rl c ; 8 32 ld a,c ; 4 16 rla ; 4 16 sub a,h ; 4 16 jr nc,$+5 ;12|19 48+7x inc c cpl ld h,a djnz sqrt8Loop ;13|8 47 ret ;10 10 ;287+7x, x is the number of bits in the result ;min: 287 ;max: 315 ;19 bytes
Also, in case anybody needed a small GCD (Greatest Common Divisor) routine, I have this:
GCDHL_DE: ;Outputs: ; DE is the GCD GCDLoop: or a sbc hl,de ret z jr nc,$-3 add hl,de ex de,hl jp GCDLoop
(a faster one is a few posts up) If you need a fast way to see if a 16-bit number is divisible by 3 (without actually dividing)
HL_mod_3: ;Outputs: ; Preserves HL ; A is the remainder ; destroys DE,BC ; z flag if divisible by 3, else nz ld bc,030Fh ld a,h add a,l sbc a,0 ;conditional decrement ;Now we need to add the upper and lower nibble in a ld d,a and c ld e,a ld a,d rlca rlca rlca rlca and c
add a,e sub c jr nc,$+3 add a,c ;add the lower half nibbles
ld d,a sra d sra d and b add a,d sub b ret nc add a,b ret ;at most 132 cycles, at least 123
723
« on: October 20, 2013, 01:36:05 pm »
It depends on how you want to run the application. In the case of Axe, I imagine that you are looking for a way to automatically compile an Axe program from within your shell. Luckily, newer versions of Axe have a jump table with useful routines. I think you will want to check out the API documentation for that. As for running any app, that can get pretty tricky because of how apps exit. What you would have to do is check the header of the application to locate where the code starts, then do a jump or call to that address.
724
« on: October 01, 2013, 08:43:24 am »
Yeah, I noticed the issue, too. I made it so that my characters were 7x7 to avoid the issue, but what is your code for converting the hex? If data is the 64-bit data and a holds the value of the current character:
(in Python code)
if a>64: a=a-7 data=(data<<4)-48+a
Just iterate that through each hex digit and overflow shouldn't be a problem. (this also requires that data be a 64-bit unsigned int).
725
« on: September 29, 2013, 03:45:48 pm »
726
« on: September 29, 2013, 10:21:45 am »
@AssemblyBandit: I feel that if you ran such a super computer simulation, you would need to slow it down to keep up with all of the 'problems' that need fixing. It would be like running Conway's Game of life and trying to preserve every pixel. As well, you would have to ask if you would even recognise intelligence emerging from your construction, and you would have to recognise when something bad happens or when something good happens. You could not expect human forms to come from your simulation or recognisable forms of communication. If you could recognise each instance of pain that needs remedying and prayers that need answers, and life that needs saving, would you not then automate the process through algorithms? Or modify your universe to be 'perfect' by including code to right the wrongs or preempt them? And you have a finite life. When you die, if you have not made an automated 'God' then your universe will suddenly lose its repairman. And if the universe evolved at a faster rate than ours, what would happen if a being in your created universe created their own universe? If you decided not to preserve their life, then would you be the 'God' responsible for the universe created inside your universe? This is actually pretty cool to think about
727
« on: September 27, 2013, 10:03:23 am »
That looks right except I messed up the pseudocode, sorry. The only change should be to negate if the carry flag is reset.
That looks really nice o.o The exit condition can then be made to be when a=0, if a is initialised properly. With that, I want to show the true diabolical nature of this algorithm (mwahahaha?):
Python code:
from math import * print """ ================================================================ Exact Sine of the form sin(x*pi/2^y) For x not a natural number, this provides an estimate. ================================================================ """ a=eval(raw_input("x=")) b=32+eval(raw_input("y=")) a=a*(2**32) if a==int(a): print "Exact" else: print "Estimate" a=int(a) while a%2 ==0: a=a>>1 b=b-1 str1=".5*sqrt(2" str2=")"*(b-1) a=2.0*a/(2**b) b=b-2 while b>0: b=b-1 a=a*2 str1=str1+"-+"[int(a)]+"sqrt(2" if a<1: a=1-a a=a-int(a) str1=str1+str2 print str1 print eval(str1)
TI-BASIC:
ClrHome Disp "sin(Aπ/2^B) Prompt A,B While not(remainder(A,2 .5A→A B-1→B End ".5√(2→Str1 2A/2^B→A B-2→B While B B-1→B Str1+sub("-+",int(2A)+1,1)+"√(2→Str1 2A If Ans<1 1-Ans fPart(Ans→A End
728
« on: September 27, 2013, 08:57:19 am »
I once wrote an algorithm that I originally generated from a fractal. It was a lot easier for me to come up with the rules for the fractal and then use the image for the algorithm than it was to solve the algorithm problem directly. However, yesterday, after nt touching this problem in almost a year, it randomly popped into my head with a solution, so I have the algorithm below in TI-BASIC (since I had my calculator nearby, I tested it on that). What I am wondering is how to optimise it. I tried to generate it with a binary expansion because ultimately, that is what I will be using it with, but it got too messy without the fractal I was using as a crutch:
Input A Input B
"A must be odd While not(remainder(a,2 .5A→A B-1→B End
2A/2^B→A "constraints on A and B will always cause this to be on [0,1) B-2→B ".→Str1
While B B-1→B 2A→A int(A→R A-Ans→A If not(R 1-A→A Str1+sub("01",R+1,1→Str1 End
Except for the first character, Str1 will be a sequence of 0s and 1s. Any ideas? It essentially maps an odd binary number to another binary number and the map is 1-1.
EDIT:
;given a,b such that a/2^(b+1) is on [0,1) and a is odd a/2^(b+1)→a b-2→b ""→string While b>0 b-1→b 2*a→a string & str(int(a))→string ;int(a) will either be 1 or 0, so append this to the string if a<1 1-a→a a-int(a)→a
729
« on: September 27, 2013, 08:41:31 am »
For this, the best algorithm is probably testing for a win. For example, say the player places an 'O' at position (4,5). You would check: (0,5)+(1,5)+(2,5)+(3,5)+'O'+(5,5)+(6,5)+(7,5)+(8,5) to check up/down for a string of 5 'O's (4,1)+(4,2)+(4,3)+(4,4)+'O'+(4,6)+(4,7)+(4,8)+(4,9) to check left/right for a string of 5 'O's And likewise you would check diagonals. This way, you do not need to scan the whole 20x20 grid, just the area around the last move. For AI, scanning the whole grid is probably the best way. The smartest algorithm, I think, would try moves in the following order: -searching for 4-in-a-row for the current player. If one is available, make it 5 in a row -Else then check 4 in a row for the opponent in order to block a winning move -check 3-in-a-row -check 2-in-a-row -place anywhere I also made a matrix-based algorithm for AI that may be useful, but the size is based on the number of positions (in this case 400) and the number of possible wins (1080, I think) so it would be a pretty large matrix, compared to 9x8 for a traditional tic-tac-toe board.
730
« on: September 27, 2013, 08:25:47 am »
The graffiti game idea sounds fun and the variable tile heights are an awesome feature!
731
« on: September 26, 2013, 06:18:40 pm »
I would also recommend spasm and Brass, but I would also recommend ORG as a good option. I had lots of trouble with TASM, too.
732
« on: September 26, 2013, 07:55:34 am »
And thanks for the tips, links, and optimisation! Optimisation is one of my favorite things to do for the Z80 calcs (I am primarily a Z80 assembly programmer). I think I found the routine on the Prizm Wiki, though I may have modified it more (I cannot remember). I also never tried testing for periodicity, though I am quite familiar with it (I even took a semester course in fractals and chaotic systems). I planned to write a program for the platform I am more familiar with and then port it to the Prizm to try out the optimisations.
733
« on: September 25, 2013, 06:38:59 am »
OT: Is Grammer allowed on Omnimaga contests ?
Yes it is, apparently
734
« on: September 24, 2013, 09:37:37 am »
I haven't gotten to look at the code much, but I imagine that it is the difference between using integer or fixed point math and floating point.
735
« on: September 23, 2013, 02:55:18 pm »
Wow, that looks wonderful! That is pretty similar to the explorer I made in Axe for the TI-84+ calcs (except that scrolling didn't make the image fuzzy). When zooming in, it would zoom in x2 by scaling up the image first and then redraw the image with better accuracy while the user wasn't doing anything.
Pages: 1 ... 47 48 [49] 50 51 ... 317
|