Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Oct 9th, 2005, 12:33 PM   #1
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 417
Rep Power: 4 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
Unhappy Displaying contents of an array

I am trying to print out contents of an array, I can assemble and link my code, but the output is wrong.

Here is my code

.model small
.stack 100h

.data
	array8 db 10h,20h,30h,40h
.code
	extern Writeint:proc, Crlf:proc
main proc
	mov ax, @data
	mov ds, ax
	
	mov bx, offset array8
	mov ax, [bx]
	mov bx,16
	call Writeint
	
	mov ax,4c00h
	int 21h
		
main endp
end main

When I run the executable I get 2010. I know this has something to do with byte flipping or somethign like that. Does anyone know how I can fix this?

Thanks for any input
Wizard1988 is offline   Reply With Quote
Old Oct 9th, 2005, 3:21 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
It has to do with endianness. You can Google on that. You can reverse the bytes (there's even an instruction to do that). You can treat them as bytes instead of 16-bit entities. Pay your money, take your choice. Prolly help to read your documentation, too. This has been treated on the forum before, but you'd have to search with some appropriate term ("swap bytes" might be one).
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 12th, 2005, 1:47 AM   #3
maro25
Newbie
 
Join Date: Oct 2005
Posts: 6
Rep Power: 0 maro25 is on a distinguished road
I am not sure what writeint really does! What arguments does it take?
If all arguments are correct, then it would be the endianness
__________________
Password Spyer 2k: Password Recovery Software
My NEW SEO forum
maro25 is offline   Reply With Quote
Old Oct 12th, 2005, 9:15 PM   #4
Wizard1988
Professional Programmer
 
Wizard1988's Avatar
 
Join Date: Oct 2005
Location: Chitown
Posts: 417
Rep Power: 4 Wizard1988 is on a distinguished road
Send a message via AIM to Wizard1988
Wrteint takes AX as an argument, I forgot to set it to 0 before I moved the variable into AX.

Thanks for the input
Wizard1988 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 2:19 PM.

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