Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6589591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:11:38+00:00 2026-05-25T17:11:38+00:00

I am confused as to how memory is stored when declaring variables in assembly

  • 0

I am confused as to how memory is stored when declaring variables in assembly language. I have this block of sample code:

val1  db  1,2
val2  dw  1,2
val3  db  '12'

From my study guide, it says that the total number of bytes required in memory to store the data declared by these three data definitions is 8 bytes (in decimal). How do I go about calculating this?

It also says that the offset into the data segment of val3 is 6 bytes and the hex byte at offset 5 is 00. I’m lost as to how to calculate these bytes and offsets.

Also, reading val1 into memory will produce 0102 but reading val3 into memory produces 3132. Are apostrophes represented by the 3 or where does it come from? How would val2 be read into memory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:11:39+00:00Added an answer on May 25, 2026 at 5:11 pm

    You have two bytes, 0x01 and 0x02. That’s two bytes so far.

    Then you have two words, 0x0001 and 0x0002. That’s another four bytes, making six to date.

    The you have two more bytes making up the characters of the string ’12’, which are 0x31 and 0x32 in ASCII (a). That’s another two bytes bringing the grand total to eight.

    In little-endian format (which is what you’re looking at here based on the memory values your question states), they’re stored as:

    offset  value
    ------  -----
         0   0x01
         1   0x02
         2   0x01
         3   0x00
         4   0x02
         5   0x00
         6   0x31
         7   0x32
    

    (a) The character set you’re using in this case is the ASCII one (you can follow that link for a table describing all the characters in that set).

    The byte values 0x30 thru 0x39 are the digits 0 thru 9, just as the bytes 0x41 thru 0x5A represent the upper-case alpha characters. The pseudo-op:

    db '12'
    

    is saying to insert the bytes for the characters '1' and '2'.

    Similarly:

    db 'Pax is a really cool guy',0
    

    would give you the hex-dump representation:

    addr  +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F  +0123456789ABCDEF
    0000  50 61 78 20 69 73 20 61 20 72 65 61 6C 6C 79 20   Pax is a really 
    0010  63 6F 6F 6C 20 67 75 79 00                        cool guy.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am always confused about static variables, and the way memory allocation happens for
Totally confused by this one... We have a WAMPServer installation set up, running a
There are a few concepts about iPhone memory management that have got me confused,
I am a bit confused with how variables are stored in the data segment.
I am confused by the memory management in this scenario. In my app user
Let's say a create an (executable) assembly in memory by compiling a code string.
Update: I probably confused memory usage issues with the UI sharing same thread as
I'm working on a memory pool implementation and I'm a little confused about pointers
Bit confused here, I have an on-demand instance but do I get charged even
Totally confused here. I have a PARENT UIViewController that needs to pass an NSMutableArray

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.