Hi guys..i've been cracking my head for the past few days, i can't seem to print out the result of my multiplication..I'm using MASM615..Can anyone give me some pointers ?

.MODEL MEDIUM
.STACK 
.DATA 

;==================================
ONE DW 04DEH ; First signed number A = (-79H) = FF87H (2'Compliment form)
TWO DW 096CH ; Second signed number B = (-7CH) = FF84H (2'Compliment form)
THREE DW ? ; Variable C to store result
FOUR DW ?

MSGTWO db "enter first number:$"
MSGTRI db "enter second number:$"
;MSGFOUR db "Answer  : $"
;MSGFIVE db  "thank you for using the calculator! press any ;key...$"
;ERROR db  "wrong operator!$"
;==================================
PARALIST LABEL BYTE
MAX	 DB 	6
ACT 	 DB	?
PARADATA DB 	6 DUP (' ')

PARALIST2 LABEL BYTE
MAX2	 DB 	6
ACT2 	 DB	?
PARADATA2 DB 	6 DUP (' ')

;===================================


.CODE


MAIN PROC

MOV AX,@DATA
MOV DS,AX
MOV SI,0000H ; Initialize SI to 0000H

;Prompt For Input

LEA DX,MSGTWO
MOV AH,09H
INT 21H

MOV AH,0AH
LEA DX,PARALIST
INT 21H

;New Line

MOV AH,02H
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H

;Prompt For Input2
LEA DX,MSGTRI
MOV AH,09H
INT 21H

MOV AH,0AH
LEA DX,PARALIST2
INT 21H

;New Line

MOV AH,02H
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H

;mov $ sign
MOV BL,ACT
MOV BH,00
MOV PARADATA[BX],'$'

;mov $ sign
MOV BL,ACT2
MOV BH,00
MOV PARADATA2[BX],'$'

; Perform Multiplication

LEA AX,PARADATA ;Take first number A in AX register
LEA CX,PARADATA2 ;Take second number B in CX register
MUL CX ; Performs unsigned Multiplication DX:AX = AX × CX

MOV SI,DX

MOV FOUR,SI ; Store higher 16-bit result

MOV AH,09H
MOV DX,FOUR
INT 21H

MOV AH,02H
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H

MOV SI,AX

MOV THREE,SI ; Store lower 16-bit result

MOV AH,09H
MOV DX,THREE
INT 21H

MOV AX,4c00H
INT 21H

MAIN ENDP
END MAIN

The part in red color is probably where i've gone wrong..been reading lotsa books but i don't get it..=/

The problem is that you are trying to multiply strings, which you cannot do.

Remember, the string '12' is different from the number 12.

So, you must first convert the PARADATA strings into numbers, multiply them together, then convert the resulting number back to a string, which you can print.


Since you seem to have a pretty good grasp of things, might I recommend you use some subroutines? (You don't need to, but it'll make things nicer.)

I haven't read anything past the attempt to multiply strings...
Hope this helps.

Subroutines ? what are those ?

By that does it means that i have to use MOV offset ? i'm not really sure

The difference is how data is represented in memory.

str1 db 52, 50
str2 db '42'

The strings str1 and str2 are identical. Both contain the two-character ASCII string "42".
However, the number 42 is stored as just that:

num db 42

Notice how the only difference is how we think about it. We could say that str2 is really just an array of two numbers: 52 and 50. Or a single WORD-sized number: 12852. Or a string. Once we decide what it is we must use it correctly.

Since the user input is an ASCII string, we must change it into its proper numeric representation.

The ASCII digits and their numerical values are:

ASCII
char  '0'  '1'  '2'  '3'  '4'  '5'  '6'  '7'  '8'  '9'
value 48   49   50   51   52   53   54   55   56   57

To convert the representation (in ASCII) to its numerical value, we must do a little math:

(as numbers)
52, 50 - 48, 48 = 4, 2
(as characters)
'4', '2' - '0', '0' = 4, 2

Now we just need to change the sequence 4, 2 into a single number:
4 * 10 = 40
40 + 2 = 42

This should be enough to get you started. I recommend that you do it in a procedure:

str_to_int PROC NEAR
        ; this proc converts the $-terminated string at DX into a number
        ; the number is put in AX

        ; (you must write code here)

        ; (at this point AX must contain the converted number)
        ret
str_to_int ENDP

Then, to use the procedure all you need to do is

lea dx, PARADATA
call str_to_int
; now AX contains the converted number

If I have been unclear let me know. Hope this helps.

PLEASE!!!

ANY PEOPLE, CAN PASTE "the Compleat Codes" of MULTIPLICATION HEX in Assembly.

PLEASE!!! Thanks.

Comments
No, go away and sponge of someone else you loud-mouthed thread-digger
This article has been dead for over six months. Start a new discussion instead.