Your question has to do with program logic, not language detail. Limiting the user to 4 presses is done using the same algorithms in assembly, C++, Java and Turing. What you want to know is, how to code it in assembler. But short of guiding you through the stages of design and code translation, an answer would begin to resemble a complete working example. Nobody here has time to do that for you, for free. You have to design the high level logic, learn the opcodes, and "connect the dots".