So close...InOrder Binary Tree Traversal (again...)

  • Follow


Hi Groupies,

Been working on this for weeks. Reaching the end of my tether.

Here is the code;

;*********************************************
;	SecStage.asm
;     - Binary Tree Routines
;
;Last ammended: 27th December 2010 : 11:23am
;Location: Starbucks, Nottm
;*********************************************

; The following code exports all values from the binary
; tree to screen using a loop algorithm.
; +0 Address = Value
; +4 Address = Lesser  than node address
; +8 Address = Greater than node address
; A, B, C plan below
; a) no left node = output
; b) pop address and output right node
; c) jump to a)

traverseTree:
	push DWORD 0xA0A0A0A0
..LA:
	; has it got a left node?
	mov ebx, eax
	add ebx, 4
	cmp DWORD [ebx], 0
	je .NoLeftNode
	push DWORD [eax]
	; load next left node
	mov eax, [ebx]
	jmp .LA
..NoLeftNode:
	add ebx, 4
	cmp DWORD [ebx], 0
	je .NoNodes
	push DWORD [eax]
	mov eax, [ebx]
	jmp .LA
..NoNodes:
	pop eax
	cmp eax, 0xA0A0A0A0
	je .Fin
	push eax
	mov eax, [eax]
	mov ebx, 10
	call writeInt
	pop eax
	jmp .LA
..Fin:
	ret


This is really a BUG headache! For some reason, I cannot find the
right order of commands to execute this In Order Binary Tree
traversal? Can anyone spot the mistakes? Also, take a look at
Wikipedia if need be, to brush up on In Order Traversal. The wiki page
has a neat push/pop sequence for InOrder Traversal, that I've been
thinking over. But, to no avail.

Thank you kindly in advance for any insights you may offer on the
subject,

Catcalls
0
Reply obrzut.alex (64) 3/6/2011 8:58:40 AM

On 06.03.2011 09:58, catcalls wrote:
> Hi Groupies,
> 
> Been working on this for weeks. Reaching the end of my tether.
> 
> Here is the code;
> 
> ;*********************************************
> ;	SecStage.asm
> ;     - Binary Tree Routines
> ;
> ;Last ammended: 27th December 2010 : 11:23am
> ;Location: Starbucks, Nottm
> ;*********************************************
> 
> ; The following code exports all values from the binary
> ; tree to screen using a loop algorithm.
> ; +0 Address = Value
> ; +4 Address = Lesser  than node address
> ; +8 Address = Greater than node address
> ; A, B, C plan below
> ; a) no left node = output
> ; b) pop address and output right node
> ; c) jump to a)
> 
> traverseTree:
> 	push DWORD 0xA0A0A0A0
> .LA:
> 	; has it got a left node?
> 	mov ebx, eax
> 	add ebx, 4
> 	cmp DWORD [ebx], 0
> 	je .NoLeftNode
> 	push DWORD [eax]
> 	; load next left node
> 	mov eax, [ebx]
> 	jmp .LA
> .NoLeftNode:
> 	add ebx, 4
> 	cmp DWORD [ebx], 0
> 	je .NoNodes
> 	push DWORD [eax]
> 	mov eax, [ebx]
> 	jmp .LA
> .NoNodes:
> 	pop eax
> 	cmp eax, 0xA0A0A0A0
> 	je .Fin
> 	push eax
> 	mov eax, [eax]
> 	mov ebx, 10
> 	call writeInt
> 	pop eax
> 	jmp .LA
> .Fin:
> 	ret
> 
> 
> This is really a BUG headache! For some reason, I cannot find the
> right order of commands to execute this In Order Binary Tree
> traversal? Can anyone spot the mistakes? Also, take a look at
> Wikipedia if need be, to brush up on In Order Traversal. The wiki page
> has a neat push/pop sequence for InOrder Traversal, that I've been
> thinking over. But, to no avail.
> 
> Thank you kindly in advance for any insights you may offer on the
> subject,
> 
> Catcalls

If all else fails, ask someone who knows about this stuff. a compiler,
for once. Now, gcc surprised me a bit:

$ gcc -m32 -O3 -S inorder.c
$ wc -l inorder.s
169
$ gcc -m32 -Os -S inorder.c
$ wc -l inorder.s
37

