05-memory-post

05-memory-post - The memory model Readings: Readings from...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The memory model Readings: Readings from CP, chapters 1-10, as detailed in the document available on the Web site. The memory model and C Tail recursion and loops Stacks for function calls in C The memory model and Scheme This material is not covered in the textbook. CS 136 Fall 2009 05: The memory model 1 What is going on? We can understand intuitively how the recursive GCD implementation in C we saw in the previous lecture module works. But why does it work? We could try to use the substitution model to explain it. But our C programs are full of statements that do not produce values. The semantics of C are best explained by using the memory model. Most introductions to C (including the one in CP:AMA) arent very explicit about the semantics, and delay the discussion of functions until later than we have. CS 136 Fall 2009 05: The memory model 2 A brief look at computer architecture An interpreter like DrScheme or mzscheme runs a program written in a high-level language (HLL) like Scheme. Like any application, the interpreter consists of a sequence of primitive instructions in machine language . Machine language is the low-level language that the particular computer is designed to run. The memory of the computer stores the interpreter, the HLL program which it treats as data, and the data that the user has written the HLL program to transform. CS 136 Fall 2009 05: The memory model 3 Interpreter Memory User's Scheme program User's data Working storage Processor The primitive instructions in the interpreter program specify how memory is to be altered by the processor as the computation proceeds. We will focus here on how data is represented in memory. The processor is discussed in lecture module 05. CS 136 Fall 2009 05: The memory model 4 Memory A convenient model of memory is as a set of numbered words . Each word can hold a fixed amount of information, typically 32 binary digits or bits . 10010010 11101000 00011010 11110000 00001101 00000001 11011111 01001010 11110100 10101110 00010100 00000000 ... 4 8 12 ... 256 260 264 ... address contents Word addresses are divisible by 4 because most 32-bit computer architectures allow 8-bit chunks, called bytes , to be addressed. 10010010 11101000 00011010 11110000 4 address 5 6 7 CS 136 Fall 2009 05: The memory model 5 The 32 bits stored in a memory word could be interpreted as: a single machine instruction; an integer which is part of some larger collection of data; 4 characters (each one requiring 8 bits); the address of another word or byte of memory; something else, depending on context. CS 136 Fall 2009 05: The memory model 6 When the 32 bits stored in a memory word represent the address of another word or byte, we interpret the bits as a natural number represented in binary....
View Full Document

Page1 / 104

05-memory-post - The memory model Readings: Readings from...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online