English Amiga Board


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

 
 
Thread Tools
Old 18 December 2015, 22:31   #21
demolition
Unregistered User
 
demolition's Avatar
 
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 43
Posts: 4,190
Quote:
Originally Posted by Mrs Beanbag View Post
Unless you have some specific, strict coding style that handles this sort of thing, i've thought before about what if you want a function to return an object whose size isn't known to the caller and might not be a constant... but i can't think of a neat way to do that anyway without using two stacks.
By having the last item on the stack indicate the size of the object before it?
demolition is offline  
Old 18 December 2015, 23:38   #22
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
Quote:
Originally Posted by demolition View Post
By having the last item on the stack indicate the size of the object before it?
you could do that, but then it would be difficult to access any particular item, you'd have to iterate over all the objects until you got to the right one... my idea was to have a "data stack" and a "pointer stack" and then it would be easy but, wa wa wa,,,
Mrs Beanbag is offline  
Old 19 December 2015, 02:38   #23
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
That's just regular allocation on the heap, and giving the caller the responsibility of cleaning up.
Leffmann is offline  
Old 19 December 2015, 22:03   #24
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
it's only regular allocation on the heap, if you are calling "Allocate" and "Free", but it is simple to just reserve a big lump of memory for a second stack, afterall the main stack itself is allocated on the heap by the OS when it runs your program.
Mrs Beanbag is offline  
Old 20 December 2015, 16:48   #25
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Yes, but allocating on the heap has always been how you solve this, it's not a new problem.

Quote:
Originally Posted by Mrs Beanbag View Post
Unless you have some specific, strict coding style that handles this sort of thing, i've thought before about what if you want a function to return an object whose size isn't known to the caller and might not be a constant... but i can't think of a neat way to do that anyway without using two stacks.
Leffmann is offline  
Old 22 December 2015, 21:04   #26
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
heap allocation is much slower, though. if you know you are going to construct and destroy in strict LIFO order it could be useful to use a second stack for performance benefits, and don't need to involve the operating system.
Mrs Beanbag is offline  
Old 26 December 2015, 17:09   #27
sodapop
Registered User
 
sodapop's Avatar
 
Join Date: Oct 2010
Location: France
Posts: 99
Thanks for your enlightments guys...
While doing the "add.l #60,SP // sub.l #60,SP" worked OK under Devpac, it returned an error code when launching the executable file under the shell or from a bootable floppy disc (from scratch). The code is well executed, but going back to CLI returned a "39718" error, so I will stick with the usual "movem.l d0-d7/a0-a6,-(SP)" OUTSIDE the context saving subroutine...

Last edited by sodapop; 26 December 2015 at 17:31.
sodapop is offline  
Old 27 December 2015, 02:12   #28
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Just return 0 in D0 and you'll get rid of the error message.
Leffmann is offline  
Old 27 December 2015, 09:37   #29
sodapop
Registered User
 
sodapop's Avatar
 
Join Date: Oct 2010
Location: France
Posts: 99
@Leffmann: you're right !
sodapop 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
Inside the Amiga Washac support.Hardware 14 19 February 2010 17:52
movem in debugger Ratte support.WinUAE 2 15 August 2009 23:10
Movem Pickout Amiga fun issue 06 AliasXZ support.Games 0 12 August 2009 00:32
Something like Movem MarlboroMan Looking for a game name ? 2 10 October 2004 12:47
Movem & 3D Motorrad (Amiga Mania) andreas request.Old Rare Games 6 26 September 2004 01:29

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 05:11.

Top

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