


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of the powerpc architecture and assembly language, focusing on loads and stores, arithmetic and logical operations, shifts and rotates, and branches. It includes examples and references to the powerpc manual on docsity.com.
Typology: Slides
1 / 26
This page cannot be seen from the preview
Don't miss anything!



















An Instruction Set Architecture (ISA) defines an interface between software and hardware:
instructions registers memory
addi r5, r0, 0 loop: lbz r4, 0(r3) add r5, r4, r addi r3, r3, 1 b loop
Add an (infinite) set of bytes beginning at the byte-address stored in register r3. Result in r5, which we initialize to zero.
add r5, r4, r
addi r3, r3, 1
b loop
lhz r4, 0(r3) : halfword in (r3)+0 is loaded into low 16 bits of r4; remaining bits in r4 are cleared.
lha r4, 0(r3) : halfword in (r3)+0 is loaded into low 16 bits of r4; remaining bits in r4 are filled with copy of MSB in loaded halfword. (aka ―sign-extended‖)
The algebraic option is
lwzu r4, 4(r3)
effective address (r3) + 4 r4 MEM (EA, 4) r3 effective address
In English: Load from the effective address, as usual AND Update the base register to hold the effective address
Where would you expect to see this?
struct{ int a; /* 0x1112_1314 word / double b; / 0x2122_2324_2526_2728 double word / char c; /* 0x3132_3334 word / char d[7]; / ‗L‘, …, ‗R‘ array of bytes / short e; / 0x5152 half word / int f; / 0x6162_6364 word */ } S;
11 12 13 14 21 22 23 24 25 26 27 28 31 32 33 34 L M N O P Q R 51 52
00 01 02 03 04 05 06 07
61 62 63 64 20 21 22 23 24 25 26 27
address (hex) contents contents contents contents contents address (hex)
Two ways for loading a full 32-bit value into a register:
lis r3, 5 lis r3, 5 ori r3, r3, 99 addi r3, r3, 99
When are these two approaches not equivalent?
list: .byte 0x20,4,-12,
main: lis r3, list@h ori r3, r3, list@l addi r5, r0, 0 addi r3, r3, - addi r6, r0, 0 loop: lbzu r4, 1(r3) add r5, r4, r addi r6, r6, 1 cmpwi r3, 4 beq done b loop
done: b done
A more complete version of the example the earlier slide that initializes the address and stops at the end of the list
There is an error in this code… Can you find it?
cmpwi r3, 4
beq done
Assembler suffixes: