Welcome to Dream.In.Code
Become an Expert!

Join 149,613 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,860 people online right now. Registration is fast and FREE... Join Now!




Assembly Code Equation Help

 
Reply to this topicStart new topic

Assembly Code Equation Help

tinytoh
23 Sep, 2007 - 04:12 PM
Post #1

New D.I.C Head
*

Joined: 9 Apr, 2007
Posts: 11


My Contributions
I need some help writing the .data and .code portions of the code to implement the following equation:
X=(10*Y-3*Z)/5

with X, Y=2, Z=5
I have most of it I think but I do not know where to go from here??
CODE

.DATA
X      DW    ?
Y      DW    2
Z      DW    5
.CODE
mov           ax,@data
mov           ds,ax
mov           dx,ah
mul            Y
mov           bx,03h
mul            Z
sub            ax,bx
cwd
div


This is where I got stuck....If someone could help me out I would really appreciate it

Thanks!

This post has been edited by tinytoh: 23 Sep, 2007 - 04:14 PM
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Assembly Code Equation Help
23 Sep, 2007 - 05:14 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
http://www.dreamincode.net/code/snippet446.htm
this snippet is a division example for 32 bit numbers, i think it should help. it also shows which registers hold the numerator and where the quotient and remainder end up smile.gif
User is offlineProfile CardPM
+Quote Post

tinytoh
RE: Assembly Code Equation Help
23 Sep, 2007 - 05:27 PM
Post #3

New D.I.C Head
*

Joined: 9 Apr, 2007
Posts: 11


My Contributions
that helps a little, however, I'm still not sure how to divide the stored values in both the ax and bx?

I do not think that you can divide ax by bx
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Assembly Code Equation Help
23 Sep, 2007 - 11:23 PM
Post #4

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,026



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
QUOTE
I do not think that you can divide ax by bx

Of course you can.
CODE
div bx

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:25AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month