Clear up stack noob question

All 680x0 related coding posts in this section please.

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
YQN
Atari nerd
Atari nerd
Posts: 44
Joined: Sat Jul 22, 2017 6:01 pm
Contact:

Clear up stack noob question

Postby YQN » Tue Sep 12, 2017 9:25 am

Hi,

I'm trying to follow Perihelion's tutorials but there's something I'm not sure I understand about "cleaning up stack", such as:

Code: Select all

move.w   #2,-(a7)   get physbase
trap      #14      call XBIOS
addq.l   #2,a7   clean up stack


I have read the first 5 tutorials several times and I figured (or rather guessed) that the last line adds 2 to the stack because in the 1st line a word is put on the stack, so the '-' sign decrements the pointer by 2. Am I right? To "clean up the stack" here means resetting its pointer depending on how many bytes we stacked? Just wanna make sure I'm not going further in the tutorials with wrong understanding!

Thanks for any help!

mikro
Atari God
Atari God
Posts: 1308
Joined: Sat Sep 10, 2005 11:11 am
Location: Brisbane, Queensland, Australia
Contact:

Re: Clear up stack noob question

Postby mikro » Tue Sep 12, 2017 11:36 am

Yep, you've got it figured all right.

User avatar
YQN
Atari nerd
Atari nerd
Posts: 44
Joined: Sat Jul 22, 2017 6:01 pm
Contact:

Re: Clear up stack noob question

Postby YQN » Tue Sep 12, 2017 12:05 pm

Thanks!

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4871
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Clear up stack noob question

Postby simonsunnyboy » Tue Sep 12, 2017 3:10 pm

It is similar to PUSH and POP instructions found on Intel processors.
Otherwise your stack will grow endlessly.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 2 guests