English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 23 March 2010, 12:20   #101
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596


That's why I was being dumb - I didn't even realise sf.b was a valid mnemonic!!

I'd never come across it before!

You're still the man Sting.
pmc is offline  
Old 23 March 2010, 12:41   #102
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Tested as working 410 byte version attached.

StingRay is officially a legend.

Last edited by pmc; 23 March 2010 at 20:11.
pmc is offline  
Old 23 March 2010, 13:22   #103
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 43
Posts: 2,351
Code:
move.w #%0111111111111111,d0
move.w d0,intena(a5)
move.w d0,dmacon(a5)
move.w d0,intreq(a5)
Code:
move.l #%01111111111111110111111111111111,d0
move.l d0,intena(a5)
move.w d0,dmacon(a5)
Doesn't save any bytes...? but could save you some memory cycles

Asman could be onto something with his $4489 in a register idea, but it might just trade off ? Damn, my kingdom for an assembler
musashi5150 is offline  
Old 23 March 2010, 13:35   #104
korruptor
TDI
 
korruptor's Avatar
 
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
Best thread ever
korruptor is offline  
Old 23 March 2010, 13:39   #105
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by musashi5150
Doesn't save any bytes...?
Does actually - two.

Are you aiming to take the "legend" crown?!

Quote:
Originally Posted by musashi5150
Asman could be onto something with his $4489 in a register idea, but it might just trade off ?
But does this work putting $4489 into an *address* register as suggested rather than a data register?

In an address registers $4489 means something very different, no?
pmc is offline  
Old 23 March 2010, 13:40   #106
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 829
Quote:
Originally Posted by musashi5150 View Post
Asman could be onto something with his $4489 in a register idea, but it might just trade off ? Damn, my kingdom for an assembler
I thought about something like that

Code:
; Setup disk controls

	move.w	#$4489,a1
	move.w	a1,dsksync(a5)		;MFM sync mark

...

.seek_hdr_strt:	cmp.w	a1,(a3)+		;find start of sector
	bne.s	.seek_hdr_strt
	cmp.w	a1,(a3)
This should save some bytes.
Asman is offline  
Old 23 March 2010, 13:44   #107
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
OK guys - musashi5150's extra two byte saving has been implemented - trackloader now standing at 408 bytes.

I'll investigate Asman's suggestion after I've eaten some lunch.

New version to come...
pmc is offline  
Old 23 March 2010, 13:52   #108
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,574
Disk DMA enable/disable and DSKLEN $4000 writes can be removed. (Perhaps it is recommend somewhere but there really isn't any difference unless you need to abort active DMA)
Toni Wilen is online now  
Old 23 March 2010, 14:18   #109
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
I have a "clean" (i.e. Disk DMA still enabled etc) 402 bytes version. Once I can kill the last 2 bytes I won't touch this code again.
StingRay is offline  
Old 23 March 2010, 14:34   #110
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
398 bytes version attached. More can be done but I think I did my fair share of killing bytes.

Edit: just noticed there was a small bug in the init part (move.l/move.w) which I introduced when I applied Musashi's optimization. Fixed version attached. =)
Attached Files
File Type: 68k opt_bb_trkldr_sting.68k (9.4 KB, 216 views)

Last edited by StingRay; 23 March 2010 at 14:58.
StingRay is offline  
Old 23 March 2010, 14:34   #111
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by StingRay
I have a "clean" (i.e. Disk DMA still enabled etc) 402 bytes version.
Massive power!

The king wants to keep his crown!

Edit:

Quote:
Originally Posted by StingRay
398 bytes version attached. More can be done but I think I did my fair share of killing bytes.


Even more power!
pmc is offline  
Old 23 March 2010, 14:40   #112
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 829
We can do another one dirty trick to save some bytes (probably). Just replace
Code:
	lea	cust_regs,a5
into
Code:
	lea	cust_regs+dsklen,a5
and change all references to a5. ( for example all dsklen(a5) ---> (a5) )
Asman is offline  
Old 23 March 2010, 14:43   #113
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
Quote:
Originally Posted by Asman View Post
We can do another one dirty trick to save some bytes (probably). Just replace
Code:
    lea    cust_regs,a5
into
Code:
    lea    cust_regs+dsklen,a5
and change all references to a5. ( for example all dsklen(a5) ---> (a5) )
Did you check my attached version?
StingRay is offline  
Old 23 March 2010, 14:45   #114
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 829
Ahhhhh..... Yeeaah. You did that. Awesome
Asman is offline  
Old 23 March 2010, 14:48   #115
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
Quote:
Originally Posted by Asman View Post
Ahhhhh..... Yeeaah. You did that. Awesome
Almost. I did lea dsklen(a5),a0 as I wanted to keep the code at least somewhat readable. Your approach would be smaller (as no additional lea instruction is required) but I didn't do it like that for reasons already mentioned.
StingRay is offline  
Old 23 March 2010, 14:55   #116
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,549
Quote:
Originally Posted by StingRay View Post
398 bytes version attached. More can be done but I think I did my fair share of killing bytes.
Oh no... no PRINTV! Now I cannot assemble it any longer!

Great stuff! I didn't expect that to go lower than 400 bytes!

Some more. You can deselect and disable the diskmotor bit at once:
Code:
trkld_done:    bset.b  #3,(a6)         ;deselect df0:
        bset.b  #7,(a6)         ;dskmotor high
-->
trkld_done:   or.b    #%10001000,(a6)
phx is offline  
Old 23 March 2010, 14:56   #117
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 829
Quote:
Originally Posted by StingRay View Post
Almost. I did lea dsklen(a5),a0 as I wanted to keep the code at least somewhat readable. Your approach would be smaller (as no additional lea instruction is required) but I didn't do it like that for reasons already mentioned.
I just realized that. The code should be readable, we can change all equates for custom registers Or better some tool should do this ( first analyze code and count what should be replaced ).
Asman is offline  
Old 23 March 2010, 15:00   #118
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
This has been a really interesting experience for me.

I'm starting to see now that once you get right down to trying to wring every last space saving out of a piece of code that you start getting into a trade off for those size decreases in terms of both readability of the code and also speed of execution of that code.

As a middle way I think that the version of this code I actually use going forward will be the one I think has the right balance of these trade offs for me personally.
pmc is offline  
Old 23 March 2010, 15:01   #119
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,865
Quote:
Originally Posted by phx View Post
Oh no... no PRINTV! Now I cannot assemble it any longer!
I have attached a new version for you Asm1 haters. :P Hooray for MACRO power. \o/ :P
Attached Files
File Type: 68k opt_bb_trkldr_sting.68k (9.5 KB, 195 views)
StingRay is offline  
Old 23 March 2010, 15:04   #120
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 829
Quote:
Originally Posted by pmc View Post
This has been a really interesting experience for me.
For me too. Now I understand the power of equates in source. ( I always use #include "hardware/custom.i" ).
Asman is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
HD loader example st! Coders. General 4 16 October 2012 21:56
Game loader stuck on certain track after save state restore andreas support.WinUAE 2 26 March 2011 19:59
Can't transfer Supaplex cause of CSL track loader ! Vollldo support.Games 4 12 March 2011 21:51
Hardware File Loader h0ffman Coders. General 9 02 December 2010 16:40
mfm/custom regs/track loader snyp Coders. General 9 06 June 2006 19:42

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:53.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10475 seconds with 14 queries