Reputation: 153
Good morning,
I am trying to make a linked list which must contain a char for each node. So first the teacher provided us a code. This code creates a linked list where we can put numbers. Then we must change the code to output the numbers in order of size (0 to 99999). This was easily done. For example i can type:
"3 5 4 2 1"
and my list will contain:
[3|adr_nxt] [5|adr_nxt] [4|adr_nxt] [2|adr_nxt] [1|adr_nxt]
and then it will output: 12345
Next step is to replace numbers with char.
For example i type: "hdbcu"
and the list will contain each char separately :
[h|adr_nxt] [d|adr_nxt] [b|adr_nxt] [c|adr_nxt] [u|adr_nxt]
then it should output : bcdhu
So what i did was change the size of the value in the list from 2 bytes to 1 as it is advised by the teacher.
My problem is that it works if i let it 2 bytes and do a CHARI mVal,x
but if i do (after putting only 1 byte)
CHARI letter,d
LDA 0,i
LDBYTEA letter,d
STA mVal,x
then it doesnt work anymore and gives me crap values (and mess up my pointers too)
[00|wrong_adress] for every node
here is my code: https://pastebin.com/yyHRB89V it's quite long so i putted it in a pastebin instead.
tl;dr: i must put chars in a linked list and then sort them in alphabetical order. I can't put them in the linked list.
Upvotes: 0
Views: 171
Reputation: 153
So i did find the answer and it works using STBYTEA
So the final code would be :
CHARI letter,d
LDA 0,i
LDBYTEA letter,d
STBYTEA mVal,x
And it works !
Upvotes: 0