



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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An introduction to computer organization, specifically the von Neumann architecture and machine language. It covers the concept of a fetch-decode-execute cycle, the need for interpreters and compilers, and the use of the MARS simulator for exploring machine-level instructions. Examples of simple programs and more complex algorithms are included.
What you will learn
Typology: Slides
1 / 7
This page cannot be seen from the preview
Don't miss anything!
Carnegie Mellon University - CORTINA^ 15110 Principles of Computing, 1
Carnegie Mellon University - CORTINA^ 15110 Principles of Computing, 2
Memory Array Redcode Simulator
Carnegie Mellon University - CORTINA^ 15110 Principles of Computing, 4
Carnegie Mellon University - CORTINA^ 15110 Principles of Computing, 7
include MARSLab => Object m = make_test_machine(“simple.txt”) => #<MiniMARS mem = [DAT #0 #4,...] pc = [*2]> m.dump 0000: DAT #0 # 0001: DAT #0 # 0002: ADD -2 - 0003: DAT #0 # => nil
add the data 2 words back to the data 1 word back
Program starts at address 2 in “memory”
x DAT # y DAT # simple ADD x, y DAT #
“memory”addresses
m.step => ADD -2 - m.dump 0000: DAT #0 # 0001: DAT #0 # 0002: ADD -2 - 0003: DAT #0 # => nil m.status Run: continue PC: [ *3 ]
Carnegie Mellon University - CORTINA^ 15110 Principles of Computing, 8
x DAT # y DAT # simple ADD x, y DAT #
y has been updated
PC = Program Counter The PC indicates where the next instruction is located (e.g. address 3).
m.step => DAT #0 # m.dump 0000: DAT #0 # 0001: DAT #0 # 0002: ADD -2 - 0003: DAT #0 # => nil m.status Run: halt
Carnegie Mellon University - CORTINA^ 15110 Principles of Computing, 9
x DAT # y DAT # simple ADD x, y DAT #
nothing has changed
The MARS simulator executed an instruction with opcode 0 (halt) and has halted.
x DAT # y DAT # acc DAT # mult ADD x, acc ; add x to acc SUB #1, y ; subtract 1 from y JMN mult, y ; jump to label mult ; if y is not zero end mult Carnegie Mellon University - CORTINA^ 15110 Principles of Computing, 10
start MOV fahr, ftmp SUB #32, ftmp mult ADD ftmp, acc SUB #1, count JMN mult, count div SUB #9, acc SLT #0, acc DAT #0 ; halt ADD #1, cels JMP div end start Carnegie Mellon University - CORTINA^ 15110 Principles of Computing, 13
set ftmp = fahr - 32
add ftmp to acc 5 times (count starts off at 5) divide acc by 9: subtract 9 from acc and add 1 to cels to see how many times 9 divides into acc
skip next instruction if 0 is less than acc always jump to label div