It shouldn't be faster to be using 4.5 times the code size, should it?

My Computer Science classes taught me that algorithm:

inorder(struct node* node) {
    if (node->left) inorder(node->left);
    output(node);
    if (node->right) inorder(node->right);
}

Well, here's what gcc makes of it. Warning: SysV ABI (Meaning only eax,
ecx and edx are caller saved, the rest is callee saved)

inorder:
    push ebp
    mov ebp, esp
    push ebx
    sub esp, 4
    mov ebx, [ebp+8]
..L3:
    mov eax, [ebp+4]
    test eax, eax
    jz .L2
    sub esp, 12
    push eax
    call inorder
    add esp, 16
..L2:
    sub esp, 12
    push ebx
    call output
    mov ebx, [ebx+8]
    add esp, 16
    test ebx, ebx
    jnz .L3
    mov ebx, [ebp-4]
    leave
    ret

HTH,
Markus
0
Reply nullplan1 (27) 3/6/2011 10:53:19 AM


On Mar 6, 8:58=A0am, catcalls <obrzut.a...@nospicedham.gmail.com> wrote:
> Hi Groupies,
>
> Been working on this for weeks. Reaching the end of my tether.
>
> Here is the code;
>
> ;*********************************************
> ; =A0 =A0 =A0 SecStage.asm
> ; =A0 =A0 - Binary Tree Routines
> ;
> ;Last ammended: 27th December 2010 : 11:23am
> ;Location: Starbucks, Nottm
> ;*********************************************
>
> ; The following code exports all values from the binary
> ; tree to screen using a loop algorithm.
> ; +0 Address =3D Value
> ; +4 Address =3D Lesser =A0than node address
> ; +8 Address =3D Greater than node address
> ; A, B, C plan below
> ; a) no left node =3D output
> ; b) pop address and output right node
> ; c) jump to a)
>
> traverseTree:
> =A0 =A0 =A0 =A0 push DWORD 0xA0A0A0A0
> .LA:
> =A0 =A0 =A0 =A0 ; has it got a left node?
> =A0 =A0 =A0 =A0 mov ebx, eax
> =A0 =A0 =A0 =A0 add ebx, 4
> =A0 =A0 =A0 =A0 cmp DWORD [ebx], 0
> =A0 =A0 =A0 =A0 je .NoLeftNode
> =A0 =A0 =A0 =A0 push DWORD [eax]
> =A0 =A0 =A0 =A0 ; load next left node
> =A0 =A0 =A0 =A0 mov eax, [ebx]
> =A0 =A0 =A0 =A0 jmp .LA
> .NoLeftNode:
> =A0 =A0 =A0 =A0 add ebx, 4
> =A0 =A0 =A0 =A0 cmp DWORD [ebx], 0
> =A0 =A0 =A0 =A0 je .NoNodes
> =A0 =A0 =A0 =A0 push DWORD [eax]
> =A0 =A0 =A0 =A0 mov eax, [ebx]
> =A0 =A0 =A0 =A0 jmp .LA
> .NoNodes:
> =A0 =A0 =A0 =A0 pop eax
> =A0 =A0 =A0 =A0 cmp eax, 0xA0A0A0A0
> =A0 =A0 =A0 =A0 je .Fin
> =A0 =A0 =A0 =A0 push eax
> =A0 =A0 =A0 =A0 mov eax, [eax]
> =A0 =A0 =A0 =A0 mov ebx, 10
> =A0 =A0 =A0 =A0 call writeInt
> =A0 =A0 =A0 =A0 pop eax
> =A0 =A0 =A0 =A0 jmp .LA
> .Fin:
> =A0 =A0 =A0 =A0 ret
>
> This is really a BUG headache! For some reason, I cannot find the
> right order of commands to execute this In Order Binary Tree
> traversal? Can anyone spot the mistakes? Also, take a look at
> Wikipedia if need be, to brush up on In Order Traversal. The wiki page
> has a neat push/pop sequence for InOrder Traversal, that I've been
> thinking over. But, to no avail.
>
> Thank you kindly in advance for any insights you may offer on the
> subject,
>
> Catcalls

