Marco Abanio
Marco Abanio

Reputation: 13

how to print horizontally,vertically and diagonally in assembly language

my code is this

debug
a
mov cx,000a
mov ah,02
mov dl,30
int 21
inc dl
loop 0107
mov dl,0a
int 21
mov dl,0d
int 21
mov cx,0009
mov dl,20
int 21
mov dl,31
int 21
push dx
mov dl,0a
int 21
pop dx
inc dl
loop 011e
push dx
mov dl,0a
int 21
mov dl,0d
int 21
pop dx
mov cx,0009
mov dl,31
int 21
push dx
mov dl,0a
int 21
mov dl,0d
int 21
pop dx
inc dl
loop 0139
int 20

Actual output output

desired output:

output should be like this

Upvotes: 0

Views: 2800

Answers (1)

rkhb
rkhb

Reputation: 14409

I think this should be the knack of your program:

...
165B:011E CD21          INT 21
165B:0120 52            PUSH    DX
165B:0121 B20A          MOV DL,0A
165B:0123 CD21          INT 21
165B:0125 5A            POP DX
165B:0126 FEC2          INC DL
165B:0128 E2F4          LOOP    011E
...

After that the cursor is on the last row and you have to move it upwards. You can achieve this with functions 02 and 03 of BIOS interrupt 10

Change

165B:012A 52            PUSH DX
165B:012B B20A          MOV DL,0A
165B:012D CD21          INT 21
165B:012F B20D          MOV DL,0D
165B:0131 CD21          INT 21
165B:0133 5A            POP DX

to

mov ah, 03
mov bh, 00
int 10
mov ah, 02
mov dl, 00
sub dh, 9
int 10

You have to adjust the jumps behind it. Change

loop 0139

to

loop 013E

Upvotes: 1

Related Questions