IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

multiply 2 numbers in assembly language


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Wed Feb 13, 2008 11:38 am
Reply with quote

What I need to do is to multiply 2 numbers where both the numbers need to be hard coded in my program.

regards

Alamelu
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 13, 2008 2:51 pm
Reply with quote

why not start from
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DZ9ZR003/CCONTENTS?SHELF=HAS1BK54&DN=SA22-7832-03&DT=20040504121320

and then
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DZ9ZR003/7.5.97?SHELF=HAS1BK54&DT=20040504121320
clicking on the next page symbol for other binary multiply opcodes
( open book with a right arrow )

or
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DZ9ZR003/8.0?SHELF=HAS1BK54&DT=20040504121320
for a general description of decimal number representation

followed by ...
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DZ9ZR003/8.3.6?SHELF=HAS1BK54&DT=20040504121320
for the description
and ...
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DZ9ZR003/A.0?SHELF=HAS1BK54&DT=20040504121320#HDRAA1H1
for the examples ???
Back to top
View user's profile Send private message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Wed Feb 13, 2008 4:13 pm
Reply with quote

thanx enrico sorichetti for that reply..

i was able to solve my prob..

now i have another prob..where i need to multiply a "decimal" number..eg.0.25 with another decimal num...
use of the instruction MP doesnt help as the decimal point doesnt get recognised...plz help me here...

thanx in advance

regards

Alamelu
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 13, 2008 4:42 pm
Reply with quote

as in any programming language there is no implicit representation for the decimal point...
You must carry on Your own computations..
according to logic and legal constraints, there are rules to be followed..

Yes there are legal constraints also...

for IR ( internal revenue ) the numbers must be represented with 2 decimal digits,
but the computations must be carried on with 4 decimal digits,
beware when carrying on such operations in assembler

the logic for Your need would be ..

transform every number to a integer number with the required number of decimal digits

A = 12 ==> 1200
B = 34 ==> 3400

a * B = 1200 * 3400 = 4080000
c = 408


a = 13 ==> 1300
b = 2 ==> 200

a/B = 65000 ==> 6.50
Back to top
View user's profile Send private message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Wed Feb 13, 2008 4:55 pm
Reply with quote

thanx for ur inputs enrico sorichetti...

let me paste my code here for you for easier understanding..


BONE EQU *
MVC CAMTCAL,CAMTI
PACK PAMTCAL,PAMTI
MP PAMTCAL,=P'0.4'
UNPK RS,PAMTCAL
OI RS+09,X'F0'
CLC RS,CAMTCAL
BC 4,BONE1
B DUMMY

like i have highlighted above..after the multiplication, i need to check if one of my variable camtcal ( ie. claim amt) is greater than what i have calculated using the MP instruction...
so here my prob is that.. "0.4" isnt really getting recognised..the decimal point is being ignored and the multiplication is happening only with the number '4' and not with '0.4'...plz do help me here..is there another instruction for such a multiplication..??

thanx in advance

regards

Alamelu
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 13, 2008 5:01 pm
Reply with quote

maybe I was not clear in my previous post...
machine instructions do not recognize decimal numbers.

You must take care of it Yourself

adding the proper number of zeroes to simulate a number with decimal digits

carry on the computations,
rescale the result

example
A = 12 ==>1200 ( 12.00)
B = 34 ==> 3400 ( 34.00 )
C = A * B
step1 1200 * 3400 = 4080000 ( 408.0000)
step2 ( rescale to 2 decimal digits ) 40800 ( 408.00)
assign to c
the edit instruction with a proper mask will display the decimal point
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Feb 13, 2008 7:17 pm
Reply with quote

If both numbers are hard-coded, why not also hard-code the product (i.e., result of mult)?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 13, 2008 7:30 pm
Reply with quote

Phrzby Phil wrote:
If both numbers are hard-coded, why not also hard-code the product (i.e., result of mult)?


OK... OK... did i win the "dumbest of the day" award icon_biggrin.gif

Or the poster was just checking if we paid enough attention to the questions icon_confused.gif
Back to top
View user's profile Send private message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Thu Feb 14, 2008 10:59 am
Reply with quote

thanx enrico sorichetti for ur inputs

will try it out...

regards

Alamelu
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Generate random number from range of ... COBOL Programming 3
No new posts IMS DB using Natural Language IMS DB/DC 0
No new posts Feild level validation to test first ... JCL & VSAM 10
No new posts Usage of processor directive and firs... PL/I & Assembler 4
Search our Forums:

Back to Top