Introduction I get lots of emails and PM to write some more Assembly language programs and as I have some time I thought of writing some more. Its called Counters using the delay routine. Subroutine The subroutine we will use is as follows. This will behave as a delay for our counter Code: //FUNC MVI C, FF // Load Register C with the Hex value FF DCR C // Decrement the C Register // Address of the statment is XXXX JNZ XXXX // loop till you get the counter reduced to zero RET Now we will write the actual program to have the counter Code: LXI SP, 87DD // Load immediate stack pointer LXI H, 0000 // Load immediate register Pair H & L MVI B, 10 // Load Register B with the Hex value 10 SHLD 87FD // Store H & L direct PUSH B // Push register Pair B & C on stack CALL FUNC // Call the above subroutine POP B // Pop register Pair B & C off stack DCR B // Decrement B JNZ XXXX // - SHLD Location // Jump on no zero INX H // Increment H & L registers JMP XXXX // MVI B 10 location // Jump unconditional Now to make the decrement counter you just need one change INX to DCX
wow! this seems to be too hard to understand , especially the delay part,is there another code of a counter where a delay is not implemented,if so pliz may you show us
so where really is the counting part,is it the same aspect as in c or c++ or its a different aspect all together i seem not to get it.
Removing the CALL leaves you with the counter. specially the Code: DCR B // Decrement B JNZ XXXX // - SHLD Location // Jump on no zero INX H // Increment H & L registers
how to make delay counter with i/o.. like the problem.. the led will blink base on 4bit of switch.. i mean.. if 1111, the led will blink 15 times