Skip to content

Commit 6f181db

Browse files
committed
add text_code
1 parent 7c95b15 commit 6f181db

File tree

969 files changed

+412444
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

969 files changed

+412444
-0
lines changed

text_code/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
all:
2+
echo "Please specify a rule"
3+
4+
clean:
5+
(cd arch; make clean)
6+
(cd asm; make clean)
7+
(cd conc; make clean)
8+
(cd data; make clean)
9+
(cd ecf; make clean)
10+
(cd error; make clean)
11+
(cd intro; make clean)
12+
(cd io; make clean)
13+
(cd link; make clean)
14+
(cd mem; make clean)
15+
(cd netp; make clean)
16+
(cd opt; make clean)
17+
(cd perf; make clean)
18+
(cd src; make clean)
19+
(cd vm; make clean)

text_code/Makefile~

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
all:
2+
echo "Please specify a rule"
3+
4+
clean:
5+
(cd arch; make clean)
6+
(cd asm; make clean)
7+
(cd conc; make clean)
8+
(cd data; make clean)
9+
(cd ecf; make clean)
10+
(cd error; make clean)
11+
(cd intro; make clean)
12+
(cd io; make clean)
13+
(cd lib; make clean)
14+
(cd link; make clean)
15+
(cd mem; make clean)
16+
(cd netp; make clean)
17+
(cd opt; make clean)
18+
(cd perf; make clean)
19+
(cd src; make clean)
20+
(cd vm; make clean)

text_code/arch/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CFLAGS = -O1 -m64
2+
ISADIR = ../../im/labs/archlab/src/misc
3+
YAS = $(ISADIR)/yas
4+
YIS = $(ISADIR)/yis
5+
6+
pushpoptest: pushpoptest.c pp.s
7+
$(CC) $(CFLAGS) -o pushpoptest pushpoptest.c pp.s
8+
cp -p pp.s pp.sa
9+
10+
11+
.SUFFIXES: .c .s .o .ys .yo .yis .txt
12+
13+
.c.s:
14+
$(CC) $(CFLAGS) -S $*.c -o $*.s
15+
16+
.ys.yo:
17+
$(YAS) $*.ys
18+
19+
# Extracting code fragments
20+
.yo.txt:
21+
egrep "\| #|:[ a-f0-9]*\|" $*.yo | \
22+
perl -ne "s/:[ a-f0-9]+\|/:/; s/[ ]*\|[ ]*#/#/; print;" > $*.txt
23+
24+
.yo.yis: $(YIS)
25+
$(YIS) $*.yo > $*.yis
26+
27+
clean:
28+
rm -f *~ pushpoptest
29+

text_code/arch/pp.s

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* $begin pushtest-s 0 */
2+
.text
3+
.globl pushtest
4+
pushtest:
5+
movq %rsp, %rax # Copy stack pointer
6+
pushq %rsp # Push stack pointer
7+
popq %rdx # Pop it back
8+
subq %rdx, %rax # Return 0 or 8
9+
ret
10+
/* $end pushtest-s 0 */
11+
12+
/* $begin poptest-s 0 */
13+
.text
14+
.globl poptest
15+
poptest:
16+
movq %rsp, %rdi # Save stack pointer
17+
pushq $0xabcd # Push test value
18+
popq %rsp # Pop to stack pointer
19+
movq %rsp, %rax # Set popped value as return value
20+
movq %rdi, %rsp # Restore stack pointer
21+
ret
22+
/* $end poptest-s 0 */
23+
24+
.text
25+
.globl _pushtest
26+
_pushtest:
27+
movq %rsp, %rax # Copy stack pointer
28+
pushq %rsp # Push stack pointer
29+
popq %rdx # Pop it back
30+
subq %rdx, %rax # Return 0 or 8
31+
ret
32+
33+
.text
34+
.globl _poptest
35+
_poptest:
36+
movq %rsp, %rdi # Save stack pointer
37+
pushq $0xabcd # Push test value
38+
popq %rsp # Pop to stack pointer
39+
movq %rsp, %rax # Set popped value as return value
40+
movq %rdi, %rsp # Restore stack pointer
41+
ret
42+
43+