;push all left nodes
;pop left nodes
;then insert first right node
;push all left nodes
;

traverseTree:
	push DWORD 0xA0A0A0A0
..LA:
	push eax
	mov ebx, eax
	add ebx, 4
	cmp DWORD [ebx], 0
	je .NoLeftNode
	mov DWORD eax, [ebx]
	jmp .LA
..NoLeftNode:
	pop eax
	cmp eax, 0xA0A0A0A0
	je .Fin
	push eax
	mov ebx, 10
	mov eax, [eax]
	call writeInt
	pop eax
	mov ebx, eax
	add ebx, 8
	cmp DWORD [ebx], 0
	je .NoNodes
	mov DWORD eax, [ebx]

..NoNodes:
	pop eax
	cmp eax, 0xA0A0A0A0
	je .Fin
	push eax
	mov ebx,10
	mov eax, [eax]
	call writeInt
	pop eax
	pop eax
	cmp eax, 0xA0A0A0A0
	je .Fin
	jmp .LA
..Fin:
	ret


This is a complete rewrite :( Not working either. But, I think this
reflects the wikipedia push/pop sequence more so than the other
program.

How ever, it out puts 9 and 11, the two lowest nodes, then goes into
infinite loop. This might be due to the .NoNodes section. Which is the
part I am looking at right now.

As usual, any insights are welcome!

Catcalls
0
Reply obrzut.alex (64) 3/6/2011 12:23:50 PM

catcalls <obrzut.alex@nospicedham.gmail.com> writes:

> Hi Groupies,
>
> Been working on this for weeks. Reaching the end of my tether.
>
> Here is the code;
>
> ;*********************************************
> ;	SecStage.asm
> ;     - Binary Tree Routines
> ;
> ;Last ammended: 27th December 2010 : 11:23am
> ;Location: Starbucks, Nottm
> ;*********************************************
>
> ; The following code exports all values from the binary
> ; tree to screen using a loop algorithm.
> ; +0 Address = Value
> ; +4 Address = Lesser  than node address
> ; +8 Address = Greater than node address
> ; A, B, C plan below
> ; a) no left node = output
> ; b) pop address and output right node
> ; c) jump to a)
>
> traverseTree:
> 	push DWORD 0xA0A0A0A0

Have you considered using 0x0 as end-of-stack marker?  That's unlikely
to be a valid memory address for your tree structure on most
architectures.

> .LA:
> 	; has it got a left node?
> 	mov ebx, eax
> 	add ebx, 4
> 	cmp DWORD [ebx], 0
> 	je .NoLeftNode
> 	push DWORD [eax]
> 	; load next left node
> 	mov eax, [ebx]
> 	jmp .LA
> .NoLeftNode:

Shouldn't you be printing the node value here?

> 	add ebx, 4
> 	cmp DWORD [ebx], 0
> 	je .NoNodes
> 	push DWORD [eax]

Why are you pushing before visiting the right-hand child?

> 	mov eax, [ebx]
> 	jmp .LA
> .NoNodes:
> 	pop eax
> 	cmp eax, 0xA0A0A0A0
> 	je .Fin
> 	push eax
> 	mov eax, [eax]
> 	mov ebx, 10
> 	call writeInt
> 	pop eax
> 	jmp .LA
> .Fin:
> 	ret
>
>
> This is really a BUG headache! For some reason, I cannot find the
> right order of commands to execute this In Order Binary Tree
> traversal? Can anyone spot the mistakes? Also, take a look at
> Wikipedia if need be, to brush up on In Order Traversal. The wiki page
> has a neat push/pop sequence for InOrder Traversal, that I've been
> thinking over. But, to no avail.

You don't say what your problem is (i.e., how does the bug manifest 
itself?)
Does the code not terminate, or does it terminate but print the wrong
value, and which inputs cause which behavior?

Before writing assembler, it's sometimes a good idea to have the
algorithm described in some sort of higher-level pseudocode. It's
easier to see logical errors or missing details at that level.
Then you can translate that code to assmebler without losing 
any details.

/L
-- 
Lasse Reichstein Holst Nielsen
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'
0
Reply lrn.unread9385 (10) 3/6/2011 12:30:43 PM

