Kashif ali
Kashif ali

Reputation: 23

Pattern in assembly language

.model small
.stack 100h
.Data 
 count word 0
.code
 main proc

   mov cx,5
  mov al,40h
   mov ah,2
  mov bx,0


first :
    mov count,cx

   inc bx
   inc al
   mov cx,bx


second :
    mov dl,al
    int 21h 



   loop second
   mov cx ,count
    mov dx,13
    mov ah,2
    int 21h 
     mov dl,10
     mov ah,2
     int 21h
     loop first
    mov ax,4c00h
    int 21h

  main endp
  end main

I wrote this code and expecting output like this

A
BB
CCC
DDDD
EEEEE

but getting this output

A
00
000
0000
00000

can anyone sort out the problem in this code when i remove the line of codes for line change it is giving output

ABBCCCDDDDEEEE

Upvotes: 0

Views: 2400

Answers (1)

Jester
Jester

Reputation: 58772

int 21/02 is destroying your al value. A simple solution is to surround your int 21h calls with push ax/pop ax.

PS: learn to use a debugger.

Upvotes: 5

Related Questions