Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   d(x,b) explanation? (http://www.go4expert.com/forums/d-xb-explanation-t27671/)

eaglei22 27Jan2012 14:43

d(x,b) explanation?
 
So lets say we have A r,D(X,B)

I know the contents of the fullword starting at address given by D(X,B) will be added to register "r"

I get the operation, I'm just confused on the D(X,B) part. I know D is the displacement written in decimal and then converted to hex. B is the base register loaded from the using statement, but I don't understand X.. I get it's for an index register but what does it actually do?

and if the displacement can be up to 4095, what is actually taking place if a register can only hold up to 32 bytes (I believe, that's what I read somewhere).. I thought the displacement is moving the "pointer" up and down the memory address stored in the base register.

The resources I have are just technical information so I still don't understand what is happening and I guess I just need a simple, less book jargon explanation. I get most of the coding but visualizing how everything works with storage from the registers, how much memory each register actually holds and how the addressing is assigned to the base register and where it goes from there, and how everything syncs up with the other registers is all confusing to me currently.

I'm studying Assembly Language in Assist on the z/os system in grad school and I want to have a firm grasp on all this stuff because when I graduate, I'd like to work with embedded systems; and especially have a good chance with jobs like this with Lockheed Martin, Boeing, or/and ultimately NASA. So I'd like to master the subject.

Thank you!

xpi0t0s 28Jan2012 05:54

Re: d(x,b) explanation?
 
Which CPU are you using?

eaglei22 28Jan2012 06:50

Re: d(x,b) explanation?
 
I'm not 100% it's on the marist mainfraim in another location.. I use the vista tn3720 terminal to access it remotely. Is there a way to find out through that program?

xpi0t0s 28Jan2012 07:02

Re: d(x,b) explanation?
 
No idea. You're the one who wants to be an embedded programming expert, finding out what CPU you're using is about as relevant as a professional racing driver finding out what kind of car he's driving.

eaglei22 28Jan2012 08:03

Re: d(x,b) explanation?
 
I'm brand new to the mainfraim and Assembly langauge, cut me some slack :happy:, I can ask around when I'm back up at school Tuesday. Can you just pick a scenero of a cpu, and explain? Would greatly appreciate it.. So I can start wrapping my head around this stuff.

eaglei22 28Jan2012 08:11

Re: d(x,b) explanation?
 
Grr, I keep typing Mainfraim, when I mean to say Mainframe.. I'm searching google now to see if I can find out what type of CPU marist runs on their Mainframe.

xpi0t0s 28Jan2012 14:18

Re: d(x,b) explanation?
 
It isn't necessarily going to be the same for every CPU, that's why I asked in the first place. But if you think it'll help, have a look at http://uva.ulb.ac.be/cit_courseware/asm/mc68000.htm and scroll down to ADDRESS REGISTER INDIRECT WITH INDEX (8-BIT) and MOVE.W $02(A0,A1.W),D0 is the relevant command.

So let's suppose you have a data structure in memory stored at A0. The offset into that data structure of the data item you want is $02. And you want to iterate over that item - maybe it's a string, for example. You don't want to change A0 because you want to keep that address around, and if you change it you'd have to remember by how much you changed it, and remember to change it back, so overall that's a bad idea. So what you need is a throwaway counter variable, and that's what the index is for.

So the code would start with A1=0, and suppose it's a C string that's NULL-terminated, so you pull out of memory the character defined by $02(A0,A1.W) which is (A0+2)+0. If that string is "hi" then that's an 'h'.

You then increment A1 by 1 and pull the next byte out of memory, which is 'i' at (A0+2)+1.

You then increment A1 by 1 and pull the next byte out of memory, which is '\0' (the terminating NULL) at (A0+2)+2.

Put all that in a loop and you have the following pseudocode:

Code:

A1=0
D0=( (A0+2)+A1 )
while D0 != 0 LOOP
// do whatever you want with D0 - display it on the screen, for example
A1=A1+1
D0=( (A0+2)+A1 )
END LOOP


eaglei22 10Feb2012 14:34

Re: d(x,b) explanation?
 
Hey thanks a lot, that actually helped me with my last assignment. Appreciate the time to respond to me.


All times are GMT +5.5. The time now is 10:36.