Reputation: 11
My code in assembly emu 8086 displays alphabets in lower case but it displays them twice instead of displaying them in new line a single time each. Ive tried everything from AI etc but could not find the solution.
.model Small
.stack 100h
.data
.code
main proc
mov cx,26
mov dl,'a'
loop1:
mov ah,2
int 21h
mov dh,10
mov ah,2
int 21h
inc dl
loop loop1
mov ah,4ch
int 21h
end main
main endp
Upvotes: -2
Views: 65
Reputation: 39516
mov dh,10
does not load the required DL register for use by the DOS.DisplayCharacter function. It is mandatory to write mov dl, 10
, and because on the DOS platform a newline is actually composed of the 2 control codes 13 (carriage return) and 10 (linefeed), you need to send both these codes to the screen.
While loading the DL register with the newline codes (one after the other), you will loose the alphabetical character that you have stored in DL. A good solution could be loading the character from a spare register like BL.
mov cx, 26
mov bl, 'a'
loop1:
mov dl, bl
mov ah, 02h
int 21h
mov dl, 13
mov ah, 02h
int 21h
mov dl, 10
mov ah, 02h
int 21h
inc bl
loop loop1
mov ah, 02h ; CONST
mov dh, 'a'
loop1:
mov dl, dh
int 21h
mov dl, 13
int 21h
mov dl, 10
int 21h
inc dh
cmp dh, 'z'
jbe loop1
jbe dh, 'z'
repeats the loop for as long as DH holds a value smaller or equal to 'z'.
Upvotes: 0