Lamer assembly question

All 680x0 related coding posts in this section please.

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

User avatar
iceman
Captain Atari
Captain Atari
Posts: 182
Joined: Sat Mar 02, 2013 11:03 pm

Lamer assembly question

Postby iceman » Tue Sep 15, 2015 8:37 pm

Hi all. Disclaimer: I AM A LAMER - I haven't done and 68k assembly in 20 years and I've forgotten most of what I know.

I'm trying to write a hello world program in 68k assembly (devpac 3.01) on my Falcon. It works when I use

Code: Select all

   pea hello
   move.w   #9,-(sp)
   trap   #1
   addq.w   #6,sp


but not when I use

Code: Select all

   move.l   hello, -(sp)
   move.w   #9,-(sp)
   trap   #1
   addq.w   #6,-(sp)


What am I doing wrong in the second example?

Thanks, and sorry for the lame question.
Atarian since 1989. Atari 1040STFM, 4MB 520STe with UltraSatan and Unitor N, A dodgy 1 MBSTe that bombs out after a few minutes, and a 14MB 48MHz Falcon 030 with NetUSBee and Soundpool 8 channel DAC. Plus my new MiST!

User avatar
shoggoth
Nature
Nature
Posts: 900
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: Lamer assembly question

Postby shoggoth » Tue Sep 15, 2015 8:41 pm

Code: Select all

   move.l   #hello, -(sp)    ; note the '#'
   move.w   #9,-(sp)
   trap   #1
   addq.w   #6,-(sp)
Ain't no space like PeP-space.

User avatar
iceman
Captain Atari
Captain Atari
Posts: 182
Joined: Sat Mar 02, 2013 11:03 pm

Re: Lamer assembly question

Postby iceman » Tue Sep 15, 2015 8:43 pm

shoggoth wrote:

Code: Select all

   move.l   #hello, -(sp)    ; note the '#'
   move.w   #9,-(sp)
   trap   #1
   addq.w   #6,-(sp)


Oh for the love of Cthulhu.

Thanks!
Atarian since 1989. Atari 1040STFM, 4MB 520STe with UltraSatan and Unitor N, A dodgy 1 MBSTe that bombs out after a few minutes, and a 14MB 48MHz Falcon 030 with NetUSBee and Soundpool 8 channel DAC. Plus my new MiST!

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 659
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Lamer assembly question

Postby dhedberg » Tue Sep 15, 2015 8:47 pm

Your code will push 4 bytes (long word) of data located at the address of hello on to the stack:

Code: Select all

   move.l   hello,-(sp)

What you want to do is to push the actual address of hello on to the stack:

Code: Select all

   move.l   #hello,-(sp)
Daniel, New Beat - http://newbeat.atari.org

User avatar
iceman
Captain Atari
Captain Atari
Posts: 182
Joined: Sat Mar 02, 2013 11:03 pm

Re: Lamer assembly question

Postby iceman » Tue Sep 15, 2015 9:08 pm

dhedberg wrote:Your code will push 4 bytes (long word) of data located at the address of hello on to the stack:

Code: Select all

   move.l   hello,-(sp)

What you want to do is to push the actual address of hello on to the stack:

Code: Select all

   move.l   #hello,-(sp)


That's where I got confuzzled - I didn't realise the # symbol denotes a pointer. I thought it just meant "number".

Thanks for the explanation, it really helped. Maybe in 2-3 years I can code my side-scrolling demo :lol:

I'm too used to high level languages now, I'm spoilt :D
Atarian since 1989. Atari 1040STFM, 4MB 520STe with UltraSatan and Unitor N, A dodgy 1 MBSTe that bombs out after a few minutes, and a 14MB 48MHz Falcon 030 with NetUSBee and Soundpool 8 channel DAC. Plus my new MiST!

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2442
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Lamer assembly question

Postby spiny » Tue Sep 15, 2015 10:13 pm

have you seen the 'Perihelion' tutorials ? they helped me loads to get started.

The Atari ST MC68000 Assembly Language Tutorial v0.84.pdf
You do not have the required permissions to view the files attached to this post.

User avatar
iceman
Captain Atari
Captain Atari
Posts: 182
Joined: Sat Mar 02, 2013 11:03 pm

Re: Lamer assembly question

Postby iceman » Wed Sep 16, 2015 6:56 am

spiny wrote:have you seen the 'Perihelion' tutorials ? they helped me loads to get started.

The Atari ST MC68000 Assembly Language Tutorial v0.84.pdf


I went through the first part, then thought I had enough to dive in with a hello world. How wrong I was!

Thanks for the link.
Atarian since 1989. Atari 1040STFM, 4MB 520STe with UltraSatan and Unitor N, A dodgy 1 MBSTe that bombs out after a few minutes, and a 14MB 48MHz Falcon 030 with NetUSBee and Soundpool 8 channel DAC. Plus my new MiST!

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 717
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Lamer assembly question

Postby mfro » Wed Sep 16, 2015 7:00 am

iceman wrote:
dhedberg wrote:...I didn't realise the # symbol denotes a pointer...


It doesn't. Strictly speaking.

"#" indicates a literal. "immediate value" in m68k assembler speak.

Its the move.l mnemnonic that interprets this immediate value as an address.

Note:

Code: Select all

move 4711,-(sp)
moves the contents of address 4711 to the stack.

Code: Select all

move #4711,-(sp)
moves the immediate value. It's not as obvious when using labels instead.

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

Re: Lamer assembly question

Postby simonsunnyboy » Wed Sep 16, 2015 5:59 pm

Some times it is more readable to use

Code: Select all

pea hello


instead. "Push effective address", e.q. the address of hello in this case. IMHO this is more readable.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

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

User avatar
iceman
Captain Atari
Captain Atari
Posts: 182
Joined: Sat Mar 02, 2013 11:03 pm

Re: Lamer assembly question

Postby iceman » Thu Sep 17, 2015 12:26 pm

simonsunnyboy wrote:Some times it is more readable to use

Code: Select all

pea hello


instead. "Push effective address", e.q. the address of hello in this case. IMHO this is more readable.


Yeah, it looks more readable to me too as long as there isn't any overhead - plus it takes away the # gotcha for idiots like me.

By the way, does anyone have any problems with Devpac 3.01 debugger making their monitor go out of range? Each time I start it it kills my monitor and I have to reboot.
Atarian since 1989. Atari 1040STFM, 4MB 520STe with UltraSatan and Unitor N, A dodgy 1 MBSTe that bombs out after a few minutes, and a 14MB 48MHz Falcon 030 with NetUSBee and Soundpool 8 channel DAC. Plus my new MiST!

User avatar
troed
Atari God
Atari God
Posts: 1350
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Lamer assembly question

Postby troed » Thu Sep 17, 2015 1:28 pm

iceman wrote:By the way, does anyone have any problems with Devpac 3.01 debugger making their monitor go out of range? Each time I start it it kills my monitor and I have to reboot.


IIRC Devpac 3 MonST can only do ST video modes, if your run your Falcon on something else.

/Troed

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 659
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Lamer assembly question

Postby dhedberg » Thu Sep 17, 2015 5:00 pm

troed wrote:
iceman wrote:By the way, does anyone have any problems with Devpac 3.01 debugger making their monitor go out of range? Each time I start it it kills my monitor and I have to reboot.


IIRC Devpac 3 MonST can only do ST video modes, if your run your Falcon on something else.

Hmm, I run Devpac 3.1 on my Falcon along with BlowUp, works in any resolution. Don't think I patched it any way. Noticed that the debugger is named Mon030 and not MonST though.
Daniel, New Beat - http://newbeat.atari.org

User avatar
troed
Atari God
Atari God
Posts: 1350
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Lamer assembly question

Postby troed » Thu Sep 17, 2015 5:14 pm

dhedberg wrote:
troed wrote:
iceman wrote:By the way, does anyone have any problems with Devpac 3.01 debugger making their monitor go out of range? Each time I start it it kills my monitor and I have to reboot.


IIRC Devpac 3 MonST can only do ST video modes, if your run your Falcon on something else.

Hmm, I run Devpac 3.1 on my Falcon along with BlowUp, works in any resolution. Don't think I patched it any way. Noticed that the debugger is named Mon030 and not MonST though.


Aha! :) It's a configuration thing that doesn't seem to be automatic. If I just start Devpac from the 3.10 install I have it will default to use the bin\ folder for executables. That mon.prg has issues. The one in \bin030 works.

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 659
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Lamer assembly question

Postby dhedberg » Thu Sep 17, 2015 7:39 pm

troed wrote:Aha! :) It's a configuration thing that doesn't seem to be automatic. If I just start Devpac from the 3.10 install I have it will default to use the bin\ folder for executables. That mon.prg has issues. The one in \bin030 works.

I think what I did many years ago was to replace mon.prg and gen.ttp in the bin folder with the ones found in the bin030 folder (and remove the "030" from their file names). By doing that you can invoke the Mon030 debugger from within the Devpac environment.
Daniel, New Beat - http://newbeat.atari.org


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 3 guests