On Mar 6, 12:30=A0pm, Lasse Reichstein Nielsen
<lrn.unr...@nospicedham.gmail.com> wrote:
> catcalls <obrzut.a...@nospicedham.gmail.com> writes:
> > Hi Groupies,
>
> > Been working on this for weeks. Reaching the end of my tether.
>
> > Here is the code;
>
> > ;*********************************************
> > ; =A0SecStage.asm
> > ; =A0 =A0 - Binary Tree Routines
> > ;
> > ;Last ammended: 27th December 2010 : 11:23am
> > ;Location: Starbucks, Nottm
> > ;*********************************************
>
> > ; The following code exports all values from the binary
> > ; tree to screen using a loop algorithm.
> > ; +0 Address =3D Value
> > ; +4 Address =3D Lesser =A0than node address
> > ; +8 Address =3D Greater than node address
> > ; A, B, C plan below
> > ; a) no left node =3D output
> > ; b) pop address and output right node
> > ; c) jump to a)
>
> > traverseTree:
> > =A0 =A0push DWORD 0xA0A0A0A0
>
> Have you considered using 0x0 as end-of-stack marker? =A0That's unlikely
> to be a valid memory address for your tree structure on most
> architectures.
>
> > .LA:
> > =A0 =A0; has it got a left node?
> > =A0 =A0mov ebx, eax
> > =A0 =A0add ebx, 4
> > =A0 =A0cmp DWORD [ebx], 0
> > =A0 =A0je .NoLeftNode
> > =A0 =A0push DWORD [eax]
> > =A0 =A0; load next left node
> > =A0 =A0mov eax, [ebx]
> > =A0 =A0jmp .LA
> > .NoLeftNode:
>
> Shouldn't you be printing the node value here?
>
> > =A0 =A0add ebx, 4
> > =A0 =A0cmp DWORD [ebx], 0
> > =A0 =A0je .NoNodes
> > =A0 =A0push DWORD [eax]
>
> Why are you pushing before visiting the right-hand child?
>
>
>
>
>
> > =A0 =A0mov eax, [ebx]
> > =A0 =A0jmp .LA
> > .NoNodes:
> > =A0 =A0pop eax
> > =A0 =A0cmp eax, 0xA0A0A0A0
> > =A0 =A0je .Fin
> > =A0 =A0push eax
> > =A0 =A0mov eax, [eax]
> > =A0 =A0mov ebx, 10
> > =A0 =A0call writeInt
> > =A0 =A0pop eax
> > =A0 =A0jmp .LA
> > .Fin:
> > =A0 =A0ret
>
> > This is really a BUG headache! For some reason, I cannot find the
> > right order of commands to execute this In Order Binary Tree
> > traversal? Can anyone spot the mistakes? Also, take a look at
> > Wikipedia if need be, to brush up on In Order Traversal. The wiki page
> > has a neat push/pop sequence for InOrder Traversal, that I've been
> > thinking over. But, to no avail.
>
> You don't say what your problem is (i.e., how does the bug manifest
> itself?)
> Does the code not terminate, or does it terminate but print the wrong
> value, and which inputs cause which behavior?
>
> Before writing assembler, it's sometimes a good idea to have the
> algorithm described in some sort of higher-level pseudocode. It's
> easier to see logical errors or missing details at that level.
> Then you can translate that code to assmebler without losing
> any details.
>
> /L
> --
> Lasse Reichstein Holst Nielsen
> =A0DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.=
html>
> =A0 'Faith without judgement merely degrades the spirit divine.'- Hide qu=
oted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Dear Mr Nielsen,

Thank you for taking the time and energy to extend your ideas to this
thread.

I already have some pseudo-code over at the Wiki page. That is what I
am working from.

The first program in this thread is abandoned. And completely re-
factored into the second effort.

And to be quite blunt; Had a breakthrough! It seems the logical
equasion is clearing in my mind.

And it is just a matter of time before I accomplish this task. But, I
believe any help here will be greatly appreciated nontheless.

At the moment, it is a matter of pushing all the left nodes onto the
stack, until reaching a no-node situation, then popping them off as we
output.

Eventually, we'll reach a right hand node doing so, and that is where
we traverse the left hand nodes again until a null node pushing as we
go.

