Jump to content

Help with 8086 Assembly

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
SCR

SCR

    Newbie

  • Members
  • Pip
  • 1 posts
I need to make a program that ask two numbers, multiply it and then show the result.

This is what I have done until now. My problem is when the program must show the result. If anyone can help me I would thank you. ;)
.model small
.stack 2000h
.data
m1 db 0dh,0ah,"Enter multiplicant (0-9): $"
m2 db 0dh,0ah,"Enter multiplier (0-9): $"
m3 db 0dh,0ah,"The product is: $"
.code
main proc
	mov ax,@data
	mov ds,ax
	mov ah,9
	mov dx,offset m2
	int 21h
	mov ah,1
	int 21h
	mov cl,al
	mov ah,9
	mov dx,offset m1
	int 21h
	mov ah,1
	int 21h
	sub cl,30
	sub al,30
	mul cl
	aam
	add al,30
	add ah,30
	mov bx,ax
	mov ah,9
	mov dx,offset m3
	int 21h
	mov dx,'bx'
	mov ah,2
        int 21h
	mov ax,4c00h
	int 21h
main endp
end main


#2
Walle

Walle

    Learning Programmer

  • Members
  • PipPipPip
  • 75 posts
To me, it looks like you're not pointing DS to the segment of the string.

Try:

.model small

.stack 2000h

.data

m1 db 0dh,0ah,"Enter multiplicant (0-9): $"

m2 db 0dh,0ah,"Enter multiplier (0-9): $"

m3 db 0dh,0ah,"The product is: $"

.code

main proc

	mov ax,@data

	mov ds,ax

	mov ah,9

	mov dx,offset m2

	int 21h

	mov ah,1

	int 21h

	mov cl,al

	mov ah,9

	mov dx,offset m1

	int 21h

	mov ah,1

	int 21h

	sub cl,30

	sub al,30

	mul cl

	aam

	add al,30

	add ah,30

	mov bx,ax

             mov ax,seg m3

             mov ds,ax

             mov dx,offset m3

	mov ah,9

	int 21h

	mov dx,'bx'

	mov ah,2

        int 21h

	mov ax,4c00h

	int 21h

main endp

end main

As you notice, I added "mov ax,seg m3" and "mov ds,ax", since we can't do "mov ds,seg m3".

Tell me if it works, will you?
________________________________________________
"I'm not young enough to know everything." - Oscar Wilde