Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Controls Guy on July 15, 2019, 12:24:33 PM

Title: MEMCLEAR not allowing casts
Post by: Controls Guy on July 15, 2019, 12:24:33 PM
Why will MEMCOPY let me cast but MEMCLEAR not?

Code: [Select]
MEMCOPY CustomWP0:UW LastCustomWP0:UW 0x20000 MaxRelayWords

MEMCLEAR LastCustomWP0 MaxRelayCount
Title: Re: MEMCLEAR not allowing casts
Post by: BobO on July 15, 2019, 01:42:56 PM
Why will MEMCOPY let me cast but MEMCLEAR not?

Code: [Select]
MEMCOPY CustomWP0:UW LastCustomWP0:UW 0x20000 MaxRelayWords

MEMCLEAR LastCustomWP0 MaxRelayCount

Because we're mean.

MEMCOPY is blind. MEMCLEAR is type-aware and does struct initialization. We could probably make it work for simple types, but it wasn't straightforward.
Title: Re: MEMCLEAR not allowing casts
Post by: Controls Guy on July 15, 2019, 01:50:09 PM
Ah, gotcha.  That makes sense.  I was kind of classing the two together mentally.
Title: Re: MEMCLEAR not allowing casts
Post by: BobO on July 15, 2019, 01:55:14 PM
Ah, gotcha.  That makes sense.  I was kind of classing the two together mentally.

In a perfect world, they would be, but 'cleared' isn't always 'zero'. For simple types it is, but the instruction is built around type awareness and casting violates that.