I used the exact code and atmega as standalone and in uno.The uno displays without any issue but while using it's atmega as standalone the lcd displays black box. I used the code and diagram from https://docs.arduino.cc/learn/electronics/lcd-displays.
A line of boxes is what you see on an LCD when it hasn't been initialized yet. If you've just removed the programmed processor from the Uno (where it was working), I would imagine that either a) the processor isn't running because there's a problem in your wiring or b) the LCD isn't seeing the commands the processor is sending because there's a problem in your wiring.
I'd suggest adding code to your sketch to blink an LED in loop() and seeing if that works. That would tell you whether or not the processor was running and allow you to concentrate on which part of the circuit is the problem.
My guess is you intended to use D2-D5 and just picked the wrong pins. That's an easy mistake to make with multi function pins. Too much information on each pin.
Below post #8, where I mentioned A2-A5, you should find a check box labeled "Solution", or something like that. I get brownie points on this forum for helping you solve your problem by you checking the box. I get a virtual gold medal by accumulating brownie points.