﻿ Assembly Programmers - Help Axe Optimize!
 Welcome, Guest. Please login or register.
23 May, 2013, 21:40:53
 Welcome, Guest. Please login or register. 1 Hour 1 Day 1 Week 1 Month Forever Login with username, password and session length
 home news downloads projects tutorials misc forums rules new posts irc about Login Register
 OmnomIRC You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

 Pages: 1 ... 14 15 [16] 17 18 ... 20   Go Down
 Author Topic: Assembly Programmers - Help Axe Optimize! -  (Read 20511 times) 0 Members and 1 Guest are viewing this topic.
Xeda112358
Xombie. I am it.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)

Online

Last Login: Today at 21:36:18
Date Registered: 31 October, 2010, 08:46:36
Location: Land of Little Cubes and Tea, NY
Posts: 3760

Total Post Ratings: +609

 « Reply #225 on: 11 August, 2011, 19:10:51 » 0

I was toying around with some math routines while I was away and I was curious about the square root algorithms. Are the designed to return the square root rounded down, up, or just rounded? If it is rounded down and you want to round it to the nearest integer answer, here is a code I made a while ago (it isn't even close to what Axe needs, but it should only be taken as an example):
 1234567891011121314151617181920212223242526272829303132333435363738394041424344 ;===============================================================sqrtE:;===============================================================;Input:;     E is the value to find the square root of;Outputs:;     A is E-D^2;     B is 0;     D is the rounded result;     E is not changed;     HL is not changed;Destroys:;     C;        xor a               ;1      4         4        ld d,a              ;1      4         4        ld c,a              ;1      4         4        ld b,4              ;2      7         7sqrtELoop:        rlc d               ;2      8        32        ld c,d              ;1      4        16        scf                 ;1      4        16        rl c                ;2      8        32        rlc e               ;2      8        32        rla                 ;1      4        16        rlc e               ;2      8        32        rla                 ;1      4        16        cp c                ;1      4        16        jr c,\$+4            ;4    12|15      48+3x          inc d             ;--    --        --          sub c             ;--    --        --        djnz sqrtELoop      ;2    13|8       47        cp d                ;1      4         4        jr c,\$+3            ;3    12|11     12|11          inc d             ;--    --        --        ret                 ;1     10        10;===============================================================;Size  : 29 bytes;Speed : 347+3x cycles plus 1 if rounded down;   x is the number of set bits in the result.;===============================================================

The only reason that I mention this is that I know a lot of graphical algorithms would have better results if the square root was returned in rounded form as opposed to just rounded up or down.

Sorry if this was already covered and I missed it
Spoiler for Hidden:
EDIT:
Wow, I just did something I didn't think was even possible. I found a good use for a forward djnz.
>.> Hehe, I use forward djnz in many-- if not most-- of my programs... It is one of the most useful tricks I use and is kind of my signature touch I use it to save time and memory a lot, especially in instances like this:
 1234567891011 ld b,a     or a \ jr nz,Next1       ;codeNext1:     djnz Next2       ;codeNext2:     djnz Next3       ;code;...et cetera
* Xeda112358 loves it
 « Last Edit: 11 August, 2011, 20:29:55 by Xeda112358 » Logged

Grammer Download (2.29.04.12)
Latest update (possibly incomplete)
My pastebin
Spoiler for FileSyst:
FileSyst is an application that provides a folder and filesystem for the TI-83+/84+ calculators. It is designed to be easy to access and use in BASIC, and it can be used to access game files and save data, or to create a command prompt, among other things:

Spoiler for Graphiti:
This is a graph explorer for graph theory. It will require lots of work to finish. Currently you can:
Add/delete vertices
Add edges (direction not shown, but they are directed)
Arrange vertices in a circle (in the future, you will be able to define levels of rings and the number of nodes in each)
Create complete graphs quickly

Plans:
Add adjacency matrix viewer
Deleting edges
Multiple graphs support
Arrows for directed graphs
Planarity testing
Matrix operations
Weighted edges
Chromatic polynomials
Chromatic numbers

Spoiler for Stats:

Samocal             [o---------]
Virtual Processor   [o---------]
EnG                 [oo--------]
Grammer             [ooo-------]
AsmComp             [ooo-------]
Partex              [oooo------]
BatLib              [oooooooo--]
Grammer82           [----------]
Grammer68000        [----------]

Pseudonyms:  Zeda, Xeda, Thunderbolt
Languages:   English, français
Programming: z80 Assmebly
Grammer
TI-BASIC (83/84/+/SE, 89/89t/92)
Known For:   -Creator of the Grammer programming language
(Winning program of zContest2011)
-BatLib- One of the most feature packed libraries for BASIC programmers available
with over 100 functions and a simple programming language
-Learning to program z80 in hexadecimal before using an assembler (no computer was
available!)
╔═╦╗░╠═╬╣▒║ ║║▓╚═╩╝█

 Pages: 1 ... 14 15 [16] 17 18 ... 20   Go Up
Jump to:

Powered by EzPortal
Page created in 0.265 seconds with 32 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.