English Amiga Board Newbie question: what is the difference between #-1 and #\$ff?
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 05 May 2020, 06:12 #1 pushead Registered User   Join Date: May 2019 Location: Norway Posts: 14 Newbie question: what is the difference between #-1 and #\$ff? Hi, In the "Compute's Machine Language Programming" book it says: moveq #\$ff,d7 ; Move the value \$FFFFFFFF (the sign-extended version of \$FF) into data register D7. This sounds like a smart way (and fast!) to set all the bits of a register. But if I write this instruction in AsmOne I get an error message 'Out of range 8-bit'. Now, if I instead write 'moveq #-1,d7' it works fine. What is the difference between #\$ff and #-1? And why does not moveq #ff,d7 work at all?
 05 May 2020, 08:07 #2 meynaf son of 68k   Join Date: Nov 2007 Location: Lyon / France Age: 47 Posts: 3,925 That's because \$ff is seen as 255, not -1. If you write moveq #\$ffffffff,d7 then it will work.
05 May 2020, 13:17   #3
Auscoder
Registered User

Join Date: Jan 2019
Location: Brisbane
Posts: 70
Quote:
 Originally Posted by meynaf That's because \$ff is seen as 255, not -1. If you write moveq #\$ffffffff,d7 then it will work.
Because #\$ff in as a long is positive (moveq == moveq.l faster but functionally equivalent to move.l)
#\$ff as a word is still positive (move.w)
#\$ff as a byte is negative (move.b)

#-1 is negative in any type (8/16/32 bits), sign extending to long it remains negative

You may be interested to try in the debugger

Code:
```sub.l d0,d0 ; just clear
move.b #\$ff,d0 ; negative - see N flag is set
ext.w d0 ; still negative - n flag is still set
ext.l d0 ; still negative .... n flag set```
Code:
```sub.l d0,d0 ; just clear
move.w #\$ff,d0 ; positive - see N flag is not set
ext.l d0 ; still positive .. N flag is not set```
#\$ff is always 255. It can also be -1 in the case of a byte.

Try with -1 and see what happens. Hope this helps! seems Abacus has led you astray here!

 05 May 2020, 19:34 #4 pushead Registered User   Join Date: May 2019 Location: Norway Posts: 14 Thanks both of you! Have been playing around with the samples in the debugger and it's getting clearer! Thanks! It makes sense now - when I think of the moveq as a longword instruction which translates #\$FF to 255 and not -1. Still, I think the book is a bit unclear on this subject... Can I complain on a book written back in 1988, hehe!

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Similar Threads Thread Thread Starter Forum Replies Last Post balric support.WinUAE 1 10 May 2017 19:45 turrican3 support.FS-UAE 2 13 March 2014 17:54 Mart support.WinUAE 10 15 December 2006 11:24 immodium New to Emulation or Amiga scene 1 03 November 2005 16:24 deadduck New to Emulation or Amiga scene 11 27 November 2001 18:17

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE         project.AmigaLive     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.Amiga File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     Kinky Amiga Stuff     Collections     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic     Coders. Contest         Coders. Entries Creation     Graphics         Graphics. Work In Progress         Graphics. Finished Work         Graphics. Tutorials     Music         Music. Work In Progress         Music. Finished Work         Music. Tutorials Off Topic     OT - General     OT - Entertainment     OT - Sports     OT - Technical     OT - Gaming

All times are GMT +2. The time now is 17:25.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top