7 Replies - 1489 Views - Last Post: 16 November 2013 - 10:08 PM

#1 annie12   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 141
  • Joined: 27-July 13

instructions sequence

Posted 16 November 2013 - 02:49 AM

i have a question in which i have to develop a short sequence of instructions thart adds ax,bx,cx,dx and sp,save the sum in the di register
i tried this in the following way.kindly check that i do it rightly or not
add  ax,bx
add  ax,cx
add  ax,dx
add  ax sp
mov  di,ax
 


Is This A Good Question/Topic? 0
  • +

Replies To: instructions sequence

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6833
  • View blog
  • Posts: 28,345
  • Joined: 12-December 12

Re: instructions sequence

Posted 16 November 2013 - 05:24 AM

Even with limited Assembly knowledge, it looks wrong that line 4 doesn't have a comma but the preceding lines do.

I assume that you could add these values directly to the di register - but you'll need to re-read the instructions carefully to confirm this.

This post has been edited by andrewsw: 16 November 2013 - 05:30 AM

Was This Post Helpful? 1
  • +
  • -

#3 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6833
  • View blog
  • Posts: 28,345
  • Joined: 12-December 12

Re: instructions sequence

Posted 16 November 2013 - 05:36 AM

I think you should read the instructions carefully again as it seems a little odd to me that SP is just added to the other values.
Was This Post Helpful? 0
  • +
  • -

#4 annie12   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 141
  • Joined: 27-July 13

Re: instructions sequence

Posted 16 November 2013 - 06:45 AM

View Postandrewsw, on 16 November 2013 - 05:36 PM, said:

I think you should read the instructions carefully again as it seems a little odd to me that SP is just added to the other values.

i have read its the same question ,can it is impossible to add sp
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6833
  • View blog
  • Posts: 28,345
  • Joined: 12-December 12

Re: instructions sequence

Posted 16 November 2013 - 06:55 AM

View Postannie12, on 16 November 2013 - 01:45 PM, said:

i have read its the same question ,can it is impossible to add sp

What?
Was This Post Helpful? 0
  • +
  • -

#6 annie12   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 141
  • Joined: 27-July 13

Re: instructions sequence

Posted 16 November 2013 - 08:21 AM

View Postandrewsw, on 16 November 2013 - 06:55 PM, said:

View Postannie12, on 16 November 2013 - 01:45 PM, said:

i have read its the same question ,can it is impossible to add sp

What?

i am asking that can sp addition in the registers is possible or not
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6833
  • View blog
  • Posts: 28,345
  • Joined: 12-December 12

Re: instructions sequence

Posted 16 November 2013 - 10:52 AM

Sorry, your question still isn't clear to me. Perhaps someone else will assist you. Good luck.
Was This Post Helpful? 0
  • +
  • -

#8 GunnerInc   User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 918
  • View blog
  • Posts: 2,358
  • Joined: 28-March 11

Re: instructions sequence

Posted 16 November 2013 - 10:08 PM

sp is the stack pointer, you almost never want to modify this in any way. This is not a general purpose register. Leave this register alone!!!! I will say again, LEAVE SP ALONE!!! It holds the top address of the stack!!!

Why couldn't you just do:
	xor     di, di
	add     di, bx
	add     di, cx
	add     di, dx

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1