-
Notifications
You must be signed in to change notification settings - Fork 12
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
104 changed files
with
506 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,52 @@ | ||
# Modification of asum code to compute absolute values of entries. | ||
# This version uses a conditional jump | ||
# Execution begins at address 0 | ||
.pos 0 | ||
init: irmovl Stack, %esp # Set up Stack pointer | ||
irmovl Stack, %ebp # Set up base pointer | ||
jmp Main # Execute main program | ||
|
||
# Array of 4 elements | ||
.align 4 | ||
array: .long 0x0000000d | ||
.long 0xffffff40 # -0xc0 | ||
.long 0x00000b00 | ||
.long 0xffff6000 # -0xa0000 | ||
|
||
Main: irmovl $4,%eax | ||
pushl %eax # Push 4 | ||
irmovl array,%edx | ||
pushl %edx # Push array | ||
call AbsSum # Sum(array, 4) | ||
halt | ||
|
||
# int AbsSum(int *Start, int Count) | ||
AbsSum: | ||
pushl %ebp | ||
rrmovl %esp,%ebp | ||
mrmovl 8(%ebp),%ecx # ecx = Start | ||
mrmovl 12(%ebp),%edx # edx = Count | ||
irmovl $0, %eax # sum = 0 | ||
andl %edx,%edx | ||
je End | ||
#/* $begin abs-sum-cmov-ys 0 */ | ||
Loop: | ||
mrmovl (%ecx),%esi # get x = *Start | ||
irmovl $0,%edi # 0 | ||
subl %esi,%edi # -x | ||
cmovg %edi,%esi # if -x > 0 then x = -x | ||
addl %esi,%eax # add x to sum | ||
irmovl $4,%ebx # | ||
addl %ebx,%ecx # Start++ | ||
irmovl $-1,%ebx # | ||
addl %ebx,%edx # Count-- | ||
jne Loop # Stop when 0 | ||
#/* $end abs-sum-cmov-ys 0 */ | ||
End: | ||
popl %ebp | ||
ret | ||
|
||
.pos 0x100 | ||
Stack: # The stack goes here | ||
#/* $end code-ysa */ | ||
#/* $end code-yso */ |
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,53 @@ | ||
# Modification of asum code to compute absolute values of entries. | ||
# This version uses a conditional jump | ||
# Execution begins at address 0 | ||
.pos 0 | ||
init: irmovl Stack, %esp # Set up Stack pointer | ||
irmovl Stack, %ebp # Set up base pointer | ||
jmp Main # Execute main program | ||
|
||
# Array of 4 elements | ||
.align 4 | ||
array: .long 0x0000000d | ||
.long 0xffffff40 # -0xc0 | ||
.long 0x00000b00 | ||
.long 0xffff6000 # -0xa0000 | ||
|
||
Main: irmovl $4,%eax | ||
pushl %eax # Push 4 | ||
irmovl array,%edx | ||
pushl %edx # Push array | ||
call AbsSum # Sum(array, 4) | ||
halt | ||
|
||
#/* $begin abs-sum-jmp-ys 0 */ | ||
# int AbsSum(int *Start, int Count) | ||
AbsSum: | ||
pushl %ebp | ||
rrmovl %esp,%ebp | ||
mrmovl 8(%ebp),%ecx # ecx = Start | ||
mrmovl 12(%ebp),%edx # edx = Count | ||
irmovl $0, %eax # sum = 0 | ||
andl %edx,%edx | ||
je End | ||
Loop: | ||
mrmovl (%ecx),%esi # get x = *Start | ||
irmovl $0,%edi # 0 | ||
subl %esi,%edi # -x | ||
jle Pos # Skip if -x <= 0 | ||
rrmovl %edi,%esi # x = -x | ||
Pos: | ||
addl %esi,%eax # add x to sum | ||
irmovl $4,%ebx # | ||
addl %ebx,%ecx # Start++ | ||
irmovl $-1,%ebx # | ||
addl %ebx,%edx # Count-- | ||
jne Loop # Stop when 0 | ||
End: | ||
popl %ebp | ||
ret | ||
#/* $end abs-sum-jmp-ys 0 */ | ||
.pos 0x100 | ||
Stack: # The stack goes here | ||
#/* $end code-ysa */ | ||
#/* $end code-yso */ |
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,4 @@ | ||
# test addl | ||
addl %esi, %edi | ||
halt | ||
# end |
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,5 @@ | ||
# test .align | ||
.align 4 | ||
halt | ||
.align 8 | ||
# end |
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,4 @@ | ||
# test andl | ||
andl %esi, %edi | ||
halt | ||
# end |
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,53 @@ | ||
#/* $begin code-yso */ | ||
#/* $begin code-ysa */ | ||
# Execution begins at address 0 | ||
.pos 0 | ||
init: irmovl Stack, %esp # Set up stack pointer | ||
irmovl Stack, %ebp # Set up base pointer | ||
call Main # Execute main program | ||
halt # Terminate program | ||
|
||
# Array of 4 elements | ||
.align 4 | ||
array: .long 0xd | ||
.long 0xc0 | ||
.long 0xb00 | ||
.long 0xa000 | ||
|
||
Main: pushl %ebp | ||
rrmovl %esp,%ebp | ||
irmovl $4,%eax | ||
pushl %eax # Push 4 | ||
irmovl array,%edx | ||
pushl %edx # Push array | ||
call Sum # Sum(array, 4) | ||
rrmovl %ebp,%esp | ||
popl %ebp | ||
ret | ||
|
||
#/* $begin sum-ys 0 */ | ||
# int Sum(int *Start, int Count) | ||
Sum: pushl %ebp | ||
rrmovl %esp,%ebp | ||
mrmovl 8(%ebp),%ecx # ecx = Start | ||
mrmovl 12(%ebp),%edx # edx = Count | ||
xorl %eax,%eax # sum = 0 | ||
andl %edx,%edx # Set condition codes | ||
je End | ||
Loop: mrmovl (%ecx),%esi # get *Start | ||
addl %esi,%eax # add to sum | ||
irmovl $4,%ebx # | ||
addl %ebx,%ecx # Start++ | ||
irmovl $-1,%ebx # | ||
addl %ebx,%edx # Count-- | ||
jne Loop # Stop when 0 | ||
End: rrmovl %ebp,%esp | ||
popl %ebp | ||
ret | ||
#/* $end sum-ys 0 */ | ||
|
||
# The stack starts here and grows to lower addresses | ||
.pos 0x100 | ||
Stack: | ||
#/* $end code-ysa */ | ||
#/* $end code-yso */ |
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,48 @@ | ||
# Execution begins at address 0 | ||
.pos 0 | ||
init: irmovl Stack, %esp # Set up Stack pointer | ||
irmovl Stack, %ebp # Set up base pointer | ||
jmp Main # Execute main program | ||
|
||
# Array of 4 elements | ||
.align 4 | ||
array: .long 0xd | ||
.long 0xc0 | ||
.long 0xb00 | ||
.long 0xa000 | ||
|
||
Main: irmovl $4,%eax | ||
pushl %eax # Push 4 | ||
irmovl array,%edx | ||
pushl %edx # Push array | ||
call rSum # Sum(array, 4) | ||
halt | ||
|
||
#/* $begin rsum-ys */ | ||
# int Sum(int *Start, int Count) | ||
rSum: pushl %ebp | ||
rrmovl %esp,%ebp | ||
pushl %ebx # Save value of %ebx | ||
mrmovl 8(%ebp),%ebx # Get Start | ||
mrmovl 12(%ebp),%eax # Get Count | ||
andl %eax,%eax # Test value of Count | ||
jle L38 # If <= 0, goto zreturn | ||
irmovl $-1,%edx | ||
addl %edx,%eax # Count-- | ||
pushl %eax # Push Count | ||
irmovl $4,%edx | ||
rrmovl %ebx,%eax | ||
addl %edx,%eax | ||
pushl %eax # Push Start+1 | ||
call rSum # Sum(Start+1, Count-1) | ||
mrmovl (%ebx),%edx | ||
addl %edx,%eax # Add *Start | ||
jmp L39 # goto done | ||
L38: xorl %eax,%eax # zreturn: | ||
L39: mrmovl -4(%ebp),%ebx # done: Restore %ebx | ||
rrmovl %ebp,%esp # Deallocate stack frame | ||
popl %ebp # Restore %ebp | ||
ret | ||
#/* $end rsum-ys */ | ||
.pos 0x400 | ||
Stack: # The stack goes here |
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,7 @@ | ||
# test .byte | ||
halt | ||
Data: | ||
.byte 0x0A | ||
.byte 0x1B | ||
.byte 0x2C | ||
# end |
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,5 @@ | ||
# test call | ||
Func1: | ||
call Func1 | ||
halt | ||
# end |
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,17 @@ | ||
# /* $begin cjr-ys */ | ||
# Code to generate a combination of not-taken branch and ret | ||
irmovl Stack, %esp | ||
irmovl rtnp,%eax | ||
pushl %eax # Set up return pointer | ||
xorl %eax,%eax # Set Z condition code | ||
jne target # Not taken (First part of combination) | ||
irmovl $1,%eax # Should execute this | ||
halt | ||
target: ret # Second part of combination | ||
irmovl $2,%ebx # Should not execute this | ||
halt | ||
rtnp: irmovl $3,%edx # Should not execute this | ||
halt | ||
.pos 0x40 | ||
Stack: | ||
# /* $end cjr-ys */ |
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,4 @@ | ||
# test cmove | ||
cmove %esi, %edi | ||
halt | ||
# end |
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,4 @@ | ||
# test cmovg | ||
cmovg %eax, %ebx | ||
halt | ||
# end |
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,4 @@ | ||
# test cmovge | ||
cmovge %eax, %ebx | ||
halt | ||
# end |
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,4 @@ | ||
# test cmovl | ||
cmovl %esi, %edi | ||
halt | ||
# end |
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,4 @@ | ||
# test cmovle | ||
cmovle %esi, %edi | ||
halt | ||
# end |
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,4 @@ | ||
# test cmovne | ||
cmovne %esi, %edi | ||
halt | ||
# end |
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,3 @@ | ||
# halt immediately | ||
halt # Terminate program | ||
# end |
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,5 @@ | ||
# test irmovl | ||
irmovl $123, %eax | ||
irmovl $-123, %ebx | ||
halt | ||
# end |
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,15 @@ | ||
irmovl $1, %esi | ||
irmovl $2, %edi | ||
irmovl $4, %ebp | ||
irmovl $-32, %eax | ||
irmovl $64, %edx | ||
subl %edx,%eax | ||
je target | ||
nop | ||
halt | ||
target: | ||
addl %esi,%edx | ||
nop | ||
nop | ||
nop | ||
halt |
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,5 @@ | ||
# test je | ||
Loop: | ||
je Loop | ||
halt | ||
# end |
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,5 @@ | ||
# test jg | ||
Loop: | ||
jg Loop | ||
halt | ||
# end |
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,5 @@ | ||
# test jge | ||
Loop: | ||
jge Loop | ||
halt | ||
# end |
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,5 @@ | ||
# test jl | ||
Loop: | ||
jl Loop | ||
halt | ||
# end |
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,5 @@ | ||
# test jle | ||
Loop: | ||
jle Loop | ||
halt | ||
# end |
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,5 @@ | ||
# test jmp | ||
Loop: | ||
jmp Loop | ||
halt | ||
# end |
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,5 @@ | ||
# test jne | ||
Loop: | ||
jne Loop | ||
halt | ||
# end |
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,7 @@ | ||
# test .long | ||
halt | ||
Data: | ||
.long 0xfffff70A | ||
.long 0x0000001B | ||
.long 0xfff9062C | ||
# end |
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,6 @@ | ||
# test mrmovl | ||
mrmovl -2(%esp), %eax | ||
mrmovl (%ebx), %esi | ||
mrmovl 8(%ebp), %ecx | ||
halt | ||
# end |
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,5 @@ | ||
# nop, nop and halt | ||
nop | ||
nop | ||
halt # Terminate program | ||
# end |
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,4 @@ | ||
# test popl | ||
popl %ebp | ||
halt | ||
# end |
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,6 @@ | ||
# Test of Pop semantics for Y86 | ||
irmovl $0x100,%esp # Initialize stack pointer | ||
irmovl $0xABCD,%eax | ||
pushl %eax # Put known value on stack | ||
popl %esp # Either get 0xABCD, or 0xfc | ||
halt |
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,7 @@ | ||
# test .pos | ||
.pos 0 | ||
Begin: | ||
halt | ||
.pos 0x100 | ||
Stack: | ||
# end |
Oops, something went wrong.