CS241 Lecture Notes - Lecture 3: Binary File, Text Editor, Standard Streams

39 views4 pages
Lecture 3
Ex. Add 42 to 52, store the result in $3.
Load Immediate and skip (lis)
lis $d
000000 00000 00000 ddddd 00000 010100
$d <- MEM[PC]; PC = PC+4
lis $5 // 0x00002814
.word 42 // 0x0000002A
lis $7 // 0x00003814
.word 52 // 0x00000034
add $3, $5, $7 // 0x00A71820
jr $31 // 0x03E00008
Tools
cs241.wordasm - just a script that runs an actual program.
Where are you going to type 1's and 0's (write in binary)? Can't do it in a text editor because 1's
and 0's are stored as their ASCII value, not binary representation.
With wordasm, the input are lines in hexadecimal (32 bits) with .word syntax and its output is in
binary.
When the shell see's the binary, it will convert it into text and that's why it displays the text.
If you want to see the bits, use xxd.
If you want to see the binary, use xxd -b (this is what wordasm actually outputted).
See Assignment 1 for usage...
Simulators
1st simulator: called mips.twoints (compiled binary file)
- mips.twoints <mipsFile>
- will always expect 2 inputs (for 2 registers)
- use the simulator to execute the instructions in the example above
A1 requires writing machine language in hexadecimal.
We're going to abstract over machine language in A2 because writing machine language is very
tedious and error prone.
This will be assembly language: text based representation of machine language.
Now however, wordasm won't work with text (works with hex) so how to convert from text to
binary?
Assembly programs have to be assembled into binary and for that we use cs241.binasm.
cs241.binasm
- this tool is called a MIPS Assembler
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Add 42 to 52, store the result in .

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents