





















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!






















**car *** c = malloc(sizeof( car )); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100); c.setGals(17); float mpg = c.getMPG(); get_mpg: pushq %rbp movq %rsp, %rbp ... popq %rbp ret C: Java: Assembly language: Machine code: 0111010000011000 100011010000010000000010 1000100111000010 110000011111101000011111 Computer system: OS: Memory & data Integers & floats x86 assembly Procedures & stacks Executables Arrays & structs Memory & caches Processes Virtual memory Memory allocation Java vs. C
(empty slot)
controller Storage connections Memory
CPU Memory Disks (^) Net USB^ Etc. Bus
0.0V 0.5V 2.8V 3.3V 0 1 0
length
Least Significant Bit (LSB) Most Significant Bit (MSB)
take 469 registers i-cache
take 469 registers i-cache
How does a program find its data in memory?
instructions were exactly the size of a word
𝑤 addresses
𝟔𝟒 addresses 2 64 bytes 1.8 x 10 19 bytes = 18 billion billion bytes = 18 EB (exabytes)
❖ Addresses still specify locations of bytes in memory ▪ Addresses of successive words differ by word size (in bytes): e.g. 4 (32-bit) or 8 (64-bit) ▪ Address of word 0, 1, … 10? ❖ Address of word = address of first byte in word ▪ The address of any chunk of memory is given by the address of the first byte ▪ Alignment 32 - bit Words Bytes 64 - bit Words Addr = ?? Addr = ?? Addr = ?? Addr = ?? Addr = ?? Addr = ?? 0000 0004 0008 0012 0000 0008 0x 0x 0x 0x 0x 0x 0x 0x 0x 0x 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F Addr. (hex)
will fit on one row 0x 0x 0x 0x 0x 0x 0x 0x 0x 0x 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x one word Address
= 0x 00 ... 00 01 F
0x 0x 0x 0x 0x 0x 0x 0x 0x 0x Address 00 00 00 00 00 00 01 F 00 00 00 00 00 00 00 08 64 - bit example (pointers are 64-bits wide) big-endian
on how you use it 0x 0x 0x 0x 0x 0x 0x 0x 0x 0x Address 00 00 00 00 00 00 01 F 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 38 64 - bit example (pointers are 64-bits wide) big-endian