I was multiplying every integer of a buffer and now I need to connect the intermediate results.
I have this code:
(previously in .data I stated: count db 0
)
MOV cx, ax
MOV si, offset skBuf
MOV di, offset raBuf
add si,ax
dec si
work:
MOV dl, [si]
sub dl,48
mov bl,dl
mov al,3 ;can be changed by 0-9
mul bl
mov dl,al
add dl,48
divide:
cmp dl,09H ;compares with 9
jbe pabaiga
ja decomposition
decomposition:
mov ax,dx
mov bl, 10
div bl ;al=ax/bl ah=ax%bl
MOV [di], ah
mov dl,al
add dl,count
mov count,al
add count,48
dec si
inc di
LOOP work
I feel like I'm doing something wrong.
Basically if you didn't understand:
For example my buffer contains: 456
Right now without the divide part of a code it multiplies each digit by 3 so:
6*3
and prints it- then
5*3
and prints it - and lastly
4*3
and prints it all separately
I need that the output looked like 456*3
which equals to 1368
Right now with this code below:
MOV cx, ax
MOV si, offset skBuf
MOV di, offset raBuf
add si,ax
dec si
work:
MOV dl, [si]
sub dl,48
mov bl,dl
mov al,3 ;galima pakeisti
mul bl
mov dl,al
add dl,48
MOV [di], dl
dec si
inc di
LOOP work
the output (with 456 input) is B?<
but I need it to be 1368
If it would make it more understandable I'm reading from a file and writing it to another file.