|
-
Oct 5th, 2001, 05:55 PM
#1
Thread Starter
PowerPoster
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?
-
Oct 6th, 2001, 12:28 AM
#2
Why: Because they didnt design it that way.
Reason: I have no idea why they designed it that way though.
-
Dec 5th, 2001, 11:08 AM
#3
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.
-
Dec 10th, 2001, 05:45 PM
#4
Dazed Member
Hey CornedBee! Do you know off hand what other processors
use the x86 instruction set? Someone said AMD processors. Is this true?
-
Dec 10th, 2001, 08:19 PM
#5
Hyperactive Member
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.
-
Dec 11th, 2001, 07:26 AM
#6
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.
-
Dec 11th, 2001, 12:10 PM
#7
Dazed Member
Being a kind person I am, let me answer for CornedBee,
Now isn't that nice of you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|