Assembler and DV3
Thanks to...
Assembler and DV3

Chapter 7

Project “Moving Message” - Part 3

As mentioned in chapter 6, it may become necessary to slow down the execution of parts of a program artificially. Besides the reason, that especially machine-code programs may run too fast, it´s also because of the LCD-display of the DV3 necessary, to reduce the speed of moving objects.
Contrary to conventional displays, a LCD-display needs more time to delete set pixels. For that reason a fast moving object leaves a trace, the display “smears”.
Although this effect can be used intentionally, we are trying to avoid it in our program. Therefore we are controlling the speed of the characters of our “Moving Message” by a delay-loop as follows :
- 820172h :  MOV R8, 9999h
- 820176h :  NOP
- 820178h :  DBNZ R8, 0820176h
At first we are moving a value X (here 9999h) to a free register (R8 does a good job). The next command NOP does nothing.
But now things are getting interesting ! The command DBNZ R8, 082176h subtracts the value stored in R8 by 1 and scans the result for 0. As long as the result is not 0 (Not Zero), the program continues at adress 820176h. By that, the program runs in a loop until the value of R8 reaches 0. The original value moved to R8 represents therefore the number of repetitions of the loop ! The delay of the loop follows to the amount of that value.
Try to experiment with the delay by changing the value 9999h. The maximum number of repetitions is FFFFh.

At adress 82017Ch follows the conditional jump-command JMP.NZ 820140h. The NZ in DBNZ R8 and in JMP.NZ may not be mistaken ! While DBNZ R8 scans, if the value of R8 reaches 0, JMP.NZ examines, if the signal-register Z (flag Z) is not set.
Let´s call to mind :
Flag Z is set due to the command CMP (CoMP are), if the present column-value in R2 reaches the column limitation value of 8200A4h. This is going to happen, if our present output string reaches its determined position ! Now the command JMP.NZ will not force the program to continue at adress 820140h but it will move on quite normal at adress 820180h !
- 820180h :  SUB R2, 06h
- 820182h :  MOVB [00A4h], R2
As proved by the CMP-command, the present column-value in R2 has reached the column limitation value. We are decreasing this value (SUB) in R2 by 06h and are moving it back to 8200A4h as the new column limitation value !
- 820186h :  MOV R2, 00h
- 820188h :  MOV [00A2h], R2
We are moving 00h to R2 and transfer this value as the present column-value to 8200A2h.
- 82018Ch :  MOVB R2, [00A0h]
- 820190h :  ADD R2, 03h
- 820192h :  MOVB [00A0h], R2
At first the adress of the present output string is moved from 8200A0h to R2. There the adress-value is increased by 03h (ADD). Afterwards this value is moved back to 8200A0h as the adress of the new present output string !
What have we done by that ?

  1. Because of the new column limitation value in 8200A4h, the determined end-position of the next character of the moving message is decreased by 6 pixels.
  2. Because of the new column-value in 8200A2h the next output string starts again at column 00h.
  3. Because of the increase of the adress of the present output string in 8200A0h by 03h, the next following output string will be printed.

- 820196h :  CMP R2, [00A6h]
- 82019Ah :  JMP.NZ 0820140h
- 82019Eh :  HALT
The new adress of the present output string still contained in R2 is compared with the end-adress of the output string area (99h). Only if this value isn´t reached yet, the program will move on back at 820140h to provide the “text to screen”-routine with the new values.
But if the value of the end-adress of the output string area has been reached, this indicates, that the last output string has been printed and the program will stop at 82019Eh by the well known HALT-command.

Summary :
Essentially the program consists of an inner and an outer loop. The inner loop, which contains the “text to screen”-routine, is repeated for the purpose of the present output string until the present column limitation value is reached.
Within the outer loop the column limitation value is decreased, the present column-value is reseted to 0 and the adress of the output string of the next character is set. Afterwards the control is given back to the inner loop.
Therefore the outer loop is repeated every time after the inner loop finishes until the last character has been printed.

[DV3-Info] [Start-Deutsch] [Ergebnisse] [Start-Englisch] [Results]