Loops/Downward for: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 2,279: | Line 2,279: | ||
for I:= 10 downto 0 do |
for I:= 10 downto 0 do |
||
[IntOut(0, I); CrLf(0)]</lang> |
[IntOut(0, I); CrLf(0)]</lang> |
||
=={{header|Z80 Assembly}}== |
|||
Because of the way looping typically works in hardware, as well as 10 being two digits, it's more efficient to only print numbers 9 through 1 in the loop body, and do the rest outside it. |
|||
<lang z80>org &1000 |
|||
LD A,'1' |
|||
CALL &BB5A |
|||
LD A,'0' |
|||
CALL &BB5A |
|||
LD B,9 |
|||
LD A,'9' |
|||
for: |
|||
CALL &BB5A |
|||
DEC A |
|||
DJNZ for |
|||
LD A,'0' |
|||
JP &BB5A ;its RET returns to BASIC for us.</lang> |
|||
{{out}} |
|||
<pre>Amstrad Microcomputer (v4) |
|||
(c) 1985 Amstrad plc |
|||
and Locomotive Software Ltd. |
|||
ParaDOS V1.2+ (c)2015 BitWise Systems. |
|||
BASIC 1.1 |
|||
Ready |
|||
call &1000 |
|||
109876543210 |
|||
Ready</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |