//the original implementation
@SP
A=M-1
A=A-1
D=M  //x value

A=A+1  // M = y value
D=D-M  //x value - y value, save to d register

@SP
A=M-1
A=A-1  //x value address location

@SET_TRUE
D;JEQ

@SET_FALSE
0;JMP

(SET_TRUE)
M=-1
@END
0;JMP            

(SET_FALSE)
M=0

(END)
@SP
M=M-1

//new implementation using AM=M-1, assume original sp = 258
@SP
AM=M-1  //M=257, A=257
D=M  //RAM[257] is y value

@SP
A=M-1  // M=256, A=256, RAM[256] is x value
D=M-D  //RAM[256] - y value, save to D register

@SP
A=M  //A=256, RAM[256] is where x located

@SET_FALSE
D; JEQ

@SET_TRUE
0;JMP
@END
0;JMP

(SET_TRUE)
    M=-1  //if true, set M=-1

(SET_FALSE)
    M=0

(END)
@SP
M=M+1