English Amiga Board


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

 
 
Thread Tools
Old 04 March 2023, 16:13   #241
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by remz View Post
Curiosity: Why were 6 bits allocated to shift&rotate instructions instead of 5?
Is there any practicality to rotate more than 32?
More than 32 isn't really interesting, but 32 itself can be. And you need 6 bits to represent that value.
It needs verification, but i think it is really 5 for rotates and 6 only for shifts.
meynaf is offline  
Old 04 March 2023, 17:10   #242
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
They're all 6-bit (it was tested on real hw, a500 68000): they all take tbe same number of cycles.
a/b is offline  
Old 04 March 2023, 17:13   #243
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,135
Being able to shift 6 bits makes sense if you are thinking of some future 64-bit wide register implementation. Although that probably wasn't the actual reason.
Karlos is online now  
Old 04 March 2023, 17:18   #244
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Only logical reason is ability to shift by 32. With 5-bit, range is only 0-31.
meynaf is offline  
Old 04 July 2023, 07:56   #245
mschulz
Registered User
 
Join Date: Nov 2018
Location: Germany
Posts: 110
Quote:
Originally Posted by meynaf View Post
Only logical reason is ability to shift by 32. With 5-bit, range is only 0-31.
This, and also ROXL/ROXR rotations, where CPU deals with 33-bit number.
mschulz is offline  
Old 06 July 2023, 07:40   #246
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by mschulz View Post
This, and also ROXL/ROXR rotations, where CPU deals with 33-bit number.
Didn't think about it, but indeed, there maxing out at 31 would have missed something.
Actually, it is of course 9, 17 or 33 bits depending on the size.
One could think it is logical to cut at 6-bit for .l, 5-bit for .w, 4-bit for .b, but it's not what the cpu does - it's always 6 regardless of the operand size.
Note that PowerPC uses 6 bits as well, but not x86 (didn't check though, this is what i've read).
meynaf is offline  
Old 06 July 2023, 09:58   #247
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by meynaf View Post
.., but not x86 (didn't check though, this is what i've read).
From this page: https://c9x.me/x86/html/file_module_x86_id_273.html
it seems that starting from Intel 286 processor, the rotation is masked to 5 bits. and the masking is done in all operating modes, including the virtual-8086 mode (see note at the bottom of the page).
EDIT: of course the same for shift instructions (https://c9x.me/x86/html/file_module_x86_id_285.html)
I've written code for x86 several times, in a distant past, but never bothered about it and probably never considered it. Nice sh*t...

But we are off-topic

Last edited by ross; 06 July 2023 at 10:05.
ross is offline  
Old 17 September 2023, 11:07   #248
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Based on this 6502 routine:

Code:
;Divide by 24 for 6502 CPU
;15 bytes, 27 cycles
 lsr
 lsr
 lsr
 sta temp
 lsr
 lsr
 adc temp
 ror
 lsr
 adc temp
 ror
 lsr
I wrote 68000 version, maybe useful for something.

Code:
; divide by 24, no rest, no overflow
 lsr.l #3,D0
 move.l D0,D1
 lsr.l #2,D0
 addx.l D1,D0
 lsr.l #2,D0
 addx.l D1,D0
 lsr.l #2,D0
Here is divide by 3:

Code:
; divide by 3, no rest, no overflow
 move.l D0,D1
 lsr.l #2,D0
 addx.l D1,D0
 lsr.l #2,D0
 addx.l D1,D0
 lsr.l #2,D0
Modified versions can handle divide by 3, 6, 12, 24, 48, 96 etc.
Not tested, but seems to be OK.
Don_Adan is offline  
Old 17 September 2023, 13:20   #249
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Here is divide by 3 with rest:

Code:
; divide by 3 with rest, no overflow
 move.l D0,D1
 lsr.l  #2,D0
 addx.l D1,D0
 lsr.l  #2,D0
 addx.l D1,D0
 lsr.l #2,D0 ; score
 sub.l D0,D1
 sub.l D0,D1
 sub.l D0,D1 ; rest
Don_Adan 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
68000 boot code billt Coders. General 15 05 May 2012 20:13
Wasted Dreams on 68000 sanjyuubi support.Games 5 27 May 2011 17:11
680x0 to 68000 Counia Hardware mods 1 01 March 2011 10:18
quitting on 68000? Hungry Horace project.WHDLoad 60 19 December 2006 20:17
3D code and/or internet code for Blitz Basic 2.1 EdzUp Retrogaming General Discussion 0 10 February 2002 11:40

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 17:48.

Top

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