Hello all, I have a few questions maybe someone can help me with.
** 1st - while this is not really an kip irvine question....I am limited to his material only. I cannot use any of the fancy stuff in MASM32
**2nd - If my questions sound retarded it's because they are, they say there are no such things as stupid questions....but I think there are, I ask most of them.
I am trying to build a linked list, I have never tried and this is my 1st time.
is there another way to make or simulate a linked list besides doing something like this?
ListNode STRUCT
NodeData DWORD ? ; the node's data
NextPtr DWORD ? ; pointer to next node
ListNode ENDS
I have a file that I have read into a buffer in my program.
The data file looks like this:
Joe 80
Billy 78
Jerry 60
Amy 100
I would like to use the stack and address references to access values indirectly.
I have to sort the data and put it in a linked list in grade order from least to greatest.
The other problem is that I don't know how I would save the name and grade individually.
Thanks for any feedback
Hi Jbarrera,
you may see this (Linked List Database)
http://masm32.com/board/index.php?topic=3226.msg34406#msg34406 (http://masm32.com/board/index.php?topic=3226.msg34406#msg34406)
Wow, that is a really nice write-up, it really is. I see that you are not a fan of the Irvine stuff.....me...this is my first-semester taking assembly and That's all I have to work with
you are including in your asm program
\masm32\include\masm32rt.inc
.686
all I've been using is
Irvine32.inc
for all my programs,
it's not like I can walk up to my professor and tell him, hey why don't you start using the masm32.inc, right?....lol
Your program is a Ferrari, yet I can't even drive.
Don't give me wrong, I read your program, it's really nice, it's just way over my head.
Quote from: Jbarrera on April 08, 2018, 01:34:46 PM
it's not like I can walk up to my professor and tell him, hey why don't you start using the masm32.inc, right?....lol
That is exactly what you
should do :t
QuoteYour program is a Ferrari
Don't exaggerate. To put things in proportion:
Masm32rt.inc: | Irvine.inc: |
(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRRDPcC2hi4t1FpFLGkZfmLz7AorCvNG238bz2rNM-EpDTth8u8) | (https://mytoys.scene7.com/is/image/myToys/ext/1923122-01.jpg?$rtf_mt_prod-tile_xl$) |
Hi JBarrera
You have records of Name+Grade. So define a ListNode struct for name, for grade and for pointer to next node. Define a buffer - an array (a database) - for N records and format it first. After this you know where to put the next record (Name and Grade). Next you call a procedure to adjust the pointer to the next node ... The database needs to have (at least) a variable that points to the first record and a variable to point where to put the next record.
Think about it.
Good luck :t
EDIT: Taking your example we may have this:
.data
FirstRecord dd 3 ; first is record 3
AllocRecord dd 5 ; put next into record 5
LkdDatabase dd 4 ; Record 1 -> next is record 4
dd 80 ; grade
db "Joe ",0 ; name
;
dd 1 ; Record 2 -> next is record 1
dd 78
db "Billy ",0
;
dd 2 ; Record 3 -> next is record 2
dd 60
db "Jerry ",0
;
dd 0 ; Record 4 -> 0=> this is the last
dd 100
db "Amy ",0
;
dd 6 ; Record 5 -> next to alloc is record 6
dd 0
db " ",0
;
...
In this example we use indexes, not pointers. We may save the variables and the database to a file and we may alloc memory and load it again from file to memory and it works correctly.
When we fill in the record 5 we move the index 6 to the variable AllocRecord. The last value must be 0. If AllocRecord is 0 when we try to alloc a new record it means that the Database is full. FirstRecord must start with 0 which means that there are no records. AllocRecords starts with 1.