2 Replies - 1762 Views - Last Post: 07 June 2008 - 04:23 PM

#1 nomad1987  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-June 08

Assembly Language : Where is the answer stored?

Post icon  Posted 04 June 2008 - 11:15 PM

Well i admit i am certain that i am most definitely a noob to assembly language. Anyways i have a few small questions:

first question is like this. Where is the actual answer stored

start	 org		 $1000
		   move.l	 #$7ffe,sp		 ;
		   move.l	 #data,a1		 ;
		   move.b	#3,d2			 ;

loop	 add.b	  (a1)+,d1		  ;
		   sub.b	   #1,d2			 ;
		   bne		 loop			  ;
		   move.b   d1,(a1)		   ;
		   move.b   #228,d7		  ;
		   trap		#14

		   org		 $2000	
data	 dc.b		5				  
		   dc.b		7				  
		   dc.b		9
		   ds.b		1				 ;space for result
		   end


now i'm thinking that the answer is 21 and overwrites the actual value of 9, however i only come to this conclusion because isn't it so that ds.b just means to reserve space in a1 for the answer, not actually be called upon.

** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: Assembly Language : Where is the answer stored?

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5392
  • View blog
  • Posts: 27,387
  • Joined: 10-May 07

Re: Assembly Language : Where is the answer stored?

Posted 04 June 2008 - 11:18 PM

I thought the data segment always went at the top. Not like a "should" but a as a rule.

Which assembler language is this?
Was This Post Helpful? 0
  • +
  • -

#3 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Assembly Language : Where is the answer stored?

Posted 07 June 2008 - 04:23 PM

you can put the data anywhere you want it! Back in my days of writing TSR's I actually put the data into the code segment so that it could all fit into one littl package. So my first command of the program would be a jump to "jump over" all the data... well... I remember the first command was a jump, but I am not SURE it was for the data... I do seem to remember the data at the end of the program. I will have to look into that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1