English Amiga Board


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

 
 
Thread Tools
Old 22 March 2010, 13:32   #41
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Quote:
Originally Posted by StingRay
See, I knew you can do it. Cool!
Thanks man - it means a lot for you to have faith in me.

Gotta say again though - if it weren't for your insights I couldn't have done it. So thanks.

EDIT: Still no work on CIA timer routine but newly shaved versions attached...

444 bytes, 796 bytes and 806 bytes respectively.

EDIT: Non CIA amended versions removed.

Last edited by pmc; 22 March 2010 at 14:45.
pmc is offline  
AdSense AdSense  
Old 22 March 2010, 14:47   #42
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
CIA timer routine amended and a couple of other small amendments. I think all size optimising is done on these now - I can't currently see anything else.

New sizes are: 434, 786 and 796 bytes respectively.

Last edited by pmc; 22 March 2010 at 16:24.
pmc is offline  
Old 22 March 2010, 14:53   #43
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by pmc View Post
I think all size optimising is done on these now
move.b #0,d5 ;set track 0 as current track
move.w #71,d7 ;head settle time

Sorry.

Edit:
move.l (a3),d0 ;MFM coded sector header to d0
move.l 4(a3),d1 ;and d1

Sorry again.

Last edited by StingRay; 22 March 2010 at 15:02.
StingRay is offline  
Old 22 March 2010, 15:33   #44
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
LOL.

No worries mate.

I was thinking while I ate my lunch today that there might be another lea in there somewhere I could do without... Not sure on this, need to check.

And in the meantime you've supplied some more savings.
pmc is offline  
Old 22 March 2010, 15:42   #45
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by pmc View Post
And in the meantime you've supplied some more savings.
Some (not so) subtle hints: moveq/sf; movem.l


Good job btw! Nicely size optimized loader you have now! =)
StingRay is offline  
Old 22 March 2010, 16:25   #46
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
OK. Turned out I could remove another lea. So, that plus Sting's other size savings means there's now a 424 byte version attached.

Last edited by pmc; 22 March 2010 at 18:35.
pmc is offline  
Old 22 March 2010, 16:36   #47
Asman
68k

Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 628
I have questions.
For what or why stack pointer and supervisor stack pointer are relocated ? In other words I don't understand code between comments ( ;Relocate stack pointers and ;Setup disk controls.
Is possible to remove that code ?
Asman is offline  
Old 22 March 2010, 16:36   #48
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Nice! In case you wonder why I mentioned movem.l, I would have replaced
move.l (a3),d0
move.l 4(a3),d1

with
movem.l (a3),d0/d1

as I didn't check if a3 could be trashed or not.

Also, it's better to use meaningful offsets for the CIA accesses, e.g.

move.b #%01111111,ciabicr-ciabprb(a6)
instead of
move.b #%01111111,3072(a6)

as that's pretty much unreadable. Let the assembler calculate the offsets.
StingRay is offline  
Old 22 March 2010, 16:40   #49
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
@ Sting - you replied just while I was replying.

Regarding your extra stuff - agreed. I did intend (honest!) to change those evil offsets so, like you say, it's more readable.

I'll do that soon.

Regarding a3 - I have to add offsets to it after those moves so I wouldn't want a3 to be trashed. Would your suggested movem trash a3 then or I have misunderstood...?

@ Asman - All I'm doing is moving the stack pointers low in memory (below where the disk buffers are...) so that I know where they are and they can't accidentally get overwritten by what gets read off the disk into memory.
pmc is offline  
Old 22 March 2010, 16:44   #50
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by pmc View Post
Regarding what your extra stuff - agreed. I did intend (honest!) to change those evil offsets so, like you say, it's more readable.
No problem, thought you didn't know how to do it so I mentioned it. =)
Remember: boring stuff -> let the assembler do it.
Another advantage is that you always know which CIA base register ax points to as it's used in the offset calculations (e.g. ciabicr-ciabprb(a6) -> a6 = ciabprb)


Quote:
Originally Posted by pmc View Post
Regarding a3 - I have to add offsets to it after those moves so I wouldn't want a3 to be trashed. Would your suggested movem trash a3 then or I have misunderstood...?
My movem.l version does exactly the same as your move.l (a3),d0 move.l 4(a3),d1 approach, it's just shorter. In other words, a3 is not trashed.
StingRay is offline  
Old 22 March 2010, 16:50   #51
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Quote:
Originally Posted by StingRay
My movem.l version does exactly the same as your move.l (a3),d0 move.l 4(a3),d1 approach, it's just shorter. In other words, a3 is not trashed.
More savings! \o/

