![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
|
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 |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Oct 2005
Posts: 6
Rep Power: 0
![]() |
I am not sure what writeint really does! What arguments does it take?
If all arguments are correct, then it would be the endianness ![]() |
|
|
|
|
|
#4 |
|
Professional Programmer
|
Wrteint takes AX as an argument, I forgot to set it to 0 before I moved the variable into AX.
Thanks for the input ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|