If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

68hc11, largest unsigned contents of memory question

Hi...I'm trying to figure out this homework question, and it's the only question I've been truly stuck on.

Write the assembly language instructions to put the largest unsigned contents of memory locations $3000 and $3001 into memory location $4000

I don't even know where to start, I would imagine I have to use compare instructions, but I can't figure out how to use them. Any help would be appreciated. The answer with an explanation I can follow would be best. I know we don't like to just give answers out on here, but I think having the answer will be the only way I can learn how to do this sort of thing. Thanks!!!

Re: 68hc11, largest unsigned contents of memory question

These are the general steps your program needs to take in order to accomplish its goal:

Read the value from location $3000. (It would commonly be read into a register called "accumulator" on a microprocessor.)

Compare the value you just read in step #1 to that in memory location $3001. You may or may not need to read the value from $3001 into another (i.e. not the accumulator) register before you can do the actual comparison; this depends on the set of supported instructions on the 68HC11.

Execute a conditional jump (AKA conditional branch) instruction that lets your program continue execution at step #5 if the value from location $3001 turned out to be greater (or greater-or-equal) than the value you read into the accumulator in step #1.

This step will only be reached if the value in the accumulator (i.e. the one from location $3000) was the greater one. So now store that into memory location $4000. Now you're done.

When you get here, the value at memory location $3001 was the greater one, so store that to location $4000. You may or may not need to load the value into a regster before you can do so, depending on whether or not you already loaded it in step #2. Done.

The steps above will not translate into assembly language instructions one-to-one, but the structure of the concrete program will be very similar. Also note that this clear-text description is much longer than the actual assembly language program will be (counting characters or words rather than lines and not counting any comments in the program code that explain what's going on, which generally are quite recommended in assembly language).

Besides the fact that I would not give you a ready-made program you can submit as the answer, actually I could not, because I don't know the specific assembly language of the 68HC11.

HTH

I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Re: 68hc11, largest unsigned contents of memory question

there's not much we can do here that wouldn't be in violation of the forum rules about not flat out giving the answers to homework.
Even a rough step by step if "too far" in this case because that's pretty much the whole problem here.

but yes, what you need is a compare operation (there's 3 to pick from for the 8bit versions, and 3 for 16bit which aren't relevant here). and then you need to do something with the result of that compare.

68hc11 specific, there's a compare_and_assign_largest_byte "trick" you can pull that does this entirely arithmatically (which has it's advantages in some cases, but I can't say much more about that without giving away the answer), but I doubt that's what your homework is really after.

Re: 68hc11, largest unsigned contents of memory question

Thanks guys, that's exactly how I ended up doing it anyway. It's nice to have some reassurance though! It's just one out of about 100 homework problem guys, it's not even graded. I just wanted to know how to do it. Eri523, I think you're fine. If you can't get help here, what's the point of the forum. I can see if I uploaded my final and asked people to do it. Anyway, thanks for the help!

Re: 68hc11, largest unsigned contents of memory question

Originally Posted by mdbriscoe

Thanks guys, that's exactly how I ended up doing it anyway. It's nice to have some reassurance though! It's just one out of about 100 homework problem guys, it's not even graded. I just wanted to know how to do it. Eri523, I think you're fine. If you can't get help here, what's the point of the forum. I can see if I uploaded my final and asked people to do it. Anyway, thanks for the help!

The point of the forum is to help people, but at the same time, it's not the point to do your homework for you, which is technically cheating.

If you want reassurance, then next time, do the homework yourself
post the results of your work here, and ask "is this correct" or "how could this be improved".
As to the "is this correct", you can also largely verify this yourself by actually inputting this in an assembler and loading it up, there are even several freeware full 68hc11 emulators and several simple state machines. There's even (free) in circuit emulators (ICE) that will allow you to emulate/debug/try things at a really low level, including voltage changes on the pins.

Re: 68hc11, largest unsigned contents of memory question

If you think about it, this is pretty elementary stuff. and the question asked here is "how does a conditional work" akin to C/C++

Code:

if (test)
do_something;

So the solution you give is pretty much the problem explained, apart from the actual 'translate that into assembly statements'

Yeah, at such a low level it's pretty difficult to clearly draw the line of dstinction between an understandable explanation and the practical equivalent of a given-out solution. After asking whether it might be a good idea to remove my post, I thought about it some more and came to the conclusion that what I wrote could, more or less similar, be from a student's text book (in particular as it doesn't contain any refrence to the concrete platform in question, thus leaving the final rendition up to the student).

You may now, correctly, object, that in this case the OP might as well have looked it up in the text book in the first place. Unfortunately, as we know, explanations from actual text books (or teachers) aren't aways really understandable...

I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.