Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 June, 2013, 13:00:04 *
Welcome, Guest. Please login or register.

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.

Poll
Question: I would like to expand some drawing commands! What syntax do you prefer for:   [1] Horizontal and vertical lines? [2] White and xor drawing?   Please pick ONE [1] option and ONE [2] option.
[1] Prefix with letters:   HLine(Y,X1,X2)  and  VLine(X,Y1,Y2) - 16 (26.7%)
[1] Overload shift commands:   Horizontal(Y,X1,X2)  and  Vertical(X,Y1,Y2) - 3 (5%)
[1] Use Horiz and G-T:   Horiz(Y,X1,X2)  and  Vert(X,Y1,Y2) - 6 (10%)
[1] Use LinReg(a+bx)  and LinReg(ax+b) :   HLine(Y,X1,X2)  and  VLine(X,Y1,Y2) - 4 (6.7%)
[1] Use LinReg(a+bx)  and LinReg(ax+b) :   Horiz(Y,X1,X2)  and  Vert(X,Y1,Y2) - 2 (3.3%)
[1] Other:   Please specify in a post! - 0 (0%)
[2] Use letter modifiers W and X:   e.g.  WHLine(Y,X1,X2),  WRect(X,Y,W,H),  XLine(X1,Y1,X2,Y2),  XCircle(X,Y,R) - 20 (33.3%)
[2] Use symbol modifiers ! and i:   e.g.  !HLine(Y,X1,X2),  !Rect(X,Y,W,H),  iLine(X1,Y1,X2,Y2),  iCircle(X,Y,R) - 9 (15%)
[2] Other:   Please specify in a post! - 0 (0%)
Total Voters: 32

Pages: 1 2 [3] 4 5 ... 146   Go Down
  Print  
Author Topic: Axe Parser -  (Read 123046 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 10:48:29
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Topic starter
Total Post Ratings: +1019

View Profile
« Reply #30 on: 04 February, 2010, 00:45:25 »
0

When I said fast, I didn't expect unrolled fast Wink  I'd prefer the smallest code possible that doesn't use a naive method.

I think I see the pattern though.  I can just figure out how to roll it up again. 

Here is the super efficient HL*DE multiplication routine I'm using, only 14 bytes  Smiley  The real routine is a little bit bigger just because it has to find which of the two arguments is smallest and exchange them if necessarily.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
_DE_Times_L:
xor a
ld h,a
ld a,l
ld l,h
_Loop:
rra
jr nc,_Skip
add hl,de
_Skip:
sla e
rl d
or a
jr nz,_Loop
ret
Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:09:04
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2737


Total Post Ratings: +376

View Profile
« Reply #31 on: 04 February, 2010, 00:51:25 »
+1

Hold up, found a more efficient method (and I put it into loops just for you Grin)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
div_hl_de:
; BC = HL/DE, HL = remainder

xor a
sub e
ld e,a
sbc a,a
sub d
ld d,a

ld a,h
ld b,l
ld hl,0
ld c,8

div_loop_1:
rla
adc hl,hl
add hl,de
jr c,$+4
sbc hl,de
dec c
jr nz,div_loop_1
rla

ld c,a
ld a,b
ld b,8

div_loop_2:
rla
adc hl,hl
add hl,de
jr c,$+4
sbc hl,de
djnz div_loop_2
rla

ld b,a
ret
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
ztrumpet
The Rarely Active One
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 11 June, 2013, 05:10:51
Date Registered: 08 November, 2009, 21:10:12
Location: Michigan
Posts: 5688


Total Post Ratings: +360

View Profile
« Reply #32 on: 04 February, 2010, 02:46:14 »
0

That's awesome code!  Grin Great job on it, though I only kinda understand. (The time for explaining is not now, so you don't need to explain it to me now. Smiley )
« Last Edit: 04 February, 2010, 02:46:33 by ztrumpet » Logged

Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 10:48:29
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Topic starter
Total Post Ratings: +1019

View Profile
« Reply #33 on: 04 February, 2010, 06:11:55 »
0

Thanks for that division routine, but I found this one and its a lot smaller.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
HL_div_DE:
ld a,h
ld c,l
ld hl,0
ld b,16
__DivLoop:
sll c
rla
adc hl,hl
sbc hl,de
jr nc,__DivSkip
add hl,de
dec c
__DivSkip:
djnz __DivLoop
ld h,a
ld l,c
ret

I'm just a little bit worried about the use of the sll command, will that sacrifice compatibility with the Nspire?
« Last Edit: 04 February, 2010, 06:12:44 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:09:04
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2737


Total Post Ratings: +376

View Profile
« Reply #34 on: 04 February, 2010, 06:45:58 »
0

Thanks for that division routine, but I found this one and its a lot smaller.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
HL_div_DE:
ld a,h
ld c,l
ld hl,0
ld b,16
__DivLoop:
sll c
rla
adc hl,hl
sbc hl,de
jr nc,__DivSkip
add hl,de
dec c
__DivSkip:
djnz __DivLoop
ld h,a
ld l,c
ret