See, I can clearly illustrate the logic ~ But writing the code is
another matter altogether!

Thank you, Mr Nielson,

Cat
0
Reply obrzut.alex (64) 3/6/2011 1:28:49 PM

catcalls <obrzut.alex@nospicedham.gmail.com> writes:

> As usual, any insights are welcome!

Your code is complex - it pushes and pops the same value multiple times,
which makes it harder to reason about what's on the stack at any given
time. 

> .NoLeftNode:
> 	pop eax
> 	cmp eax, 0xA0A0A0A0

You only get herre from the je above, so the popped value cannot be
0xA0A0A0A0.

> 	je .NoNodes
> 	mov DWORD eax, [ebx]
>
> .NoNodes:

Shouldn't there be a jump to .LA before .NoNodes?

> 	call writeInt
>	pop eax
You need to check the right node of the node in eax here.
>	pop eax
>	cmp eax, 0xA0A0A0A0


It should be possible to make this simpler.
I'll try a quick rewrite (NASM syntax, not really tested, so beware)

InOrderTraverse:
     test eax, eax      ; Test for null input.
     jz done
     push DWORD 0       ; Using null as end-of-stack marker.
loop:
     mov ebx, [ebx + 4] ; while node has left, push node and loop on left
     test ebx, ebx
     jz after_left
     push eax
     mov eax, ebx
     jmp loop

after_left:
     push eax           ; Write value
     mov ebx, 10
     mov eax, [eax]
     call writeInt
     pop eax
     
     mov eax, [eax + 8] ; If node has right, loop on right.
     test eax, eax
     jnz loop

     pop eax            ; Else pop node and if it's not end-of stack,
     test eax, eax      ; continue after its left. 
     jnz after_left

done:
     ret        

/L
-- 
Lasse Reichstein Holst Nielsen
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'
0
Reply lrn.unread9385 (10) 3/6/2011 1:30:31 PM

Lasse Reichstein Nielsen <lrn.unread@nospicedham.gmail.com> writes:

> InOrderTraverse:
>      test eax, eax      ; Test for null input.
>      jz done
>      push DWORD 0       ; Using null as end-of-stack marker.
> loop:
>      mov ebx, [ebx + 4] ; while node has left, push node and loop on left

Typo, damnit!
       mov ebx, [eax + 4]

>      test ebx, ebx
>      jz after_left

/L
-- 
Lasse Reichstein Holst Nielsen
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'
0
Reply lrn.unread9385 (10) 3/6/2011 1:46:40 PM

Markus Wichmann wrote:

....
> inorder:
>     push ebp
>     mov ebp, esp
>     push ebx
>     sub esp, 4
>     mov ebx, [ebp+8]
> .L3:
>     mov eax, [ebp+4]

Can this be right??? ebx?

>     test eax, eax
>     jz .L2
>     sub esp, 12
>     push eax
>     call inorder
>     add esp, 16
> .L2:
>     sub esp, 12
>     push ebx
>     call output
>     mov ebx, [ebx+8]
>     add esp, 16
>     test ebx, ebx
>     jnz .L3
>     mov ebx, [ebp-4]
>     leave
>     ret
> 
> HTH,
> Markus

Best,
Frank
0
Reply fbkotler9831 (124) 3/6/2011 2:33:54 PM

On Mar 6, 2:33=A0pm, Frank Kotler <fbkot...@nospicedham.myfairpoint.net>
wrote:
> Markus Wichmann wrote:
>
> ...
>
> > inorder:
> > =A0 =A0 push ebp
> > =A0 =A0 mov ebp, esp
> > =A0 =A0 push ebx
> > =A0 =A0 sub esp, 4
> > =A0 =A0 mov ebx, [ebp+8]
> > .L3:
> > =A0 =A0 mov eax, [ebp+4]
>
> Can this be right??? ebx?
>
>
>
>
>
> > =A0 =A0 test eax, eax
> > =A0 =A0 jz .L2
> > =A0 =A0 sub esp, 12
> > =A0 =A0 push eax
> > =A0 =A0 call inorder
> > =A0 =A0 add esp, 16
> > .L2:
> > =A0 =A0 sub esp, 12
> > =A0 =A0 push ebx
> > =A0 =A0 call output
> > =A0 =A0 mov ebx, [ebx+8]
> > =A0 =A0 add esp, 16
> > =A0 =A0 test ebx, ebx
> > =A0 =A0 jnz .L3
> > =A0 =A0 mov ebx, [ebp-4]
> > =A0 =A0 leave
> > =A0 =A0 ret
>
> > HTH,
> > Markus
>
> Best,
> Frank- Hide quoted text -
>
> - Show quoted text -

