Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

AARCH64 Assembly Language: Performing Arithmetic and Defining Global Data, Study notes of Architecture

An overview of AARCH64 assembly language, including instructions to perform arithmetic and define global data. It covers the use of special-purpose registers, the instruction format, and data transfer operations. The document also discusses the little-endian byte order used in AARCH64 architecture.

Typology: Study notes

2021/2022

Uploaded on 09/12/2022

venice
venice 🇬🇧

4.7

(10)

216 documents

1 / 57

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Assembly Language:
Part 1
Princeton University
Computer Science 217: Introduction to Programming Systems
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39

Partial preview of the text

Download AARCH64 Assembly Language: Performing Arithmetic and Defining Global Data and more Study notes Architecture in PDF only on Docsity!

Assembly Language:

Part 1

Princeton University

Computer Science 217: Introduction to Programming Systems

First half of the semester: “Programming in the large”

Second half: “Under the hood”

Context of this Lecture

Starting Now Later

C Language

Assembly Language

Machine Language

Application Program

Operating System

Hardware

language levels tour

service levels tour

Agenda

Language Levels

Architecture

Assembly Language: Performing Arithmetic

Assembly Language: Load/Store and Defining Global Data

High-Level Languages

Characteristics

  • Portable
    • To varying degrees
  • Complex
    • One statement can do much work – good ratio of functionality to code size
  • Human readable
    • Structured – if(), for(), while(), etc.

count = 0;

while (n>1)

{ count++;

if (n&1)

n = n*3+1;

else

n = n/2;

Assembly Languages

Characteristics

  • Not portable
    • Each assembly lang instruction maps to one machine lang instruction
  • Simple
    • Each instruction does a simple task
  • Human readable (In the same sense that Polish is human readable, if you know Polish.)

ands wzr, w0, # beq else

b endif else:

endif:

asr w0, w0, 1

add w2, w0, w add w0, w0, w add w0, w0, 1

add w0, w0, #

loop: cmp w0, 1 ble endloop

b loop endloop:

mov w1, 0

Why Learn Assembly Language?

Q: Why learn assembly language?

A: Knowing assembly language helps you:

  • Write faster code
    • In assembly language
    • In a high-level language!
  • Write safer code
    • Understanding mechanism of potential security problems helps you avoid them – even in high-level languages
  • Understand what’s happening “under the hood”
    • Someone needs to develop future computer systems
    • Maybe that will be you!
  • Become more comfortable with levels of abstraction
    • Become a better programmer!

Agenda

Language Levels

Architecture

Assembly Language: Performing Arithmetic

Assembly Language: Load/Store and Defining Global Data

John Von Neumann (1903-1957)

In computing

  • Stored program computers
  • Cellular automata
  • Self-replication

Other interests

  • Mathematics
  • Inventor of game theory
  • Nuclear physics (hydrogen bomb)

Princeton connection

  • Princeton Univ & IAS, 1930-

Known for “Von Neumann architecture (1950)”

  • In which programs are just data in the memory
  • Contrast to the now-obsolete “Harvard architecture”

Von Neumann Architecture

RAM

Control Unit

CPU

Registers

Data bus

ALU

RAM (Random Access Memory)

Conceptually: large array of bytes (gigabytes+ in modern machines)

  • Contains data (program variables, structs, arrays)
  • and the program!

Instructions are fetched from RAM

Von Neumann Architecture

RAM

Control Unit

CPU

Registers

Data bus

ALU

Registers

Small amount of storage on the CPU (tens of words in modern machines)

  • Much faster than RAM
  • Top of the “storage hierarchy”: above RAM, disk, etc.

ALU (arithmetic+logic unit) instructions operate on registers

Registers (ARM-64 architecture)

x0 (^) w

63 31 0

x1 (^) w

x29 (FP) (^) w x30 (LR) (^) w

xzr (all zeros) (^) wzr sp (stack pointer)

pc (program counter)

n z c v pstate

General-Purpose Registers

X0 .. X

  • 64-bit registers
  • Scratch space for instructions, parameter passing to/from functions, return address for function calls, etc.
  • Some have special purposes defined in hardware (e.g. X30) or defined by software convention (e.g. X29)
  • Also available as 32-bit versions: W0 .. W

XZR

  • On read: all zeros
  • On write: data thrown away

PC Register

Special-purpose register…

  • Contains PC (Program Counter)
  • Stores the location of the next instruction
    • Address (in TEXT section) of machine-language instructions to be executed next
  • Value changed:
    • Automatically to implement sequential control flow
    • By branch instructions to implement selection, repetition

PC

TEXT section

PSTATE Register

Special-purpose register…

  • Contains condition flags: n (Negative), z (Zero), c (Carry), v (oVerflow)
  • Affected by compare ( cmp ) instruction
    • And many others, if requested
  • Used by conditional branch instructions
    • beq , bne , blo , bhi , ble , bge , …
    • (See Assembly Language: Part 2 lecture)

n z c v pstate