I'm just a little bit worried about the use of the sll command, will that sacrifice compatibility with the Nspire?
You are correct. You can replace it with "scf \ rl c" though

Edit:
Also, if you haven't done this already, I'd like to suggest that you auto-generate multiplication algorithms when multiplying by constants. Like A*9 would become:

1
2
3
4
5
6
7
ld hl,(var_a)
ld d,h
ld e,l
add hl,hl
add hl,hl
add hl,hl
add hl,de
« Last Edit: 04 February, 2010, 06:56:42 by calc84maniac » Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
Silver Shadow
Beta Tester
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 21 December, 2011, 21:23:08
Date Registered: 03 October, 2008, 17:34:52
Location: France
Posts: 799


Total Post Ratings: +20

View Profile
« Reply #35 on: 04 February, 2010, 14:56:41 »
0

Thanks for that division routine, but I found this one and its a lot smaller.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
HL_div_DE:
ld a,h
ld c,l
ld hl,0
ld b,16
__DivLoop:
sll c
rla
adc hl,hl
sbc hl,de
jr nc,__DivSkip
add hl,de
dec c
__DivSkip:
djnz __DivLoop
ld h,a
ld l,c
ret

I'm just a little bit worried about the use of the sll command, will that sacrifice compatibility with the Nspire?
I definitely want this to work on the NSpire, so could you use another method instead?
Logged

Former Coder of Tomorrow

Eeems
THE GAME
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: Today at 05:46:11
Date Registered: 14 March, 2009, 03:32:57
Location: Edmonton, Alberta
Posts: 5103


Total Post Ratings: +231

View Profile WWW
« Reply #36 on: 04 February, 2010, 16:40:15 »
0

 think calc84 gave a way that works.
Logged

Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 10:48:29
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Topic starter
Total Post Ratings: +1019

View Profile
« Reply #37 on: 04 February, 2010, 23:04:22 »
0

Yeah, its only one byte more for the compatibility.  Worth it. Wink

Quote
Also, if you haven't done this already, I'd like to suggest that you auto-generate multiplication algorithms when multiplying by constants.
I probably will for powers of 2, but I don't think there will really need to be such high speed math operations, I mean, I don't think anyone will be making a first person shooter or anything.  But I guess if a few microseconds are important enough to account for the program size increase, you can always add some Hex code to do the faster multiplication.
Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 10:47:05
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50634


Total Post Ratings: +2637

View Profile WWW
« Reply #38 on: 05 February, 2010, 01:48:34 »
+1

I am confused by what this means. Does it means it would be only possible to mutiply by 2, 4 and the like? It might become an issue for example if I did a small RPG where your max HP and attack power was like 101 x character LV
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 10:48:29
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Topic starter
Total Post Ratings: +1019

View Profile
« Reply #39 on: 05 February, 2010, 01:54:02 »
0

No, no, it just means that multiplying by powers of 2 will use a smaller, faster code that multiplying the regular way.  Its just an optimization.  Even things like +1 and +2 can be optimized.

Probably won't be in the next release, but I'll get to automatic optimizations eventually.
Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:09:04
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2737


Total Post Ratings: +376

View Profile
« Reply #40 on: 05 February, 2010, 01:54:17 »
0

I am confused by what this means. Does it means it would be only possible to mutiply by 2, 4 and the like? It might become an issue for example if I did a small RPG where your max HP and attack power was like 101 x character LV
He's just saying that it would be slower to multiply by anything else because it would call a general routine instead of adding manually

Edit: Ninjaaaaa
« Last Edit: 05 February, 2010, 01:54:47 by calc84maniac » Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 10:47:05
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50634


Total Post Ratings: +2637

View Profile WWW
« Reply #41 on: 05 February, 2010, 01:55:03 »
+1

aaaah ok, I see, thanks for clarifying
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 08:32:53
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5645


Total Post Ratings: +589

View Profile
« Reply #42 on: 05 February, 2010, 01:55:27 »
0

I think (but i'm not sure) is that when multiplying by any arbitrary number, it uses the general multiplication routine, but when multiplying by 2, you use the dedicated x2 routine?

EDIT: nice Ninja there Quigibo Tongue
EDIT2: Double ninja  Shocked
EDIT3: Damn Triple ninja Sad
Logged

Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 10:48:29
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Topic starter
Total Post Ratings: +1019

View Profile
« Reply #43 on: 05 February, 2010, 01:57:40 »
0

I think (but i'm not sure) is that when multiplying by any arbitrary number, it uses the general multiplication routine, but when multiplying by 2, you use the dedicated x2 routine?

Correct.  The general x2 routine is to add the number to itself Tongue
« Last Edit: 05 February, 2010, 01:58:13 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 10:47:05
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50634


Total Post Ratings: +2637

View Profile WWW
« Reply #44 on: 05 February, 2010, 09:49:00 »
+1

I removed all replies from the updates thread and moved them here.
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Pages: 1 2 [3] 4 5 ... 146   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.878 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.