Wow! THX!!!

Thanks, everyone, for you input. Expressedly valuable insights, love
it!

Got to test a lot of the code, so reserving my full response until
later.

Interesting to see other peoples take on this situation.

The stage I got at, after reading Nielsen's post, was the logic of it
all.

That is the stage I remain at now.

I'll def. be taking a long hard look at all the code snippets provided
here.

Excellent stuff people!

I cannot thank you enough :)

Really thankful,

Cat
0
Reply obrzut.alex (64) 3/6/2011 3:43:10 PM

On Mar 6, 3:43=A0pm, catcalls <obrzut.a...@nospicedham.gmail.com> wrote:
> On Mar 6, 2:33=A0pm, Frank Kotler <fbkot...@nospicedham.myfairpoint.net>
> wrote:
>
>
>
>
>
> > Markus Wichmann wrote:
>
> > ...
>
> > > inorder:
> > > =A0 =A0 push ebp
> > > =A0 =A0 mov ebp, esp
> > > =A0 =A0 push ebx
> > > =A0 =A0 sub esp, 4
> > > =A0 =A0 mov ebx, [ebp+8]
> > > .L3:
> > > =A0 =A0 mov eax, [ebp+4]
>
> > Can this be right??? ebx?
>
> > > =A0 =A0 test eax, eax
> > > =A0 =A0 jz .L2
> > > =A0 =A0 sub esp, 12
> > > =A0 =A0 push eax
> > > =A0 =A0 call inorder
> > > =A0 =A0 add esp, 16
> > > .L2:
> > > =A0 =A0 sub esp, 12
> > > =A0 =A0 push ebx
> > > =A0 =A0 call output
> > > =A0 =A0 mov ebx, [ebx+8]
> > > =A0 =A0 add esp, 16
> > > =A0 =A0 test ebx, ebx
> > > =A0 =A0 jnz .L3
> > > =A0 =A0 mov ebx, [ebp-4]
> > > =A0 =A0 leave
> > > =A0 =A0 ret
>
> > > HTH,
> > > Markus
>
> > Best,
> > Frank- Hide quoted text -
>
> > - Show quoted text -
>
> Wow! THX!!!
>
> Thanks, everyone, for you input. Expressedly valuable insights, love
> it!
>
> Got to test a lot of the code, so reserving my full response until
> later.
>
> Interesting to see other peoples take on this situation.
>
> The stage I got at, after reading Nielsen's post, was the logic of it
> all.
>
> That is the stage I remain at now.
>
> I'll def. be taking a long hard look at all the code snippets provided
> here.
>
> Excellent stuff people!
>
> I cannot thank you enough :)
>
> Really thankful,
>
> Cat- Hide quoted text -
>
> - Show quoted text -

On Mar 6, 2:33 pm, Frank Kotler <fbkot...@nospicedham.myfairpoint.net>
wrote:
> Markus Wichmann wrote:
>
> ...
>
> > inorder:
> >     push ebp
> >     mov ebp, esp
> >     push ebx
> >     sub esp, 4
> >     mov ebx, [ebp+8]
> > .L3:
> >     mov eax, [ebp+4]
>
> Can this be right??? ebx?
>
>
>
>
>
> >     test eax, eax
> >     jz .L2
> >     sub esp, 12
> >     push eax
> >     call inorder
> >     add esp, 16
> > .L2:
> >     sub esp, 12
> >     push ebx
> >     call output
> >     mov ebx, [ebx+8]
> >     add esp, 16
> >     test ebx, ebx
> >     jnz .L3
> >     mov ebx, [ebp-4]
> >     leave
> >     ret
>
> > HTH,
> > Markus
>
> Best,
> Frank- Hide quoted text -
>
> - Show quoted text -

Oh my LORD! Nielsen, well done, kind sir! You've beaten me to the
punch, so to speak :)

Your code is outstanding!

It works, first time, straight out the box. Only one line needed
changing. OMG!

Sorted! Excuse the pun!

Outstanding craftmanship. I might add.

Def. add a credit to you in my source code, Mr Nielsen.

Thank you,

Catcalls
0
Reply obrzut.alex (64) 3/6/2011 6:52:13 PM

catcalls wrote:

....
>>> Markus Wichmann wrote:
....
> Def. add a credit to you in my source code, Mr Nielsen.

Getting confused about whose code is whose? :)

Best,
Frank

0
Reply fbkotler9831 (124) 3/6/2011 11:07:09 PM

On Mar 6, 11:07=A0pm, Frank Kotler
<fbkot...@nospicedham.myfairpoint.net> wrote:
> catcalls wrote:
>
> ...
>
> >>> Markus Wichmann wrote:
> ...
> > Def. add a credit to you in my source code, Mr Nielsen.
>
> Getting confused about whose code is whose? :)
>
> Best,
> Frank

Hi Frank,

I'm crediting the traverseNode routine to Mr Nielsen. Yet, I've also
wrote several other routines in the same file. Which are mine.

Just thought I'd clear that issue up!

Kind regards,

Cat
0
Reply obrzut.alex (64) 3/7/2011 4:45:00 AM

On Mar 7, 4:45=A0am, catcalls <obrzut.a...@nospicedham.gmail.com> wrote:
> On Mar 6, 11:07=A0pm, Frank Kotler
>
> <fbkot...@nospicedham.myfairpoint.net> wrote:
> > catcalls wrote:
>
> > ...
>
> > >>> Markus Wichmann wrote:
> > ...
> > > Def. add a credit to you in my source code, Mr Nielsen.
>
> > Getting confused about whose code is whose? :)
>
> > Best,
> > Frank
>
> Hi Frank,
>
> I'm crediting the traverseNode routine to Mr Nielsen. Yet, I've also
> wrote several other routines in the same file. Which are mine.
>
> Just thought I'd clear that issue up!
>
> Kind regards,
>
> Cat

Oh, Frank, btw...There might be similarities between my code and Mr
Nielsen's code. But, his code works, whereas mine did not! *smiles*

Sometimes, you just need a fresh set of eyes on a problem, and to
another person who is new to it all, the solution just pops into their
head.

Thanks anyway for the concern,

Cat
0
Reply obrzut.alex (64) 3/7/2011 7:06:59 AM

catcalls wrote:
> On Mar 7, 4:45 am, catcalls <obrzut.a...@nospicedham.gmail.com> wrote:
>> On Mar 6, 11:07 pm, Frank Kotler
>>
>> <fbkot...@nospicedham.myfairpoint.net> wrote:
>>> catcalls wrote:
>>> ...
>>>>>> Markus Wichmann wrote:

....
> Oh, Frank, btw...There might be similarities between my code and Mr
> Nielsen's code. But, his code works, whereas mine did not! *smiles*

A minor but important difference! :)

But the code I stuck a comment into was from Markus Wichmann, not Lasse 
Reichstein Nielsen. I don't know which you're using. Important that 
*you* know, not me. :)

> Sometimes, you just need a fresh set of eyes on a problem, and to
> another person who is new to it all, the solution just pops into their
> head.

Agreed. I think it's very useful to pass these code snippets around and 
discus 'em.

1) Someone might spot a bug you've missed.
2) Someone might spot an improvement you can make.
3) Someone might learn something they can use to improve their own code.

You really can't lose!

> Thanks anyway for the concern,

No problem. I'm just trying to follow along... to "help"... or to 
"learn"... either is good...

Best,
Frank
0
Reply fbkotler9831 (124) 3/7/2011 9:29:24 AM

On Mar 7, 9:29=A0am, Frank Kotler <fbkot...@nospicedham.myfairpoint.net>
wrote:
> catcalls wrote:
> > On Mar 7, 4:45 am, catcalls <obrzut.a...@nospicedham.gmail.com> wrote:
> >> On Mar 6, 11:07 pm, Frank Kotler
>
> >> <fbkot...@nospicedham.myfairpoint.net> wrote:
> >>> catcalls wrote:
> >>> ...
> >>>>>> Markus Wichmann wrote:
>
> ...
>
> > Oh, Frank, btw...There might be similarities between my code and Mr
> > Nielsen's code. But, his code works, whereas mine did not! *smiles*
>
> A minor but important difference! :)
>
> But the code I stuck a comment into was from Markus Wichmann, not Lasse
> Reichstein Nielsen. I don't know which you're using. Important that
> *you* know, not me. :)
>
> > Sometimes, you just need a fresh set of eyes on a problem, and to
> > another person who is new to it all, the solution just pops into their
> > head.
>
> Agreed. I think it's very useful to pass these code snippets around and
> discus 'em.
>
> 1) Someone might spot a bug you've missed.
> 2) Someone might spot an improvement you can make.
> 3) Someone might learn something they can use to improve their own code.
>
> You really can't lose!
>
> > Thanks anyway for the concern,
>
> No problem. I'm just trying to follow along... to "help"... or to
> "learn"... either is good...
>
> Best,
> Frank

Ah! I think you've mistaken my quoting one message incorrectly.

Actually, I'm using Nielsen's code. Not Wichman's. That is where I
think this misunderstanding came from.

Either code seems to work. Haven't tested Wichman's code. Only
Nielsen's. And oh boy does it work!

I'm writing my own Operating System ~ called Lita's OS ~ to learn ASM.
NASM syntax. Under GNU/Linux. Using VMWare Player as a test bed.

The OS is coming along nicely. Especially now that Nielsen's helped
with the Memory Management side of things in this thread.

Basically, I'm using a Binary Tree to manage memory. My other thread
in this group is about Memory Bitmaps, which is also being used as
part

of the memory manager. In fact, the Memory Manager is my own
conception. Let me explain it to you;

i) All starts with creating a block address from a memory bitmap into
a data area reserved in RAM.
ii) Armed with Block Address, I proceed to install a 'node' into the
Binary Tree to allocate an address.
iii) This address stored in the binary Tree Node is actually the
pointer to a 1MByte RAM area.

Next, comes a similarly difficult part. Using the same code, a memory
bitmap and binary tree, I'll be finding out which addresses are
available to use in the above binary tree!

Sounds complex!? IT IS!!!

Haha.

But, my original thought was to use a memory bitmap, and binary tree,
but the idea 'grew' from there. Excuse the pun.

For a memory management system in the OS.

Basically, when it comes down to managing RAM, this is where the
programmer moves away from standardised code, and can get creative.

The standardised code I'm talking about is boot loaders, setting up
the hard ware into Protected Mode, such as establishing a Segmented
Memory Model, Global/Local/Interrupt Descriptor Tables, and other
little bits and pieces of standard code to get a working OS off the
ground.

Next, after finishing this memory management system, I can actually
start loading programs into ram, and multitasking!

But, I'll also need a protected Mode floppy driver!!! I do have one,
but it isn't commented code. The code is also copyrighted. :(

So, at that point I'll be pulling my hair out looking for information
on the Net on how to figure out this FLP Driver in MYRTLE OS.

Burges MYRTLE OS is the only resource I have. It's an *almost* pure
ASM OS. Which is pretty damn neat saying how old it is!

Sadly, all the code is copyrighted to Burgess, so I cannot use any of
it. That hasn't stopped me re-factoring large portions of it tho!
Haha. For my own OS.

Hey, I'm not ENTIRELY a copy and paste coder!!! *smiles*

I do have some of my own work in the OS. A friend supplied me with the
boot loader. So, I've been hacking away ever since then!

Almost a year in actually, programming the OS.

Sadly, the OS work might get put on hold when I get a real job :(

Right now, I'd like to work as an OS developer, but there isn't much
call for that in Notts. Maybe London?

Who knows, eh?

Thanks any hoo how, Frank, for the chat!

Cat
0
Reply obrzut.alex (64) 3/7/2011 10:36:54 AM

14 Replies
36 Views

(page loaded in 0.312 seconds)


Reply: