943,762 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 1771
  • Assembly RSS
May 4th, 2009
0

Division in Assembly?

Expand Post »
How can I perform Division in Marie Assembly Language? The functions available in Marie programming are for Addition and Subtraction. Any help will be appreciated.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Rameses is offline Offline
8 posts
since Dec 2008
May 5th, 2009
0

Re: Division in Assembly?

Click to Expand / Collapse  Quote originally posted by Rameses ...
How can I perform Division in Marie Assembly Language? The functions available in Marie programming are for Addition and Subtraction. Any help will be appreciated.
You can do division using subtraction.
60 / 3 if I subtract 3 from 60 it will take 20 times before 60 < 3
Reputation Points: 57
Solved Threads: 5
Light Poster
sysop_fb is offline Offline
42 posts
since Apr 2009
May 6th, 2009
0

Re: Division in Assembly?

Click to Expand / Collapse  Quote originally posted by sysop_fb ...
You can do division using subtraction.
60 / 3 if I subtract 3 from 60 it will take 20 times before 60 < 3
I was able to do multiplication:Input /Input A value
Store A
Input /Input B value
Store B
Loop, Load A
Skipcond 800 If AC > 0, continue loop
Jump Endloop
Subt One
Store A
Load C
Subt B
Store C
Jump Loop
Endloop, Load C
Output
Halt
C, DEC 0
A, DEC 0
B, DEC 0
One, DEC 1

Division doesn't seems to be working for me. Is there something I could change in multiplication code to make division work? Multiplication is repeated adding, similar to Division, repeated subtraction.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Rameses is offline Offline
8 posts
since Dec 2008
May 6th, 2009
0

Re: Division in Assembly?

Psuedocode

Assembly Syntax (Toggle Plain Text)
  1. a = 60
  2. b = 3
  3. divide a b
  4.  
  5.  
  6. divide a b:
  7. c=0
  8. while a isn't less then b
  9. a = a - b
  10. c = c + 1
  11.  
Reputation Points: 57
Solved Threads: 5
Light Poster
sysop_fb is offline Offline
42 posts
since Apr 2009
May 7th, 2009
0

Re: Division in Assembly?

Click to Expand / Collapse  Quote originally posted by sysop_fb ...
Psuedocode

Assembly Syntax (Toggle Plain Text)
  1. a = 60
  2. b = 3
  3. divide a b
  4.  
  5.  
  6. divide a b:
  7. c=0
  8. while a isn't less then b
  9. a = a - b
  10. c = c + 1
  11.  
ORG 100
Input
Store X
Input
Store Y
Load Zero / Move 0 into AC
Store Z / Set Z to 0
If, Load Z / Load Z
Skipcond 400 / If AC=0 (Z=0), skip the next instruction
Jump Endif / Jump to Endif if X is not greater than 1
Then, Load X
Subt Y / X - Y
Store X / X= X - Y
Endif, Load Z / Load Z into AC
Add One / Add 1 to Z
Store Z / Z = Z + 1
Output
Halt / Terminate program
X, Dec 0 / X has starting value, not given in problem
Y, Dec 0 / Y has starting value, not given in problem
Z, Dec 0
One, Dec 1 / Use as a constant
Zero, Dec 0 / Use as a constant
END

What am I missing?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Rameses is offline Offline
8 posts
since Dec 2008
May 7th, 2009
0

Re: Division in Assembly?

Click to Expand / Collapse  Quote originally posted by Rameses ...
ORG 100
Input
Store X
Input
Store Y
Load Zero / Move 0 into AC
Store Z / Set Z to 0
If, Load Z / Load Z
Skipcond 400 / If AC=0 (Z=0), skip the next instruction
Jump Endif / Jump to Endif if X is not greater than 1
Then, Load X
Subt Y / X - Y
Store X / X= X - Y
Endif, Load Z / Load Z into AC
Add One / Add 1 to Z
Store Z / Z = Z + 1
Output
Halt / Terminate program
X, Dec 0 / X has starting value, not given in problem
Y, Dec 0 / Y has starting value, not given in problem
Z, Dec 0
One, Dec 1 / Use as a constant
Zero, Dec 0 / Use as a constant
END

What am I missing?
Nevermind, I got it. Thanks a ton!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Rameses is offline Offline
8 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Correct me if i'm wrong pls.....
Next Thread in Assembly Forum Timeline: Assembly Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC