944,025 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 1942
  • Assembly RSS
Nov 9th, 2009
0

Assembly Code Help

Expand Post »
I am trying to do this: z=(5*a-b/7)/(3/b+a*a) in assembly code and I keep getting some errors.
Here is the code & the errs.


Assembly Syntax (Toggle Plain Text)
  1. assume cs:code,ds:data
  2. data segment
  3. a dw 5
  4. b dw 6
  5. z dw 10
  6.  
  7.  
  8. intermed dw ?
  9. rez db ?
  10. data ends
  11. code segment
  12. start:
  13.  
  14. mov ax,data
  15. mov ds,ax
  16. mul 5 ; ERROR Argument needs type override & Illegal immediate
  17. ; in ax we will have a*5;
  18. mov bx,ax ; we move the ax data in the bx register bx:ax
  19. mov ax,b; we move the b in the ax register ax:b
  20. cwd ; ERROR Argument needs type override& Illegal immediate ;we convert the word from ax in doubleword, in dx:ax
  21. idiv 7 ; ax=b/7
  22. sub bx,ax; we substract ax out of bx ( ax: ax-bx <=> 5*a-b/7 )
  23. mov intermed, ax ;we move all the data from ax to interm=(5*a-b*7)
  24.  
  25. mov al,3
  26. idiv b; ax:3/b
  27. mov bx,a; bx:a
  28. mul a; bx:a*a
  29. add ax, bx; ax=ax+bx;
  30. mov bx,intermed; Err. Undefined symbol Intermed
  31. idiv ax; we obtain the result in al and the reminder in ah
  32.  
  33. mov rez,al
  34.  
  35. mov ax, 4C00h
  36. int 21h
  37. code ends
  38. end start

Where are my sins? Thank you !
Last edited by ovidiu82; Nov 9th, 2009 at 1:12 am. Reason: i clarified some potential confusing aspects
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ovidiu82 is offline Offline
1 posts
since Jun 2009
Nov 9th, 2009
0
Re: Assembly Code Help
Click to Expand / Collapse  Quote originally posted by ovidiu82 ...
Where are my sins?
As a general recommendation, you should read some technical documentation on the x86 instructions... this page is a good start, but the Intel processor manuals are the real deal.

As for your specific questions:

Assembly Syntax (Toggle Plain Text)
  1. mul 5 ; ERROR Argument needs type override & Illegal immediate

operands to mul are either registers or memory locations; immediate values aren't supported.

Assembly Syntax (Toggle Plain Text)
  1. cwd ; ERROR Argument needs type override& Illegal immediate ;we convert the word from ax in doubleword, in dx:ax
  2. idiv 7 ; ax=b/7

cwd should be fine... this error might be for your idiv , which has the same restriction as mul --only registers or memory locations.

Assembly Syntax (Toggle Plain Text)
  1. mov bx,intermed; Err. Undefined symbol Intermed

Not sure what's wrong off the top of my head.
Reputation Points: 182
Solved Threads: 72
Posting Pro in Training
gusano79 is offline Offline
476 posts
since May 2004

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: Trying to analyse code
Next Thread in Assembly Forum Timeline: Assembly MIPS help





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


Follow us on Twitter


© 2011 DaniWeb® LLC