Home > Software engineering >  Debug assembly prints limited amount of characters
Debug assembly prints limited amount of characters

Time:10-28

I have been working on project with DOS Debug. I have to take string and count symbol's 0, 2, 3 and 6 bit sum. If it is even, I need to turn that symbol into 4. And I have to print out string backwards. I have done almost everything.

But I have a problem and I stuck. It only prints out 12 characters. Where the problem could be?

Input: abcdefghijklmn

Output: n4lk4i4g4e44

Expected output: n4lk4i4g4e44b4 (more, than 12 characters)

This is the code

a800
db 50 00

a100
mov ah, 09
mov dx, 700
int 21
mov ah, 3f
mov dx, 800
int 21

a150
mov bx, 800
mov si, 0
jmp 250

a250
mov al, [bx si]
mov cl, [bx si]
mov byte [750], cl
cmp al, 20
jl 490
mov ah, 0
clc
rcr al, 1
adc ah, 0
clc
rcr al, 2
adc ah, 0
clc
rcr al, 1
adc ah, 0
clc
rcr al, 4
adc ah, 0
mov al, ah
mov ah, 0
clc
rcr al, 1
adc ah, 0
cmp ah, 0
jg 300
jmp 320

a300
mov byte [bx si], 34
inc si
jmp 250

a320
mov byte [bx si], [750]
inc si
jmp 250

a490
mov byte [bx si 1], 24
xor dx, dx
jmp 500

a500
mov ah, 02
mov dl, [bx si]
int 21
dec si
loop 500
mov ah, 4c
int 21

a700
db "Iveskite teksta " 0A 0D "$"

n bb.com
r cx
1000
w
q

a250 counts bit's sum

a490 adds $ sign to the end

EDIT: I think that loop stops working after twelve reps.

CodePudding user response:

The answer is simpler than expected. Thanks to @Jester and @Michael comments. I had a bad loop. I just moved si to cx and it works perfectly. Thank you all for help.

a490
mov byte [bx si 1], 24
xor cx, cx
mov cx, si
inc cx
jmp 500

a500
mov ah, 02
mov dl, [bx si]
int 21
dec si
loop 500
mov ah, 4c
int 21
  • Related