Welcome to Dream.In.Code
Getting Help is Easy!

Join 105,765 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,635 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Assembly Language : Where is the answer stored?

 
Reply to this topicStart new topic

Assembly Language : Where is the answer stored?, Ultimate Noob to Assembly

nomad1987
post 4 Jun, 2008 - 11:15 PM
Post #1


New D.I.C Head

*
Joined: 4 Jun, 2008
Posts: 1

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

CODE

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.gif
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 4 Jun, 2008 - 11:18 PM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,710



Thanked 25 times

Dream Kudos: 2325

Expert In: Goofing Off

My Contributions


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

Which assembler language is this?
User is online!Profile CardPM

Go to the top of the page

NickDMax
post 7 Jun, 2008 - 04:23 PM
Post #3


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,672



Thanked 26 times

Dream Kudos: 475
My Contributions


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.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/21/08 02:25PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month