English Amiga Board


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

 
 
Thread Tools
Old 21 December 2013, 18:10   #21
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
Ok, the optimisation is for a func that converts the min/max bounds of a rectangle from 32 bit into 16 bit in order that it can be filled.

Now I have another problem. If I do not have the right and bottom coordinates, but instead a width and a height, what to do then? I want the clipped width and height returned. This time the input and the result of width and height cannot and must not be negative, but input can be larger than $7fff.

Last edited by AGS; 21 December 2013 at 20:26.
AGS is offline  
Old 21 December 2013, 20:38   #22
AnimaInCorpore
Registered User
 
Join Date: Nov 2012
Location: Willich/Germany
Posts: 232
Quote:
Originally Posted by Don_Adan View Post
Perhaps the fastest version is version based on meynaf's trick.

Code:
 move.w D0,A0
 cmp.l D0,A0
 beq.b OK
 move.w #$8000,D0
 tst.l D0
 bmi.b OK
 not.w D0
OK
Another idea:

Code:
  movea.w d0,a0
  cmpa.l  d0,a0
  beq.s   ok
  add.l   d0,d0
  scc     d0
  ext.w   d0
  roxr.w  #1,d0
ok:
Cheers
Sascha
AnimaInCorpore is offline  
Old 21 December 2013, 22:37   #23
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Quote:
Originally Posted by AGS View Post
Ok, the optimisation is for a func that converts the min/max bounds of a rectangle from 32 bit into 16 bit in order that it can be filled.
Why are you using 32 bit values for those rectangles? Even with 16 bit you already have 65536x65536 pixel rectangles, far more than what's needed for anything on Amigas.

Quote:
Originally Posted by AGS View Post
Now I have another problem. If I do not have the right and bottom coordinates, but instead a width and a height, what to do then? I want the clipped width and height returned.
I don't see how you can clip without knowing the location of the rectangle.

Quote:
Originally Posted by AGS View Post
This time the input and the result of width and height cannot and must not be negative, but input can be larger than $7fff.
If the input is never negative, 0 is the minimum, and the maxium is $7fff, than that's pretty easy.
Thorham is offline  
Old 21 December 2013, 23:03   #24
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
In my GUI I habe Listviews for File Directories. These need 32 bit values as they can be very big and also partially outside of the screen. This is how my scrolling works. The location of the Rectangle is given, only width and height are there in difference to right and bottom. It's pretty easy with a compare and this is how i do it, but maybe there is another solution.
AGS is offline  
Old 22 December 2013, 17:50   #25
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Quote:
Originally Posted by AnimaInCorpore View Post
Another idea:

Code:
  movea.w d0,a0
  cmpa.l  d0,a0
  beq.s   ok
  add.l   d0,d0
  scc     d0
  ext.w   d0
  roxr.w  #1,d0
ok:
Cheers
Sascha
Nice.
I checked ADPCM source and full version of meynaf's trick looks next:

Code:
  move.w d0,a0
  cmp.l  d0,a0
  beq.s   ok
  add.l   d0,d0
  subx.l    d0,d0
  eor.w #$7FFF,D0
ok
Anyway the shortest version can be next:

Code:
  move.w d0,a0
  cmp.l  d0,a0
  beq.s   ok
  add.w   d0,d0
  subx.w   d0
  asr.l  #1,d0
ok
Don_Adan is offline  
Old 22 December 2013, 17:55   #26
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
What does "subx.w d0" do? Is this a plain 68000 command or do I need an 680xx?
AGS is offline  
Old 22 December 2013, 18:12   #27
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
To Don_Adan:

You've made a mistake.

Quote:
Originally Posted by AGS View Post
What does "subx.w d0" do? Is this a plain 68000 command or do I need an 680xx?
Subx is available on all 68000 CPUs. It simply subtracts with carry, just like addx adds with carry. The carry bit is set when an arithmetic operation causes an overflow or underflow, and these instructions can therefore be used to, for example, add two 32 bit numbers together, and get a 33 bit result:
Code:
    clr.l   d2
    add.l   d0,d1   ; d1 contains bits 0-31 of the result
    addx.l  d2,d2   ; d2 contains bit 32 of the result
Thorham is offline  
Old 22 December 2013, 18:15   #28
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Don_Adan View Post
This is not my idea, but meynaf's (french coder, available on EAB too) trick, he used this trick in own productions for fast range check (-32768 to +32767). Moving word into address register works as move.w and ext.l together.
This trick wasn't invented by Meynaf either, it was used for a long time already.

Quote:
Originally Posted by AGS View Post
What does "subx.w d0" do? Is this a plain 68000 command or do I need an 680xx?
subx.w d0 is illegal, should be subx.w d0,d0, this is a standard 68000 instruction. Subtracts d0 from d0 but takes the value of the carry bit into account as well. if the carry bit was set before, d0 would be -1 after this operation.
StingRay is offline  
Old 27 December 2013, 13:14   #29
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Quote:
Originally Posted by Thorham View Post
To Don_Adan:

You've made a mistake.


Subx is available on all 68000 CPUs. It simply subtracts with carry, just like addx adds with carry. The carry bit is set when an arithmetic operation causes an overflow or underflow, and these instructions can therefore be used to, for example, add two 32 bit numbers together, and get a 33 bit result:
Code:
    clr.l   d2
    add.l   d0,d1   ; d1 contains bits 0-31 of the result
    addx.l  d2,d2   ; d2 contains bit 32 of the result

Standard usage of addx/subx commands is not enough sexy for me. Especially subx can be used for many tricks.
And od course it must be subx.w D0,D0.


Code:
move.w d0,a0
cmp.l d0,a0
beq.s ok
add.w d0,d0   ; bit x, 0 or 1
subx.w d0,d0  ; d0, $FFFF0000 or $0000FFFF
asr.l #1,d0   ; d0, $FFFF8000 or $00007FFF
ok
Don_Adan is offline  
Old 28 December 2013, 15:54   #30
TheDarkCoder
Registered User
 
Join Date: Dec 2007
Location: Dark Kingdom
Posts: 213
Quote:
Originally Posted by Don_Adan View Post
Standard usage of addx/subx commands is not enough sexy for me. Especially subx can be used for many tricks.
And od course it must be subx.w D0,D0.


Code:
move.w d0,a0
cmp.l d0,a0
beq.s ok
add.w d0,d0   ; bit x, 0 or 1
subx.w d0,d0  ; d0, $FFFF0000 or $0000FFFF
asr.l #1,d0   ; d0, $FFFF8000 or $00007FFF
ok

this last code seems not working to me..
I tried with D0 = $00200010. The correct result should be (if I understood the problem) D0 = $00007fff. The code instead sets D0 = $00100000 which is wrong even if you consider only D0.w
TheDarkCoder is offline  
Old 28 December 2013, 15:56   #31
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
You understood correctly.
AGS is offline  
Old 29 December 2013, 13:58   #32
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Quote:
Originally Posted by TheDarkCoder View Post

this last code seems not working to me..
I tried with D0 = $00200010. The correct result should be (if I understood the problem) D0 = $00007fff. The code instead sets D0 = $00100000 which is wrong even if you consider only D0.w
This version fixes only values from $00008000-$0000FFFF and $FFFF7FFF-$FFFF000 range. For other values you must/can use meynaf version with eor. This routine is used mostly (only?) for correction ($7FFF to $8000) range and it works OK (I checked ADPCM player), perhpas can works for JPEG and MPEG decompression routine too. But of course if you need routine for conversion (not for correction only) then meynaf version must be used for this case.
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
32-bit access on 16-bit bus? NorthWay Coders. Asm / Hardware 7 04 September 2013 00:46
REQ: 17-Bit Artwork 2 (1988-04)(17-Bit Software) Sea7 request.Demos 5 13 May 2011 01:07
8 bit to optimized 6 bit palette histogram improvements needed NovaCoder Coders. General 0 14 April 2011 02:13
My A500 is dying bit by bit :( Old Fool support.Hardware 3 03 July 2009 17:12
64 bit signed multiply cdoty Coders. General 2 16 December 2007 12:24

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 19:51.

Top

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