Loops/Downward for: Difference between revisions

Line 107:
DBRA D0,loop ;repeat until D0.W = $FFFF
rts</lang>
 
=={{header|8086 Assembly}}==
<lang asm> .model small ;.exe file, max 128 KB
.stack 1024 ;reserve 1 KB for the stack pointer.
.data
;no data needed
 
.code
start:
mov ax,0100h ;UNPACKED BCD "10"
mov cx,0Bh ;loop counter
repeat_countdown:
call PrintBCD_IgnoreLeadingZeroes
sub ax,1
aas
;ascii adjust for subtraction, normally 0100h - 1 = 0FFh but this corrects it to 0009h
push ax
mov dl,13
mov ah,02h
int 21h
mov dl,10
mov ah,02h
int 21h
;these 6 lines of code are the "new line" function
pop ax
loop repeat_countdown
 
mov ax,4C00h
int 21h ;return to DOS
 
PrintBCD_IgnoreLeadingZeroes:
push ax
cmp ah,0
jz skipLeadingZero
or ah,30h ;convert a binary-coded decimal quantity to an ASCII numeral
push dx
push ax
mov al,ah
mov ah,0Eh
int 10h ;prints AL to screen
pop ax
pop dx
skipLeadingZero:
or al,30h
push dx
push ax
mov ah,0Eh
int 10h
pop ax
pop dx
pop ax
ret
 
end start ;EOF</lang>
 
=={{header|AArch64 Assembly}}==
1,489

edits