Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
multiply 2 numbers in assembly language

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: multiply 2 numbers in assembly language
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Wed Feb 13, 2008 2:51 pm    Post subject: Reply to: multiply 2 numbers in assembly language
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Wed Feb 13, 2008 4:42 pm    Post subject: Reply to: multiply 2 numbers in assembly language
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Wed Feb 13, 2008 5:01 pm    Post subject: Reply to: multiply 2 numbers in assembly language
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

Active Member


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

PostPosted: Wed Feb 13, 2008 7:17 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Wed Feb 13, 2008 7:30 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts StreamWeaver language reference chetanambi Compuware & Other Tools 1 Wed Jul 05, 2017 12:50 pm
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Need Help in understanding what is th... mainakdalal PL/I & Assembler 9 Mon Oct 03, 2016 8:03 pm
No new posts Any body aware of CAP-COBOL language? Sachin Raghuwanshi COBOL Programming 4 Tue Aug 02, 2016 9:34 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us