Nice one.
pmc is offline  
Old 22 March 2010, 16:52   #52
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,953
Quote:
Originally Posted by pmc View Post
@ Asman - All I'm doing is moving the stack pointers low in memory (below where the disk buffers are...) so that I know where they are and they can't accidentally get overwritten by what gets read off the disk into memory.
Nothing prevents your bootblock code getting overwritten by your relocated stacks
Toni Wilen is offline  
Old 22 March 2010, 16:54   #53
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by pmc View Post
More savings! \o/

Nice one.
I don't think so because your
move.l (a3)+,d0 ;MFM coded sector header to d0
move.l (a3),d1 ;and d1

is fine and also 4 bytes (just liked the movem version)


Quote:
Originally Posted by Toni Wilen View Post
Nothing prevents your bootblock code getting overwritten by your relocated stacks
Yup.
StingRay is offline  
Old 22 March 2010, 16:54   #54
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Hey Stinger - just noticed that movem.l (a3),d0/d1 is the same length as what I changed that code to, namely:

move.l (a3)+,d0
move.l (a3),d1

So, as it turns out, not another saving...

Toni - you're right - any way this *can* be prevented...?
pmc is offline  
Old 22 March 2010, 16:56   #55
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by pmc View Post
Hey Stinger - just noticed that movem.l (a3),d0/d1 is the same length as what I changed that code to, namely:

move.l (a3)+,d0
move.l (a3),d1

So, as it turns out, not another saving...
I replied already. :P

Quote:
Originally Posted by pmc View Post
Toni - how come? Stacks grow downwards don't they so how can they overwrite the stuff loaded of disk that's "above" the stacks in memory?
What Toni means is, your bootblock can be loaded anywhere in memory by the OS so you don't really know where your code is located and thus it can be trashed by your loader. Copy the complete bootblock code to some location in highmem (f.e.) and execute it then.
StingRay is offline  
Old 22 March 2010, 17:01   #56
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Yeah, I edited my post as I'd cottoned onto what Toni meant.

Thanks guys.
pmc is offline  
Old 22 March 2010, 17:03   #57
Asman
68k

Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 628
Quote:
Originally Posted by pmc View Post
@ Asman - All I'm doing is moving the stack pointers low in memory (below where the disk buffers are...) so that I know where they are and they can't accidentally get overwritten by what gets read off the disk into memory.
Maybe easier is to use exec function AllocMem instead of relocate stack pointers.
Asman is offline  
Old 22 March 2010, 17:03   #58
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,953
These kinds of low memory "relocations" are one cause for games and demos that only work if number of external drives = <some specific number that coder had>. Do not do that
Toni Wilen is offline  
Old 22 March 2010, 17:05   #59
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
@ Asman - OS functions are for wimps!

Seriously though, worth considering - thanks.

Toni - I bow to your superior knowledge.
pmc is offline  
Old 22 March 2010, 17:08   #60
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by Asman View Post
Maybe easier is to use exec function AllocMem instead of relocate stack pointers.
Not really the best idea when the system is completely killed. Besides, relocating stacks is nothing bad.
Edit: As long as the system is completely killed and you don't plan to return to the OS.

Quote:
Originally Posted by Toni Wilen View Post
These kinds of low memory "relocations" are one cause for games and demos that only work if number of external drives = <some specific number that coder had>. Do not do that
And while we are at it, also don't forget to flush caches on CPU's >=68020 after you copied your bootblock to some safe location in memory (call Exec's CacheClearU(), only works on Kick 2.0+ though).

Last edited by StingRay; 22 March 2010 at 17:14. Reason: some additions
StingRay is offline  
AdSense AdSense  
 


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 22:56
Game loader stuck on certain track after save state restore andreas support.WinUAE 2 26 March 2011 20:59
Can't transfer Supaplex cause of CSL track loader ! Vollldo support.Games 4 12 March 2011 22:51
Hardware File Loader h0ffman Coders. General 9 02 December 2010 17:40
mfm/custom regs/track loader snyp Coders. General 9 06 June 2006 20: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 16:06.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.26447 seconds with 13 queries