CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jul 2014
    Posts
    3

    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!!!

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: 68hc11, largest unsigned contents of memory question

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

    1. Read the value from location $3000. (It would commonly be read into a register called "accumulator" on a microprocessor.)
    2. 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.
    3. 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.
    4. 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.
    5. 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.

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    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.

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: 68hc11, largest unsigned contents of memory question

    Quote Originally Posted by OReubens View Post
    [...] Even a rough step by step if "too far" in this case because that's pretty much the whole problem here.
    Oops!

    Do you really think my post #2 above goes too far? I consider removing it in this case...
    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.

  5. #5
    Join Date
    Jul 2014
    Posts
    3

    Re: 68hc11, largest unsigned contents of memory question

    Quote Originally Posted by Eri523 View Post
    Oops!

    Do you really think my post #2 above goes too far? I consider removing it in this case...
    I just re-read the forum rules on homework help...you are fine! Thanks for taking the time to help me.

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: 68hc11, largest unsigned contents of memory question

    Quote Originally Posted by Eri523 View Post
    Oops!

    Do you really think my post #2 above goes too far? I consider removing it in this case...
    it might.

    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'

  7. #7
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: 68hc11, largest unsigned contents of memory question

    Quote Originally Posted by OReubens View Post
    [...]

    it might.

    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.

  8. #8
    Join Date
    Jul 2014
    Posts
    3

    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!

  9. #9
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: 68hc11, largest unsigned contents of memory question

    Quote Originally Posted by mdbriscoe View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured