Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 18th, 2006, 12:11 PM   #11
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
Quote:
Originally Posted by DaWei
Endianness.
one does not compute compute DaWei, went to google and found this:
Quote:
"Endianness" generally refers to sequencing methods used in a one-dimensional system (such as writing or computer memory). The two main types of endianness are known as big-endian and little-endian. Systems which exhibit aspects of both conventions are often described as middle-endian. When specifically talking about bytes in computing, endianness is also referred to as byte order.
^ from http://en.wikipedia.org/wiki/Endianness.

I am very confuse do you mind shedding some of your knowledge onto us(can u please explain)
kruptof is offline   Reply With Quote
Old May 18th, 2006, 12:47 PM   #12
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>but why did u put 2 in the di regester
Here's how the division algorithm works:
123 / 10
AX = 12
DX = 3

12 / 10
AX = 1
DX = 2

1 / 10
AX = 0
DX = 1
Notice how DX, the value that is used to build the string, gives the digits in reverse order. By starting di at 2 and decrementing it, the algorithm builds the string in reverse order, thus negating the reverse order of the digits:
      --0---1---2---3--
save: |   |   |   |'$'|
      -----------------

DX = '3'
DI = 2

      --0---1---2---3--
save: |   |   |'3'|'$'|
      -----------------

DX = '2'
DI = 1

      --0---1---2---3--
save: |   |'2'|'3'|'$'|
      -----------------

DX = '1'
DI = 0

      --0---1---2---3--
save: |'1'|'2'|'3'|'$'|
      -----------------
You can see what would happen if you just start at the beginning and go to the end by changing the corresponding portion of the code to this:
	mov	di,0

    convert:
	mov	dx,0
	div	bx
	add	dx,'0'
	mov	[save+di],dl
	inc	di
	test	ax,ax
	jnz	convert
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old May 18th, 2006, 12:53 PM   #13
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
so what are you doing or testing when you do

test ax,ax
are you comparing ax to ax
kruptof is offline   Reply With Quote
Old May 18th, 2006, 1:04 PM   #14
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
"test ax,ax" does the same thing as "cmp ax,0", but in a different way. In case you're curious, because at this point it doesn't really matter, cmp performs a subtraction and test performs a bitwise AND.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old May 18th, 2006, 1:07 PM   #15
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
okay thanks but i still don't understand how you got the number stored backwards in the string save.
kruptof is offline   Reply With Quote
Old May 18th, 2006, 1:15 PM   #16
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
The division trick takes the least significant digit off each time, so the digits you get will be in 3,2,1 order rather than 1,2,3 order.

If you save each digit at the index specified by DI in 0,1,2 order, the string will be "321$".

If you save each digit at the index specified by DI in 2,1,0 order, the string will be "123$".
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old May 18th, 2006, 1:18 PM   #17
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
you taught me something new on every post just like to say thanks.........but when you do this

save db 4 dup '$' are you setting up a variable that can only store 4 characters?
kruptof is offline   Reply With Quote
Old May 18th, 2006, 2:40 PM   #18
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>save db 4 dup '$' are you setting up a variable that can only store 4 characters?
Kind of. It sets aside four bytes, initializes them to the $ character, and creates a label called "save" that refers to the memory address of the first byte. That's technically a variable in assembly, but it's important to know what's going on. You could also do this to the same effect:
save:
	db '$'
	db '$'
	db '$'
	db '$'
Or this:
save:
	db '$$$$'
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old May 18th, 2006, 4:45 PM   #19
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
okay narue another question why did you add a 0 to whats inside dx

add dx,'0'
kruptof is offline   Reply With Quote
Old May 18th, 2006, 4:59 PM   #20
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 5 lostcauz is on a distinguished road
She explained this in comment #2.
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC