English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 20 July 2017, 23:25   #1
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
Mem Alloc Bootblock

Hi there,

I would like to alloc mem in order to copy data there. It's a bootblock code as the rest of the program is trackloaded after that from disk to fast mem.
Need approx 100Kbytes in Fast (or Fake Fast) memory.
Can someone explain me how it works ? May be a code sample in asm ?
A method that should work in all Amigas (OCS,ECS,AGA) would be great.
Also, a simple method, please

Thanks,
LeCaravage is offline  
Old 20 July 2017, 23:31   #2
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,017
move.l #size_of_data,d0
move.l #$10004,d1
move.l 4.w,a6
jsr -$c6(a6)

If successful, pointer to the allocated memory space will be passed as a longword in D0, if not succesful, D0 = 0

However, I wouldn't only allocate just fast memory, because if you want your program to work on 1meg chip ram machines, they are less likely to have the fast ram located at $c00000

I typically do this, I try and allocate absolute memory, because from bootup, we can be pretty sure that the middle of the second half of chip ram from booting up the disk is free hence checking for the $c0000 memory range.

And likewise, checking in the middle of fake fast ram $c40000 is a pretty safe bet.

You obviously don't have to use those memory addresses afterwards, you're simply checking that memory type is available, obviously once you know it is, then $80000 would be the start of the second half of 512K chip ram in a 1 meg chip ram machine, and $c00000 is the base address of slow fast ram expansion.

move.l 4.w,a6
move.l #$c0000,a1
jsr -$216(a6)
tst.l d0
beq.s not_1meg_chip

move.l #$c40000,a1
jsr -$216(a6)
tst.l d0
beq.s not_fake_fast

Last edited by Galahad/FLT; 20 July 2017 at 23:45.
Galahad/FLT is offline  
Old 21 July 2017, 09:10   #3
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
Thanks for your fast and detailled reply.

Indeed, going for absolut memory allocs seems to be the best choice.
LeCaravage is offline  
Old 21 July 2017, 20:08   #4
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,658
As long as you will not exit the bootblock to CLI/WB, this is OK for checking what kind of machine you're running on. But even if you don't exit, if you later try to allocate memory, it will now be fragmented (if you use AbsAllocs and don't free it).

Obviously don't use the slowmem (fake fast) check to assume that there's no fastmem in the machine, because lots of Amigas have fastmem without slowmem, and they could still have just the 512K chipmem.

Last edited by Photon; 21 July 2017 at 23:02.
Photon is offline  
Old 21 July 2017, 20:59   #5
Old_Bob
BiO-sanitation Battalion
 
Old_Bob's Avatar
 
Join Date: Jun 2017
Location: Scotland
Posts: 152
Is there no handy system variable tucked away somewhere that has the amount of Chip & Fast RAM that we can read to get an easy answer?

B
Old_Bob is offline  
Old 21 July 2017, 21:08   #6
LeCaravage
Registered User
 
LeCaravage's Avatar
 
Join Date: May 2017
Location: AmigaLand
Posts: 459
@Photon: I won't exit bootblock as the rest of the trackloaded program will turn system off. I have an Amiga 500 KS1.3 + FakeFast (1,8Mb) but I'd like to make the program ECS,AGA compatible.
About the NoFakeFastMem & YesTrueFastMem case, adding to Galahad's code this paragraph will be ok ? :

move.l #$240000,a1
jsr -$216(a6)
tst.l d0
beq.s not_realfastmem
LeCaravage is offline  
Old 21 July 2017, 21:08   #7
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Old_Bob View Post
Is there no handy system variable tucked away somewhere that has the amount of Chip & Fast RAM that we can read to get an easy answer?

B
For max. available CHIP you can use Exec's MaxLocMem, for fast mem AvailMem() does the trick.
StingRay is offline  
Old 21 July 2017, 21:27   #8
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,017
Quote:
Originally Posted by LeCaravage View Post
@Photon: I won't exit bootblock as the rest of the trackloaded program will turn system off. I have an Amiga 500 KS1.3 + FakeFast (1,8Mb) but I'd like to make the program ECS,AGA compatible.
About the NoFakeFastMem & YesTrueFastMem case, adding to Galahad's code this paragraph will be ok ? :

move.l #$240000,a1
jsr -$216(a6)
tst.l d0
beq.s not_realfastmem
Yes, as true fast mem is at $200000 for that machine

Obviously if you were not binning the system right from the start, using allocabs isn't a good idea, but from the bootblock, we can be certain that most of memory is clear and the check will work.
Galahad/FLT is offline  
Old 22 July 2017, 00:22   #9
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,658
Quote:
Originally Posted by LeCaravage View Post
@Photon: I won't exit bootblock as the rest of the trackloaded program will turn system off. I have an Amiga 500 KS1.3 + FakeFast (1,8Mb) but I'd like to make the program ECS,AGA compatible.
About the NoFakeFastMem & YesTrueFastMem case, adding to Galahad's code this paragraph will be ok ? :

move.l #$240000,a1
jsr -$216(a6)
tst.l d0
beq.s not_realfastmem
Real fastmem could basically start anywhere >=$200000. Unless you're doing something very special with it, you shouldn't care whether fastmem is fake or real.

Lots of setups have fastmem at $1000000, $40000000, and even $c80000 (with no RAM at $c00000-$c80000). So you shouldn't rely on fixed addresses.

Quote:
Originally Posted by StingRay View Post
For max. available CHIP you can use Exec's MaxLocMem, for fast mem AvailMem() does the trick.
This will give you available chipmem and fastmem to make decisions.

If you find you need an actual start address for chipmem/fastmem, you can allocate the largest chunk and take the addresses.

If you need the system on for library calls, you're done. Just pass the pointers to the rest of the code. If not, it's safe to round them off to the nearest lower or equal 512K boundary.

Chipmem always starts at address $0. But some bytes are required for the different CPUs. I use $100.w as the start address for the loader.

Last edited by Photon; 22 July 2017 at 01:09.
Photon is offline  
Old 22 July 2017, 00:59   #10
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,017
Quote:
Originally Posted by Photon View Post
Real fastmem could basically start anywhere >=$200000. Unless you're doing something very special with it, you shouldn't care whether fastmem is fake or real.

Lots of setups have fastmem at $1000000, $40000000, and even $c80000 (with no RAM at $c00000-$c80000). So you shouldn't rely on fixed addresses.


This will give you available chipmem and fastmem to make decisions.

If you find you need an actual start address for chipmem/fastmem, you can allocate the largest chunk and take the addresses.

If you need the system on for library calls, you're done. Just pass the pointers to the rest of the code. If not, it's safe to round them off to the nearest lower or equal 512K boundary.

Chipmem always start at address $0. But some bytes are required for the different CPUs. I use $100.w as the start address for the loader.

I use $c0.... but, The Bitmap Brothers are more dope than me, they use $80
Galahad/FLT is offline  
Old 22 July 2017, 11:06   #11
Apollo
Registered User
 
Apollo's Avatar
 
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 138
trap #0 ?
Apollo is offline  
Old 22 July 2017, 11:24   #12
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
Quote:
Originally Posted by Apollo View Post
trap #0 ?
Surely they are careful not to use it if writing code from $80
ross is offline  
Old 22 July 2017, 11:35   #13
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
And stepping through ExecBase->MemList?
You can have a real view of memory mapping and select the best.

Bye
ross
ross 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
bootblock mai support.Apps 7 25 September 2012 11:28
Coding a bootblock Yesideez Coders. General 15 23 May 2010 00:13
Interferon Bootblock Protector Bloodwych Nostalgia & memories 4 12 September 2007 08:50
Anyone like to help understanding this bootblock ??? Joe Maroni Coders. Tutorials 2 15 February 2007 17:33
Bootblock checksum -Rob- Coders. General 5 17 April 2006 15:49

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 14:36.

Top

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