The parseRegister() method tries to parse a register. First, it checks for a percent sign %. If this is followed…