forked from Hansimov/csapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,111 changed files
with
598,713 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
all: | ||
echo "Please specify a rule" | ||
|
||
dist: | ||
(cd opt; make dist) | ||
|
||
clean: | ||
(cd arch; make clean) | ||
(cd asm; make clean) | ||
(cd conc; make clean) | ||
(cd data; make clean) | ||
(cd ecf; make clean) | ||
(cd error; make clean) | ||
(cd intro; make clean) | ||
(cd io; make clean) | ||
(cd link; make clean) | ||
(cd mem; make clean) | ||
(cd netp; make clean) | ||
(cd opt; make clean) | ||
(cd perf; make clean) | ||
(cd src; make clean) | ||
(cd vm; make clean) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CFLAGS = -O1 -m64 | ||
ISADIR = ../../im/labs/archlab/src/misc | ||
YAS = $(ISADIR)/yas | ||
YIS = $(ISADIR)/yis | ||
|
||
pushpoptest: pushpoptest.c pp.s | ||
$(CC) $(CFLAGS) -o pushpoptest pushpoptest.c pp.s | ||
cp -p pp.s pp.sa | ||
|
||
|
||
.SUFFIXES: .c .s .o .ys .yo .yis .txt | ||
|
||
.c.s: | ||
$(CC) $(CFLAGS) -S $*.c -o $*.s | ||
|
||
.ys.yo: | ||
$(YAS) $*.ys | ||
|
||
# Extracting code fragments | ||
.yo.txt: | ||
egrep "\| #|:[ a-f0-9]*\|" $*.yo | \ | ||
perl -ne "s/:[ a-f0-9]+\|/:/; s/[ ]*\|[ ]*#/#/; print;" > $*.txt | ||
|
||
.yo.yis: $(YIS) | ||
$(YIS) $*.yo > $*.yis | ||
|
||
clean: | ||
rm -f *~ pushpoptest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* $begin pushtest-s 0 */ | ||
.text | ||
.globl pushtest | ||
pushtest: | ||
movq %rsp, %rax # Copy stack pointer | ||
pushq %rsp # Push stack pointer | ||
popq %rdx # Pop it back | ||
subq %rdx, %rax # Return 0 or 8 | ||
ret | ||
/* $end pushtest-s 0 */ | ||
|
||
/* $begin poptest-s 0 */ | ||
.text | ||
.globl poptest | ||
poptest: | ||
movq %rsp, %rdi # Save stack pointer | ||
pushq $0xabcd # Push test value | ||
popq %rsp # Pop to stack pointer | ||
movq %rsp, %rax # Set popped value as return value | ||
movq %rdi, %rsp # Restore stack pointer | ||
ret | ||
/* $end poptest-s 0 */ | ||
|
||
.text | ||
.globl _pushtest | ||
_pushtest: | ||
movq %rsp, %rax # Copy stack pointer | ||
pushq %rsp # Push stack pointer | ||
popq %rdx # Pop it back | ||
subq %rdx, %rax # Return 0 or 8 | ||
ret | ||
|
||
.text | ||
.globl _poptest | ||
_poptest: | ||
movq %rsp, %rdi # Save stack pointer | ||
pushq $0xabcd # Push test value | ||
popq %rsp # Pop to stack pointer | ||
movq %rsp, %rax # Set popped value as return value | ||
movq %rdi, %rsp # Restore stack pointer | ||
ret | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* $begin pushtest-s 0 */ | ||
.text | ||
.globl pushtest | ||
pushtest: | ||
movq %rsp, %rax # Copy stack pointer | ||
pushq %rsp # Push stack pointer | ||
popq %rdx # Pop it back | ||
subq %rdx, %rax # Return 0 or 8 | ||
ret | ||
/* $end pushtest-s 0 */ | ||
|
||
/* $begin poptest-s 0 */ | ||
.text | ||
.globl poptest | ||
poptest: | ||
movq %rsp, %rdi # Save stack pointer | ||
pushq $0xabcd # Push test value | ||
popq %rsp # Pop to stack pointer | ||
movq %rsp, %rax # Set popped value as return value | ||
movq %rdi, %rsp # Restore stack pointer | ||
ret | ||
/* $end poptest-s 0 */ | ||
|
||
.text | ||
.globl _pushtest | ||
_pushtest: | ||
movq %rsp, %rax # Copy stack pointer | ||
pushq %rsp # Push stack pointer | ||
popq %rdx # Pop it back | ||
subq %rdx, %rax # Return 0 or 8 | ||
ret | ||
|
||
.text | ||
.globl _poptest | ||
_poptest: | ||
movq %rsp, %rdi # Save stack pointer | ||
pushq $0xabcd # Push test value | ||
popq %rsp # Pop to stack pointer | ||
movq %rsp, %rax # Set popped value as return value | ||
movq %rdi, %rsp # Restore stack pointer | ||
ret | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* Experiments to test pushl %esp */ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
long pushtest(); | ||
long poptest(); | ||
|
||
int main() | ||
{ | ||
printf("pushtest -> 0x%lx\n", pushtest()); | ||
printf("poptest -> 0x%lx\n", poptest()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* $begin 010-multmain-c */ | ||
#include <stdio.h> | ||
|
||
void multstore(long, long, long *); | ||
|
||
int main() { | ||
long d; | ||
multstore(2, 3, &d); | ||
printf("2 * 3 --> %ld\n", d); | ||
return 0; | ||
} | ||
|
||
long mult2(long a, long b) { | ||
long s = a * b; | ||
return s; | ||
} | ||
/* $end 010-multmain-c */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04 | ||
Copyright (C) 2012 Free Software Foundation, Inc. | ||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | ||
This is free software: you are free to change and redistribute it. | ||
There is NO WARRANTY, to the extent permitted by law. Type "show copying" | ||
and "show warranty" for details. | ||
This GDB was configured as "x86_64-linux-gnu". | ||
For bug reporting instructions, please see: | ||
<http://bugs.launchpad.net/gdb-linaro/>... | ||
Reading symbols from /afs/cs.cmu.edu/project/ics3/code/asm/prog...(no debugging symbols found)...done. | ||
Breakpoint 1 at 0x400540 | ||
|
||
Breakpoint 1, 0x0000000000400540 in multstore () | ||
$1 = 0x7fffffffe818 | ||
$2 = 0x400540 | ||
0x0000000000400544 in multstore () | ||
$3 = 0x400544 | ||
0x000000000040054d in multstore () | ||
$4 = 0x40054d | ||
2 * 3 --> 6 | ||
[Inferior 1 (process 29584) exited normally] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
break multstore | ||
run | ||
print /x $rsp | ||
print /x $rip | ||
nexti 2 | ||
print /x $rip | ||
nexti 3 | ||
print /x $rip | ||
cont | ||
quit |
Oops, something went wrong.