Y86-64 Reference, Lecture notes of Computer Architecture and Organization

CSCI 370: Computer Architecture. Y86-64 Reference. Instruction Format ... fn Codes icode,ifun. rA,rB. valC. valP. valA,srcA. valB,srcB.

Typology: Lecture notes

2022/2023

Uploaded on 05/11/2023

jokerxxx
jokerxxx ๐Ÿ‡บ๐Ÿ‡ธ

4.3

(36)

330 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCI 370: Computer Architecture
Y86-64 Reference
Instruction Format
0 0
1 0
9 0
2 0 rA rB
2fn rA rB
6 0 rA rB
6 1 rA rB
6 2 rA rB
6 3 rA rB
A 0 FrA
B 0 FrA
8 0 Dest
7fn Dest
7 0 Dest
5 0 rA rB D
4 0 rA rB D
3 0 F rB V
halt
nop
rrmovq rA, rB
cmovXX rA, rB
irmovq V, rB
rmmovq rA,D(rB)
mrmovq D(rB),rA
addq rA, rB
subq rA, rB
andq rA, rB
xorq rA, rB
jmp Dest
jXX Dest
call Dest
ret
pushq rA
popq rA
1
2
3
4
5
6
le
l
e
ne
ge
g
fn Codes
icode,ifun
rA,rB
valC
valP
valA,srcA
valB,srcB
valE
cnd
valM
dstE
dstM
PC
Fetch
Decode
Execute
Memory
Writeback
PC Update
Read instruction byte
Read register byte
Read constant word
Compute next PC
Read operand A
Read operand B
Perform ALU operation
Set/Use Condition Code
Memory Read/Write
Write back ALU result
Write back Mem result
Update PC
register(s) descriptionstage
HCL Y86-64 Hardware Registers
Registers
%rdi
%rsi
%rdx
%rcx
%r8
%r9
%rax
%rbx
%r10
%r11
%r12
%r13
%r14
%rsp
%rbp
F
5
4
E
D
C
3
B
A
0
9
8
1
2
6
7arg1
arg2
arg3
arg4
arg5
arg6
return
stack ptr
base ptr
no reg
caller-savedcallee-saved
ID Enc Usage
general
general
general
general
general
general
.align 8
Array:
.quad 0x0000000000000001
.quad 0x0000000000000002
.quad 0x0000000000000003
.quad 0x0000000000000004
Y86-64 Data Example
AOK
HLT
ADR
INS
1
2
3
4
Normal
Halt Encountered
Bad Address
Invalid Instruction
Status Conditions
/* find number of elements in null-terminated list */
long len(long* a) {
long len;
for (len = 0; a[len]; ++len)
;
return len;
}
len:
irmovq $1, %r8 # Constant 1
irmovq $8, %r9 # Constant 8
irmovq $0, %rax # len = 0
mrmovq (%rdi), %rdx # val = *a
and %rdx, %rdx # Test val
je Done # If zero, goto Done
Loop:
addq %r8, %rax # len++
addq %r9, %rdi # a++
mrmovq (%rdi), %rdx # val = *a
andq %rdx, %rdx # Test val
jne Loop # If !0, goto Loop
Done:
ret
Assembly Translation Example

Partial preview of the text

Download Y86-64 Reference and more Lecture notes Computer Architecture and Organization in PDF only on Docsity!

CSCI 370: Computer Architecture Y86-64 Reference

Instruction Format 01

(^22) fn 0 rArA rBrB 666 021 rArArA rBrBrB 6 3 rA rB A B^8 000 rArADestFF

77 fn^0 DestDest

543 000 rArAF^ rBrBrB DDV

halt nop rrmovq rA , rB

cmovXX irmovq rmmovq rA V rA , ,, rB D rB ( rB )

mrmovq addq subq rArA ,, D rBrB ( rB ), rA

andq xorq jmp Dest rArA ,, rBrB

jXX call ret Dest Dest

pushq popq rA rA

fn Codes 21 le l 34 e ne 56 ge g

icode,ifun rA,rB valC valP valA,srcA valB,srcB valE cnd valM dstE dstM PC

Decode^ Fetch Writeback^ Execute^ Memory PC Update

Read instruction byte Read register byte Read constant word Compute next PC Read operand A Read operand B Perform ALU operation Set/Use Condition Code Memory Read/Write Write back ALU result Write back Mem result Update PC

HCL Y86-64 Hardware Registers stage register(s) description

Registers %rdi %rsi

%rdx %rcx %r8 %r %rax %rbx %r10 %r %r12 %r13 %r14 %rsp %rbp F 54 E^ D

C^3 B^ A

267 arg1^ arg2 arg3 arg4 arg5 arg return stack base no reg (^) ptrptr

caller-saved callee-saved

ID Enc Usage general general general general general general

Array:^ Y86-64 Data Example^ .align .quad .quad .quad .quad 0x00000000000000010x00000000000000020x00000000000000030x0000000000000004^8

AOK HLT ADR

INS

Normal Halt Encountered Bad Address

Invalid Instruction

Status Conditions

/* long long for find ;len( (len len;number long = *0; ofa) a[len]; elements{ ++len) in null-terminated list */

} len:^ return irmovq^ len; $1 , %r8 # Constant 1

irmovq irmovq mrmovq and je Done %rdx, $8$0 (%rdi), ,, %rdx%r9%rax %rdx ##### ConstantlenvalTestIf zero,== val 0 *a 8 goto Done

Loop: addq addq mrmovq andq %r8,%r9,%rdx, (%rdi), %rax%rdi %rdx %rdx #### len++a++valTest = val*a

Done:^ jne ret^ Loop^ #^ If^ !0,^ goto^ Loop

Assembly Translation Example