English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 28 June 2008, 22:23   #41
Belgarath
HOL Team Member

Belgarath's Avatar
 
Join Date: Dec 2001
Location: Manchester
Posts: 2,392
You ever going to fix the typo in the thread title?
Belgarath is offline  
AdSense AdSense  
Old 28 June 2008, 22:27   #42
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 42
Posts: 8,621
No it makes the thread title unique
BippyM is offline  
Old 28 June 2008, 22:39   #43
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by bippym View Post
so it is allocating 78bytes of best-Available ram!
Close but no cigar It's allocating cleared mem.

Quote:
Hmmm.. i'm figuring stack out more than anything.. it's the movem.l(4,sp)d0/d1 as I presume it adds 4 to the stack.. which is kinda backwards to me
The 4(a7) is just to get the right things from the stack. When calling a subroutine the return address is pushed onto the stack thus the offset to skip that very return address. If the Allocmem would have been called directly (i.e. without any jsr) you would not need the offset, you would do "movem.l (a7),d0/d1" to get the parameters. Play a bit around in a debugger, call a subroutine and watch the stack, then you should understand what's going on.
StingRay is offline  
Old 28 June 2008, 22:41   #44
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 42
Posts: 8,621
how big is the amiga stack when not defined?
BippyM is offline  
Old 28 June 2008, 23:17   #45
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 42
Posts: 8,621
Ok nobody answered so I'm gonna take a stab in the dark at 4096bytes, unless modified in the icon tooltypes or using the stack command

I guess this game uses amigaos quite a bit. where is the stack located?
BippyM is offline  
Old 29 June 2008, 00:07   #46
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 42
Posts: 8,621
if the program dos the following

Code:
START
    JMP ADDY1

    <code>

ADDY1    move.l sp,address

    <code>

    move.l address,sp

    RTS
Now from the start of the program what exactly does the SP contain because it is saved and then used later!
BippyM is offline  
Old 29 June 2008, 10:54   #47
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 19,945
Quote:
Originally Posted by bippym View Post
Ok nobody answered so I'm gonna take a stab in the dark at 4096bytes, unless modified in the icon tooltypes or using the stack command
Default is 4096, very small.. Always set bigger stack or you will have problems with many programs.

Quote:
I guess this game uses amigaos quite a bit. where is the stack located?
Stack is per process/task and is dynamically allocated when process/task is created. Stack start and end pointers are located in Task structure if you really want to know but it is not normally needed.
Toni Wilen is offline  
Old 29 June 2008, 12:06   #48
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Quote:
Originally Posted by bippym View Post
if the program dos the following

Code:
START
    JMP ADDY1

    <code>

ADDY1    move.l sp,address

    <code>

    move.l address,sp

    RTS
Now from the start of the program what exactly does the SP contain because it is saved and then used later!

This is probably just to save the current stack pointer and restore it later when the program ends. E.g.
Code:
START   lea     InitialStack(pc),a0
        move.l  a7,(a0)                 ; store sp
        bsr     alotofthings
        ....
        
END     move.l  InitialStack(pc),a7     ; restore sp
        ...                             ; some other cleanup stuff
        rts
I do something like this in my demosystem f.e.
StingRay is offline  
Old 30 June 2008, 16:03   #49
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 42
Posts: 8,621
The game uses a lot of LINK etc and the game accesses the register that is linked alot and I need to follow what it is doing

Anyway have the following code, which loads the system prefs, then modifies I think and saves them back.

Code:
lbC0040AA    LINK.W    A5,#-4
    MOVEM.L    D2/D3/A6,-(SP)
    PEA    ($E8).W
    PEA    (_PrefBuffer).L
    JSR    (_GetPrefs).L
    ADDQ.W    #8,SP
    PEA    ($E8).W
    PEA    (_PrefBuffer2).L
    JSR    (_GetPrefs).L
    ADDQ.W    #8,SP
    CLR.L    (-4,A5)
lbC0040DA     MOVE.L    (-4,A5),D0
    ASL.L    #1,D0
    LEA    (lbL024E98).L,A0
    CLR.W    (A0,D0.L)
    ADDQ.L    #1,(-4,A5)
    CMPI.L    #$24,(-4,A5)
    BLT.B    lbC0040DA
    CLR.L    -(SP)
    PEA    ($E8).W
    PEA    (_PrefBuffer2).L
    JSR    (lbC009AD4).L
    LEA    (12,SP),SP
    MOVEM.L    (SP)+,D2/D3/A6
    UNLK    A5
    RTS
Now I have started inserting labels, and if you want to see the _GetPrefs routine let me know, all it does is put $e8 into d0 and points a0 to either prefbuffer or prefbuffer2 then executes _LVOGetPrefs

The lines i'm unsure of I have made bold. If you could tell me what is happening, andf why there is stuff like clr.l -4.a5 etc.. why is it doing the -4? what is a5 pointing to?

Thanks
BippyM is offline  
Old 30 June 2008, 16:05   #50
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Don't be so impatient I just answered that question in a pm :P
StingRay is offline  
Old 30 June 2008, 16:17   #51
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 42
Posts: 8,621
hehehe sorry thoght you was busy, and I have work in an hour
BippyM is offline  
Old 30 June 2008, 16:59   #52
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
I just had a meeting and thus couldn't reply immediately :P

Last edited by StingRay; 30 June 2008 at 22:31. Reason: typo fixx0red :)
StingRay is offline  
Old 30 June 2008, 21:51   #53
Hungry Horace
Wipe-Out Enthusiast

Hungry Horace's Avatar
 
Join Date: Nov 2005
Location: .
Age: 36
Posts: 2,478
any chance of seeing a copy of that reply for the sake of those of us who like to learn?
Hungry Horace is offline  
Old 30 June 2008, 22:33   #54
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,591
Of course, no problem! Here's what I wrote to bippym:

A5 is the ptr to the local variables that is created using the LINK instruction at the beginning. As you can see, it's just a simple counter and the clr instruction is just to initialise the counter. In "normal" (i.e. not produced by a compiler) asm it could look like:

Code:
lbC0040DA
        MOVE.L  .counter(pc),D0
        ASL.L   #1,D0
        LEA     (lbL024E98).L,A0
        CLR.W   (A0,D0.L)
        ADDQ.L  #1,.counter
        CMPI.L  #$24,.counter
        BLT.B   lbC0040DA
        ...
.counter        dc.l 0
That should be a bit easier to understand I hope.
StingRay is offline  
Old 02 July 2008, 17:31   #55
Wepl
Moderator
Wepl's Avatar
 
Join Date: Nov 2001
Location: Germany
Posts: 641
this program is compiled using Aztec-C, if you are using ReSource you should 'run the .rcl file' CFuncs.rcl supplied with ReSource.
this will name most Compiler and clib stuff

PS: the usage of frestore is 68060 incompatible (workaround in the 68060.library) because the stackframe (size) has changed

Last edited by Wepl; 02 July 2008 at 17:37.
Wepl 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
Darkmere WHD Problem Steve support.Games 7 06 March 2013 16:46
Possible problem with Battle Squadron WHD jimmy2x2x project.WHDLoad 8 20 May 2011 22:08
WHD-Problem Cannibalpinhead support.Games 1 14 November 2005 20:16
WHD Games Problem Shinobi support.WinUAE 2 24 September 2003 12:24
Same problem w several WHD installs benjamin79 support.Games 6 30 November 2002 22:14

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 13:54.


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