22 January 2020, 17:19 | #1 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Is this a bug in EASy68K?
When writing a function I stumbled on this, and did a small test to confirm:
Code:
move.l #$abababab,d1 movem.w d1,-(sp) movem.w (sp)+,d1 ; d1 now contains $ffffabab I haven't tested it yet on WinUAE or real machine, as I don't have access at the moment, and now I wonder if this is a bug in EASy68k or not? I thought it would be legal to save only a word operand on the stack? According to the M6800PRM.pdf this would be legal, so I assume a bug. |
22 January 2020, 17:32 | #2 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
(Second, mem to reg) movem.w automatically sign-extends registers to longwords.
|
22 January 2020, 17:51 | #3 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
Yes, word reads from stack to register are sign extended to a long
|
22 January 2020, 18:11 | #4 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,329
|
movem.w from memory to registers always sign extend (this can actually be useful).
If you want to restore only a word operand, use move instead of movem. |
22 January 2020, 22:41 | #5 |
Registered User
Join Date: Jul 2014
Location: Warsaw/Poland
Posts: 187
|
interesting finding.
never heard before about data register sign extension. |
23 January 2020, 09:30 | #6 | |
Registered User
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
|
For your reference, the M68000PRM states on page 4-128 in the MOVEM description:
Quote:
|
|
23 January 2020, 09:46 | #7 |
OCS forever!
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
|
This was one of the tricks that I was really pleased to learn when relearning last year. I went through a load of routines stripping out ext.l used after a movem
|
23 January 2020, 12:49 | #8 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
Don't think I ever actually used an ext.l after a movem ever... but it's a handy trick to know for any future implementations
|
23 January 2020, 13:52 | #9 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
|
I organize everytime my data for movem access (both .w or .l).
And sign extension on data registers is usually usefull. There a case I've also used movem to a single dx register, just to have not CPU flags set (yes, a little slow, but with only worst alternatives available..) [movem exist also for no register at all encoding, like movem.l -(sp)-> $48e7,$0] |
23 January 2020, 17:23 | #10 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
|
23 January 2020, 17:53 | #11 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
|
Absolutely nothing (apart the 8 cycles for the two memory accesses on 68k, flags, stack and sp value sre untouched).
The only use that comes to mind is for some ugly SMC code, that varies registries selection based on value set on 2nd opcode instruction. Well, forget about it |
24 January 2020, 14:43 | #12 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
|
Speaking of Easy68k I found two flaws, if someone is registered on their forum it could report the problem.
1. (and this is big..) Code:
movea.l #$00800001,a5 lea (a5,a5.l),a5 So at the end A5=$2.. 2. Code:
btst #0,d0 Anyway I've a doubt about bit instructions and my manual is not clear about it.. Code:
instruction size dynamic static register memory register memory BCHG byte - 8(1/1) + - 12(2/1) + long 8(1/0) * - 12(2/0) * - BCLR byte - 8(1/1) + - 12(2/1) + long 10(1/0) * - 14(2/0) * - BSET byte - 8(1/1) + - 12(2/1) + long 8(1/0) * - 12(2/0) * - BTST byte - 4(1/0) + - 8(2/0) + long 6(1/0) - 10(2/0) - + add effective address calculation time * indicates maximum value But I've not found where is it specified what affects this maximum value. |
24 January 2020, 17:59 | #13 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,528
|
Quote:
|
|
24 January 2020, 18:32 | #14 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
|
Quote:
EDIT Another important thing to remember: if possible use logical operations directly, that are faster. As it is very probable that bxxx instructions are microcoded, internally are fluxed to the basic operations in ALU. This also explains why bclr is slower: bchg -> set, eor bset -> set, or bclr -> set, not, and Last edited by ross; 24 January 2020 at 19:34. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Bug I think... | NLS | support.WinUAE | 8 | 24 July 2017 22:09 |
Bug in x64 file requester and bug in Blizzard PPC ROM filesize | headkase | support.WinUAE | 5 | 26 June 2016 14:17 |
A little PM bug | Dizzy | project.EAB | 19 | 19 December 2006 20:00 |
Got a bug | Error | support.WinUAE | 2 | 17 March 2004 13:36 |
|
|