Quote:
how to write simple debugger
Writing a debugger is anything but simple.
Quote:
i want to set hardware breakpoint to address in the memory
Modern OS are pretty complicated and the handling of memory is pretty complex.
I recommend to use existing debuggers, the one of your IDE is a good start.
Note than debugging a serial communication may imply a special tooling to ensure that the debugging itself do not alter the communication.