printing an array of Double Word integers in x86 assembly

Posted on 2006-04-09
Last Modified: 2012-05-05
I set up an array of double words in memory but I do not know how to get them out of memory and print them.  Can any one give me an idea of how to do this or direct me to some good sites to explain working with bigger variables than the register itself.  I know I could probalby use extended registers, but am not very familiar with them.
Question by:feldmani
    LVL 11

    Expert Comment

    If you want to work with standard registers then you can handle a double word in two parts. You have to know that the four bytes of a double word a ordered in the memory from less meaningfull to the most meaningful byte. Or speaking in words - the first word in the memory of a double word is the less meaningful word of both.
    So if you have a double word at address A in the memory then you have the less meaningful word at address A and the most meaningful word at address A+2. Knowing that and knowing how to work with standard registers you're supposed to do the trick.

    btw The extended registers (at least general purpose ones) work like the standard ones. The only difference is that they are bigger.

    Hope that helps!
    LVL 1

    Accepted Solution

    If it's a string you want to print out, you could use int 21h with ah = 09. Then you're printing out directly from memory ds:dx untill you hit a $-sign (ascii-code 24h). Unless it's a string you're planing on writing out, I don't know how you would do it.

    But anyway how you do it, I do belive you should know how the double words are stored in memory. If you have the double word 1234abcdh, it will be stored in memory like this:

    adress   value
    1000       cd
    1001       ab
    1002       34
    1003       12

    So the bytes are reversed. If you however have an array of double words, only the specific double words are reveresd, not the array. So if you had three doublewords: 11223344h, AABBCCDDh and 1234ABCDh in an array, they would be stored like this:

    adress value
    1000    44
    1001    33
    1002    22
    1003    11
    1004    DD
    1005    CC
    1006    BB
    1007    AA
    1008    CD
    1009    AB
    100A    34
    100B    12

    If you know a quick way of printing things out of registers, you could probably use the knowledge of how things are stored in memory, and the 'mov ax, [variable+bx]' command to read from memory, and write them out of the ax-register.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    For Sennheiser, comfort, quality and security are high priority areas. This paper addresses the security of Bluetooth technology and the supplementary security that Sennheiser’s Contact Center and Office (CC&O) headsets provide.  
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now