EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Help needed in writing a 68HC11 assembly program

Started by icbinghui July 22, 2006
hi all

I am currently having problem in writing a 68HC11 assembly program
which requires me to:

Arrange an array of double byte signed numbers in ascending order.
The number of elements in the array is specified by the user.
Example: BC45 , 46F5, 8678, 1078,78CF

In ascending order : 8678,BC45,1078,46F5,78CF

I am suppose to use the THRSIM11 simulator to test out this program.
Is there any sample of this program so i can stimulate it in the
THRSIM11 simulator?

pls help me

You are supposed to at least try to write the program, not just run an
'example' of it. Maybe try to sort a bunch of one byte numbers first? That sounds
easier to start things off. Lots of folks will help you find bugs in your
program if you get stumped.
--- In m..., BobGardner@... wrote:
>
> You are supposed to at least try to write the program, not just run an
> 'example' of it. Maybe try to sort a bunch of one byte numbers
first? That sounds
> easier to start things off. Lots of folks will help you find bugs in
your
> program if you get stumped.
>
>

well.. that's the thing. I have tried writing it several times but i
still couldn't get it done. I thought it might be easier if I can have
some guidelines or examples which relate to the question which i am
dealing right now. Maybe i can start off from there. I really tried my
very best to write this program. I just started learning it three
weeks ago. Is there any important operation which i miss?

Hope you can understand my dillema...
In a message dated 7/22/2006 11:25:07 A.M. Eastern Standard Time,
i...@gmail.com writes:

Is there any important operation which i miss?

========================================Try to write the smallest complete program that does something simple, like
init the stack pointer, turn on an output with an led, delay 100ms, turn off
the led, delay 100 ms, jump back. We can help you debug that. Then you can do
the sort program.


icbinghui wrote:
> --- In m..., BobGardner@... wrote:
>
>>You are supposed to at least try to write the program, not just run an
>>'example' of it. Maybe try to sort a bunch of one byte numbers
>
> first? That sounds
>
>>easier to start things off. Lots of folks will help you find bugs in
>
> your
>
>>program if you get stumped.
>>
>>
> well.. that's the thing. I have tried writing it several times but i
> still couldn't get it done. I thought it might be easier if I can have
> some guidelines or examples which relate to the question which i am
> dealing right now. Maybe i can start off from there. I really tried my
> very best to write this program. I just started learning it three
> weeks ago. Is there any important operation which i miss?
>
> Hope you can understand my dillema...

No, I can't. He told you what to do. Work until
you get stuck, post what you have here, along with
questions, and you'll get help.

Also, be aware that your Prof. is reading this.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!
Dear icbinghui,

Go to your college library and check out "The Art of Computer
Programming", Vol. 3, "Sorting and Searching", by Donald Knuth, Addison
Wesley, ISBN 0-201-03803-X. Knuth had originally planned a 10-20 volume
series covering all phases of the programming arts up through compiler
writing. I don't think he ever got beyond the first three volumes.
Even so, these volumes are priceless and should be components of the
library of any serious programmer.

The most common "simple" sort is the so called "bubble" sort where you
search the list from bottom to top multiple times searching for the
higher valued argument and promoting it up the list. The promotion of
the 'current' value is done in-place each time a new higher value is
found. Eventually all higher values will "bubble" to the top of the
list and lower values will "sink" to the bottom.

The down side of the "bubble" sort is that the computing time required
for a list with n members is proportional to 12^^n so it is not
suitable for 'large' lists.

I am sure that Knuth's books are out of publication by now (my copy is
dated 1973) but you should be able to find good used copies at Amazon or
the used book store at your college.

Also, searching via Google with the argument "+bubble+sort" should yield
some discussions and many examples.

Best wishes,

Bob Smith

icbinghui wrote:
> --- In m..., BobGardner@... wrote:
>>
>> You are supposed to at least try to write the program, not just run
>> an 'example' of it. Maybe try to sort a bunch of one byte numbers
> first? That sounds

Hi Robert,

I must say I agree that Knuth's Sorting and Searching is invaluable.
It's got all sorts of good stuff in it like Batcher Sorting networks
which are supposed to be about the most efficient sort you can
perform, in terms of compares and swaps.

BTW ... I'm fairly new to the list, so hi to every one.
I've got some FPGA 8 bit Motorola processors on my web site
people might be interested in if they are keen to expand their technical
horizons.

http://members.optusnet.com.au/jekent/FPGA.htm

I have an FPGA 68HC11 core that has been sitting there incomplete for
some time.
I had problems sorting out how to implement the 16 bit and 32 bit divide
instructions.
I'm currently completing testing of a 6809 core. The 6809 runs on a 12.5 MHz
E clock and has VDU, PS/2 Keyboard interface, ACIA, etc. all built in.
It will run on a US$99 Xilinx Spartan3 starter board.

I also have a 6800/6801 core and an incomplete 6805 core.
They are all free for people to download and try out.

John.

Robert Smith wrote:
>
> Dear icbinghui,
>
> Go to your college library and check out "The Art of Computer
> Programming", Vol. 3, "Sorting and Searching", by Donald Knuth, Addison
> Wesley, ISBN 0-201-03803-X. Knuth had originally planned a 10-20 volume
> series covering all phases of the programming arts up through compiler
> writing. I don't think he ever got beyond the first three volumes.
> Even so, these volumes are priceless and should be components of the
> library of any serious programmer.
>

--
http://members.optushome.com.au/jekent

OK, what "examples" do you have at your disposal? Do you have a "hello
world" example? That is something that flashes LED s in a port or
something as a starting place. I assume you have access to the hc11
reference manual. That manual has a large number of functional examples
that will include (in various contexts) comparisons, condition tests and
the like. Research the instruction set. I know, there is a lot of
words, but you are a student aren't you? As a programmer you will be
referencing the reference manual a lot, hence the name.. The sooner you
start exploring the better you will do. Find the comparison and
branching instructions you think apply, modify the "hello world" example
to do different things based on the instructions you want to use. When
actual result equals expected result consider that instruction
understood and continue.

Hope that helps,

Jim
--- In m..., "Jim Peterson" wrote:
>
>
> OK, what "examples" do you have at your disposal? Do you have a "hello
> world" example? That is something that flashes LED s in a port or
> something as a starting place. I assume you have access to the hc11
> reference manual. That manual has a large number of functional examples
> that will include (in various contexts) comparisons, condition tests and
> the like. Research the instruction set. I know, there is a lot of
> words, but you are a student aren't you? As a programmer you will be
> referencing the reference manual a lot, hence the name.. The sooner you
> start exploring the better you will do. Find the comparison and
> branching instructions you think apply, modify the "hello world" example
> to do different things based on the instructions you want to use. When
> actual result equals expected result consider that instruction
> understood and continue.
>
> Hope that helps,
>
> Jim
>

Dear Jim,

LOL .. i think there is some missunderstanding here. I am not a
programmer-to-be in the future. I'm currently taking up a degree in
electrical and electronics(E&E) and 68hc11 is part of my module in
this course. I have not gone so far yet and seriously, i have no idea
about the LED thingy like what Bob and you were saying. Or maybe it is
my fault asking the wrong stuff in this forum cause i though 68HC11
assembly program is mainly just about writing out program and execute
it in THRSIM11 simulator. please don't be mad at me because i'm really
new to this.

Thanks BOB ROBERT and JIM for helping me out.
On Jul 22, 2006, at 12:43 PM, icbinghui wrote:

> LOL .. i think there is some missunderstanding here. I am not a
> programmer-to-be in the future. I'm currently taking up a degree in
> electrical and electronics(E&E) and 68hc11 is part of my module in
> this course.

Well, embedded software is very much a part of E&E. Embedded software
is too important to trust to Computer Science grads.

About 10 years ago where I was working had an opening for an entry
level system/security/database administrator. Of the 20 or so resumes
forwarded from the personnel department of recent grads, not one had
any experience outside of Microsoft Visual tools. I couldn't convince
personnel to provide resumes of candidates with something other than
a CS degree. Didn't bother to invite any for an interview. Position
remained unfilled until end of contract.

> I have not gone so far yet and seriously, i have no idea
> about the LED thingy like what Bob and you were saying.

Flashing an LED is about the easiest exercise one can do on real
hardware while having some sort of indication the program is actually
running as intended.

> Or maybe it is my fault asking the wrong stuff in this forum

We see a good number of students asking someone to do their homework
for them. Thats not the same thing as asking for help with an
assignment.

> cause i though 68HC11 assembly program is mainly just about writing
> out program and execute it in THRSIM11 simulator. please don't be
> mad at me because i'm really new to this.

You have a relatively trivial assignment. Most of what you are
expected to learn is how to get the CPU up and running. The
instructor wants to see that you initialized the CPU registers and
stack to sane values before launching into your problem. There should
be plenty of examples floating around for you to start. Probably
everything the instructor will look for was covered in class.

As for the sort, because you have such a small array start at the
front and compare the 1st and 2nd values. If the 2nd is greater than
the 1st, write them back in the new order. Then because you swapped
values start over at the beginning again and march thru the whole
list until you reach the end without swapping. This isn't terribly
efficient but should be easy and require the least amount of code.
The instructor is going to look to see how you handle indirection and
the arrays.

--
David Kelly N4HHE, d...@HiWAAY.net
=======================================================================Whom computers would destroy, they must first drive mad.

Memfault Beyond the Launch