Results 1 to 7 of 7

Thread: Question about CPU registers

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Question about CPU registers

    I saw an example of writting a "Hello World" program but I am jus not understanding one part:

    Code:
    mov ax, seg message
    mov ds, ax
    Why can't I just move segment of "message" in "DS" directly?
    Baaaaaaaaah

  2. #2
    ChimpFace9000
    Guest
    Why: Because they didnt design it that way.

    Reason: I have no idea why they designed it that way though.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    While reding on the AOA page I found this one out:
    It lies in the way the instructions are encoded. Here is the way AOA encodes instructions for their hypothetical x86 processors (and I figure it's not too far away from the real way 80x86 cpus use).
    The main part is always 1 byte, and used like this:
    aaabbccc

    aaa is the main instruction code. It defines wether the instruction is a simple 2 argument instruction, or something else.
    simple 2 arguments are mov, add, sub etc.
    If it is, bb specifies one operand, ccc the other
    There are two mov instructions:
    mov register, other
    mov other, register

    register is always encoded into bb, while other is in ccc
    bb is two bits, therefore can have only 4 values: 00, 01, 11, 10
    Those say which register to move to/from. These are a, b, c and d, with whatever size extension is used. Therefore, one operand must be one of the main registers.

    Now, this is of course much more complicated on a real cpu, but I think it is the reason why you must take this route: to save bits in the instructions.
    mov ds, seg message is therefore not possible.

    BTW, two mov instructions needing each other aren't good according to AOA. Use this syntax:
    mov ax, seg String
    mov dx, offset String
    mov ds, ax

    This maybe is better.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Hey CornedBee! Do you know off hand what other processors
    use the x86 instruction set? Someone said AMD processors. Is this true?

  5. #5
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Being a kind person I am, let me answer for CornedBee,

    Yes, bcos AMD x86 CPUs are Intel x86 compatible. or else how it runs Windows.
    I'm a VB6 beginner.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    All CPUs you can put into a "normal" PC:
    Intel 80x86, Pentium 1, 2, 3, 4
    AMD K5, K6, Athlon
    Cyrix cpus
    etc...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width