text_code/arch/pp.sa

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* $begin pushtest-s 0 */
2+
.text
3+
.globl pushtest
4+
pushtest:
5+
movq %rsp, %rax # Copy stack pointer
6+
pushq %rsp # Push stack pointer
7+
popq %rdx # Pop it back
8+
subq %rdx, %rax # Return 0 or 8
9+
ret
10+
/* $end pushtest-s 0 */
11+
12+
/* $begin poptest-s 0 */
13+
.text
14+
.globl poptest
15+
poptest:
16+
movq %rsp, %rdi # Save stack pointer
17+
pushq $0xabcd # Push test value
18+
popq %rsp # Pop to stack pointer
19+
movq %rsp, %rax # Set popped value as return value
20+
movq %rdi, %rsp # Restore stack pointer
21+
ret
22+
/* $end poptest-s 0 */
23+
24+
.text
25+
.globl _pushtest
26+
_pushtest:
27+
movq %rsp, %rax # Copy stack pointer
28+
pushq %rsp # Push stack pointer
29+
popq %rdx # Pop it back
30+
subq %rdx, %rax # Return 0 or 8
31+
ret
32+
33+
.text
34+
.globl _poptest
35+
_poptest:
36+
movq %rsp, %rdi # Save stack pointer
37+
pushq $0xabcd # Push test value
38+
popq %rsp # Pop to stack pointer
39+
movq %rsp, %rax # Set popped value as return value
40+
movq %rdi, %rsp # Restore stack pointer
41+
ret
42+
43+

text_code/arch/pushpoptest.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* Experiments to test pushl %esp */
2+
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
6+
long pushtest();
7+
long poptest();
8+
9+
int main()
10+
{
11+
printf("pushtest -> 0x%lx\n", pushtest());
12+
printf("poptest -> 0x%lx\n", poptest());
13+
}

text_code/asm/#010-main.c#

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* $begin 010-multmain-c */
2+
#include <stdio.h>
3+
4+
void multstore(long, long, long *);
5+
6+
int main() {
7+
long d;
8+
multstore(2, 3, &d);
9+
printf("2 * 3 --> %ld\n", d);
10+
return 0;
11+
}
12+
13+
long mult2(long a, long b) {
14+
long s = a * b;
15+
return s;
16+
}
17+
/* $end 010-multmain-c */
18+

text_code/asm/.#cfiles.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bryant@bryant-mc1.vlsi.cs.cmu.edu.home.83303

text_code/asm/010-code-gdb.out

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
2+
Copyright (C) 2012 Free Software Foundation, Inc.
3+
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
4+
This is free software: you are free to change and redistribute it.
5+
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
6+
and "show warranty" for details.
7+
This GDB was configured as "x86_64-linux-gnu".
8+
For bug reporting instructions, please see:
9+
<http://bugs.launchpad.net/gdb-linaro/>...
10+
Reading symbols from /afs/cs.cmu.edu/project/ics3/code/asm/prog...(no debugging symbols found)...done.
11+
Breakpoint 1 at 0x400540
12+
13+
Breakpoint 1, 0x0000000000400540 in multstore ()
14+
$1 = 0x7fffffffe818
15+
$2 = 0x400540
16+
0x0000000000400544 in multstore ()
17+
$3 = 0x400544
18+
0x000000000040054d in multstore ()
19+
$4 = 0x40054d
20+
2 * 3 --> 6
21+
[Inferior 1 (process 29584) exited normally]

text_code/asm/010-code.gdb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
break multstore
2+
run
3+
print /x $rsp
4+
print /x $rip
5+
nexti 2
6+
print /x $rip
7+
nexti 3
8+
print /x $rip
9+
cont
10+
quit

0 commit comments

Comments
 (0)