Unit 1.2 Slide, is this correct?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Unit 1.2 Slide, is this correct?

andybendy


I'm not totally sure if this image link works, so I will explain the question through text as well.

On the slide in the unit 1.2 lecture, where the title is: Arithmetic / Logical commands, it says the eq command has a return value of x==0, should this not be x==y?
Reply | Threaded
Open this post in threaded view
|

Re: Unit 1.2 Slide, is this correct?

dolomiti7
You are right, this is definitely a mistake on the slide. The eq VM command works similar to the LT and GT by comparing 2 operands on the stack. So x==y would be the correct description of the command.

A typical implementation would more look like (x-y)==0 and then use a ...;JEQ ASM instruction, maybe that's where the mixup came from.
Reply | Threaded
Open this post in threaded view
|

Re: Unit 1.2 Slide, is this correct?

andybendy
Oh okay, thank you for clarifying!

Why would the implementation likely be x-y==0 instead of x==y? Is that because all of the jump commands are centered on 0? Like there's no jump command comparing two values, they all compare a singular value to 0 (except for the unconditionals of course). Would it be possible to implement it using x==y but it'd just be more obtuse/unecessary, or it isn't even possible to logically implement?

Reply | Threaded
Open this post in threaded view
|

Re: Unit 1.2 Slide, is this correct?

andybendy
Oh okay, thank you for clarifying!

Why would the implementation likely be x-y==0 instead of x==y? Is that because all of the jump commands are centered on 0? Like there's no jump command comparing two values, they all compare a singular value to 0 (except for the unconditionals of course). Would it be possible to implement it using x==y but it'd just be more obtuse/unnecessary, or it isn't even possible to logically implement?

edit: spelling errors.
Reply | Threaded
Open this post in threaded view
|

Re: Unit 1.2 Slide, is this correct?

pm100
In reply to this post by andybendy
All compare inst auctions on almost all CPUs are implemented ,either explicitly or implicitly, as subtract followed by testing the result flags.