Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
D. Thiebaut, Computer Science, Smith College
Outline• Review + Lab 1: uP simulator Lab
• Lab2: Emacs (do on your own)
• Lab3: Assembly
• Assembly + Linking Process
• Object files
• DB directive: Everything is a byte!
• HexDump: we need to learn hexadecimal!
• Ascii Table
D. Thiebaut, Computer Science, Smith College
Review
D. Thiebaut, Computer Science, Smith College
Review
Processor +
ACPC
3
Add 1
HaltStore [9]
Load [9]
11 10 9 8 7 6 5 4 3 2 1 0
D. Thiebaut, Computer Science, Smith College
Similarity w/ Hand Calculator
D. Thiebaut, Computer Science, Smith College
Computer Simulator Review
http://www.science.smith.edu/dftwiki/media/simulator/
http://bit.ly/2jTJswI
D. Thiebaut, Computer Science, Smith College
Mini Lab
• Link to the simulator
• Link to the documentation
• Link to the simulator lab
D. Thiebaut, Computer Science, Smith College
Outline• Review + Lab 1: uP simulator Lab
• Lab2: Emacs (do on your own)
• Lab3: Assembly
• Assembly + Linking Process
• Object files
• DB directive: Everything is a byte!
• HexDump: we need to learn hexadecimal!
• Ascii Table
D. Thiebaut, Computer Science, Smith College
Emacs
D. Thiebaut, Computer Science, Smith College
Demo: Emacs (Do lab on your own)
• ssh to aurora ssh -Y [email protected]
• Emacs demo
• Basic commands
emacs -nw helloWorld.asm
^X^C^G^D^K^Y
cursor keys
D. Thiebaut, Computer Science, Smith College
Shell
D. Thiebaut, Computer Science, Smith College
Shell
D. Thiebaut, Computer Science, Smith College
3 Useful Linux Commands
• ls (ell ess) list all files in a folder/directory
• cp copy file
• cd change directory
D. Thiebaut, Computer Science, Smith College
Linux Commandscommand -switches file-name(s)
D. Thiebaut, Computer Science, Smith College
Linux Commands
ls -1 ls *.asm ls *.o ls hello* ls -l
man ls
command -switches file-name(s)
D. Thiebaut, Computer Science, Smith College
We stopped here last time…
D. Thiebaut, Computer Science, Smith College
GoogleYouTubePython
D. Thiebaut, Computer Science, Smith College
Solution ProgramsFor Simulator Lab
; Solution for Problem 1 LOAD 22 ; load 22 into the accumulator STORE [10] ; STORE [11] ; STORE [12] ; HALT ;
; Solution for Problem 2 LOAD 9 ; load 22 into the accumulator STORE [20] ; LOAD 19 ; STORE [21] ; LOAD 13 ; STORE [22] ; HALT ;
; Solution for Problem 30000: LOAD [10] ;0002: STORE [11] ;0004: STORE [12] ;0006: STORE [13] ;0008: HALT ;0010: 55 ;
Typical
Midterm
Question!
D. Thiebaut, Computer Science, Smith College
Solution ProgramsFor Simulator Lab
; Problem 4; Part 1LOAD [8] ;ADD 2 ;STORE [8] ;HALT ;8: 55 ;
; Part 20000: LOAD [20] ;0002: ADD 2 ;0004: STORE [20] ;0006: LOAD [21] ;0008: ADD 2 ;0010: STORE [21] ;0012: HALT ;0020: 55 ;0021: 13 ;
; Solution for Problem 50000: LOAD [10] ;0002: ADD 5 ;0004: STORE [10] ;0006: JUMP 0 ;0010: 55 ;
; Solution for Challenge
0000: LOAD [10] ;0002: ADD [10] ;0004: ADD [11] ;0006: STORE [12] ;0008: HALT ;0009: HALT ;0010: 3 ;0011: 5 ;0012: 0 ;
D. Thiebaut, Computer Science, Smith College
Outline• Review + Lab 1: uP simulator Lab
• Lab2: Emacs (do on your own)
• Lab3: Assembly
• Assembly + Linking Process
• Object files
• DB directive: Everything is a byte!
• HexDump: we need to learn hexadecimal!
• Ascii Table
D. Thiebaut, Computer Science, Smith College
LAB TIME!
• Demo
• Do the lab in pair
• Printing strings and understanding db
http://www.science.smith.edu/dftwiki/index.php/CSC231_Hello_World_Lab_2018
D. Thiebaut, Computer Science, Smith College
Skeleton
D. Thiebaut, Computer Science, Smith College
Hello World!
D. Thiebaut, Computer Science, Smith College
Assembly+Linking
xxx.asm xxx.o xxx
nasm ld
D. Thiebaut, Computer Science, Smith College
Assembly+Linking
xxx.asm yyy.asm
xxx.o yyy.o
xxx
nasm ld
D. Thiebaut, Computer Science, Smith College
DB: byte storage
D. Thiebaut, Computer Science, Smith College
Data Section vs Memorymessage db "hello",10
D. Thiebaut, Computer Science, Smith College
Data Section vs Memorymessage db "hello" db 10
D. Thiebaut, Computer Science, Smith College
Data Section vs Memory
message db "h","e","l","l","o" db 10
D. Thiebaut, Computer Science, Smith College
Data Section vs Memory
message db "hel" db "lo" db 10
D. Thiebaut, Computer Science, Smith College
Data Section vs Memorymessage db 104,"el" db "lo" db 10
D. Thiebaut, Computer Science, Smith College
Exercise section .data
msg1 db "lo " db "hel"
msg3 db "world!", 10msgLen equ$-msg3
_start:mov eax, 4 mov ebx, 1 mov ecx, msg1+3 mov edx, 3int 0x80
mov eax, 4 mov ebx, 1 mov ecx, msg1 mov edx, 3 int 0x80
mov eax, 4 mov ebx, 1 mov ecx, msg3mov edx, msgLen ; # of charsint 0x80
D. Thiebaut, Computer Science, Smith College
We stopped here last time…
D. Thiebaut, Computer Science, Smith College
Element of Style
Don't!
D. Thiebaut, Computer Science, Smith College
Element of Style
Better!