






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Computer Architecture and Organization
programs.
lik
ll hi h l
l l
Th
like are all high level languages. They aremachine independent. The machinedependent compilers translate the highlevel language to machine language.
Assembler language is a low levellanguage. Each different computerarchitecture has its own assemblerlanguage.
l^
t l
l^
h
t
lowest level access a programmer has tothe hardware.
implemented with microcode.
that turn switches on and off to implementeach machine language instruction.
l^
h
i t
hi
language, such as C or C++, into machinelanguage.
produces many machine instructions.
to produce optimal code.
// C++ or Java method int isflush( void ) {int i, ok;
// Portion of same method in assembler
mov
eax,
PTR hand+
add
eax, 117
mov
PTR ok[ebp], eax
ok = FLUSHBASE + hand[4].face - 5;for (i = 0; i < 4; i++)
if (hand[i].suit != hand[i+1].suit)
ok = 0;
return ok;}
[^
p],
mov
PTR i[ebp], 0
jmp
SHORT label
label3:
mov
eax,
PTR i[ebp]
add
eax, 1
mov
PTR i[ebp], eax
label4:
cmp
PTR i[ebp], 4
jge
SHORT label
mov
eax,
PTR i[ebp]
mov
ecx,
PTR i[ebp] d^
PTR h
d[^
*8 4]
mov
edx, PTR hand[eax*8+4]
cmp
edx,
PTR hand[ecx*8+12]
je^
SHORT label
mov
PTR ok[ebp], 0
label1:
jmp
SHORT label
label2:
mov
eax, PTR ok[ebp]
d
b
il d
source code can be compiled on anyarchitecture. When executed, it will givethe same results.
language. Assembler for one type oflanguage. Assembler for one type ofmachine will not run on another machine.
writing machine language.
t^
l t
bl
i t
hi
translate your assembler source into machinelanguage.
allow you to embed assembler into a C++program.program.
Register to register instructions
(rare)
appears
to be done in the register.
use an index register to specify the address
dog = cat;
-^
move the value from memory location cat into aregisterregister
-^
move the value from the register to memorylocation dog
dog = cat + cow;
-^
move the value from memory location cat into a
y
register
-^
Add the value from memory location cow to theregister
-^
Move the value from register to memory dog
General use, division only in EAX
General use
General use
General use
Base pointer
Source pointer
Destination pointer
Stack pointer
bit
i t
bit registers.
bit registers, they called the longerregisters EAX EBX etcregisters EAX, EBX, etc.
the 16 bit register, now bytes 3 & 4.
purpose registersp
p
g
have the same functionality. In othermachines the registers each have a specificmachines the registers each have a specificpurpose.
although most can do several operations.– EAX Accumulator for arithmetic
EBX P i t
t^
d t
Load
instruction copies a value from
i t
i t
d
memory into a register. (Reads memory)
Store
instruction copies a value from a
register into memory. (Writes memory)
it
th
i^
mov
f
b th
it uses the same mnemonic
mov
for both
load and store.
f b t of bytes.
memory.
the address of the data in memorythe address of the data in memory.
t^
t^
b
d
i^
th
OR, XOR, etc.) appear to be done in theregisters.
register and the other in memory oranother register.another register.
add
eax,
dog
mnemonic
operation
Add
Add
Subtract
Unsigned Multiply
Signed Multiply
Unsigned Divide
Unsigned Divide
Signed Divide
Logical AND
Logical OR
int dog=3, cat=4, bird=5;_asm {
// bird = dog + cat;
mov
eax,dog
add
eax,cat
mov
bird,eax
int dog=3,
cat=4,
bird=5,
cow;
_asm {
// cow = dog + cat - bird;
mov
eax,dog
add
eax,cat
sub
eax,bird
mov
cow,eax
asm1-
int
dog=4, cat=3,
bird=5;_asm
{
_
mov
eax,dog
sub
eax,cat
mov
bird,eax
}
inc
and
dec
instructions are one of
th
f^
th t
l^
ti
the few that can run on memory locationswithout using the registers.
in a register for memory location
inc
eax
inc
eax
dec
memoryAddr
i t
t^
t^
64 bit
l
registers to store a 64 bit value.
most significant bits in the EDX registerand the least significant bits in EAX.
a register or memory location.
right or left by the specified number of bits.
right or left, but not the sign bit. The SARcopies the sign bit into the emptied bitscopies the sign bit into the emptied bits.
cl
reg sar
eax,
shl eax,
cl
int dog=3;_asm
mov
eax,dog
eax
sal
eax,
eax
sar
eax,
eax