That's just the right solution if you know x and y (or even just x?) ahead of time isn't it?
And don't you mean "27" into register 27-x, do. 18 etc.?
And don't you mean "27" into register 27-x, do. 18 etc.?
Much faster to find upper and lower bounds and essentially construct a hash table than to manually sort a whole list of non-trivial length.