add initial file to this repos
This commit is contained in:
parent
16bfa50307
commit
14c6f67c9d
3
Makefile
Normal file
3
Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
all:
|
||||
@echo 'remember to use the "cd submit" command before running make'
|
||||
|
||||
BIN
autograder_test/autograder.o.hold
Normal file
BIN
autograder_test/autograder.o.hold
Normal file
Binary file not shown.
2
autograder_test/autograder_makefile
Normal file
2
autograder_test/autograder_makefile
Normal file
@ -0,0 +1,2 @@
|
||||
autograder:
|
||||
@clang -g autograder.o autograder_helpers.o lc4_memory.o lc4_disassembler.o lc4_loader.o -o autograder
|
||||
92
makefiletest.sh
Executable file
92
makefiletest.sh
Executable file
@ -0,0 +1,92 @@
|
||||
#!/bin/bash
|
||||
|
||||
remove_compiled () {
|
||||
rm -f autograder*
|
||||
rm -f lc4
|
||||
rm -f *.o
|
||||
}
|
||||
|
||||
ERR='\033[1;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
cd submit
|
||||
|
||||
required_files=( "lc4.c" "lc4_disassembler.c" "lc4_disassembler.h" \
|
||||
"lc4_loader.c" "lc4_loader.h" "lc4_memory.c" "lc4_memory.h" "Makefile")
|
||||
|
||||
for file in "${required_files[@]}"
|
||||
do
|
||||
if [ ! -f $file ]; then
|
||||
echo -e "${ERR}Required file ${file} does not exist!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $1 == "lc4" ]; then
|
||||
make lc4
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${ERR}LC4 Makefile failed!${NC}"
|
||||
remove_compiled
|
||||
exit
|
||||
fi
|
||||
|
||||
echo -e "${NC}LC4 Makefile successful!${NC}"
|
||||
remove_compiled
|
||||
elif [ $1 == "integration" ]; then
|
||||
remove_compiled
|
||||
cp ../autograder_test/* .
|
||||
make lc4
|
||||
|
||||
echo -e "${NC}running lc4 on testone.obj and comparing results with correct solution${NC}"
|
||||
|
||||
cp ../obj*/testone.* .
|
||||
./lc4 testone.obj
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${ERR}lc4 failed!${NC}"
|
||||
remove_compiled
|
||||
exit
|
||||
fi
|
||||
|
||||
cat testone.sol
|
||||
|
||||
make -f autograder_makefile autograder
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${ERR}Compilation failed!${NC}"
|
||||
remove_compiled
|
||||
exit
|
||||
fi
|
||||
|
||||
./autograder search_opcode 998
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${NC}Compilation passed, but ${ERR}search opcode unit test failed!${NC}"
|
||||
remove_compiled
|
||||
exit
|
||||
fi
|
||||
|
||||
./autograder reverse_assemble 999
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${NC}Compilation passed, but ${ERR}reverse assembler unit test failed!${NC}"
|
||||
remove_compiled
|
||||
exit
|
||||
fi
|
||||
|
||||
./autograder add_to_list 999
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${NC}Compilation passed, but ${ERR}add to list unit test failed!${NC}"
|
||||
remove_compiled
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
echo -e "${NC}Successfully compiled, sample unit tests passed!${NC}"
|
||||
echo -e "${NC}This is only a subset of the full tests. Remember to test your lc4 program with the sample .obj files${NC}"
|
||||
remove_compiled
|
||||
else
|
||||
echo -e "${ERR}Invalid or missing argument!${NC}"
|
||||
echo "Usage:"
|
||||
echo " ./makefiletest.sh <lc4|integration>"
|
||||
exit 1
|
||||
fi
|
||||
36
obj files for student testing/dmem_fact_ec.sol
Normal file
36
obj files for student testing/dmem_fact_ec.sol
Normal file
@ -0,0 +1,36 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
MAIN 0000 9420
|
||||
0001 D540
|
||||
0002 16A5 ADD R3, R2, #5
|
||||
FOR_LOOP 0003 2403
|
||||
0004 0603
|
||||
0005 4801
|
||||
0006 14A1 ADD R2, R2, #1
|
||||
0007 CFFB
|
||||
END_FOR_LOOP 0008 C81B
|
||||
SUB_FACTORIAL 0010 6080
|
||||
0011 2100
|
||||
0012 0A02
|
||||
0013 9201
|
||||
0014 C80D
|
||||
END_IF1 0015 0202
|
||||
0016 93FF
|
||||
0017 C80A
|
||||
END_IF2 0018 2107
|
||||
0019 0C02
|
||||
001A 93FF
|
||||
001B C806
|
||||
END_IF3 001C 1220 ADD R1, R0, #0
|
||||
LOOP 001D 2101
|
||||
001E 0C03
|
||||
001F 103F ADD R0, R0, #-1
|
||||
0020 1248 MUL R1, R1, R0
|
||||
0021 CFFB
|
||||
END_SUB_FACTORIAL 0022 7280
|
||||
0023 C1C0
|
||||
END 0024 0000
|
||||
VALUES 4020 0006
|
||||
4021 0005
|
||||
4022 0008
|
||||
4023 000A
|
||||
4024 FFFB
|
||||
248
obj files for student testing/os.sol
Normal file
248
obj files for student testing/os.sol
Normal file
@ -0,0 +1,248 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
8000 CA01
|
||||
8001 CA08
|
||||
8002 CA0F
|
||||
8003 CA34
|
||||
8004 CA4A
|
||||
8005 CA5B
|
||||
OS_START 8200 9E00
|
||||
8201 8000
|
||||
TRAP_GETC 8202 9000
|
||||
8203 D1FE
|
||||
8204 6000
|
||||
8205 07FC
|
||||
8206 9002
|
||||
8207 D1FE
|
||||
8208 6000
|
||||
8209 8000
|
||||
TRAP_PUTC 820A 9204
|
||||
820B D3FE
|
||||
820C 6240
|
||||
820D 07FC
|
||||
820E 9206
|
||||
820F D3FE
|
||||
8210 7040
|
||||
8211 8000
|
||||
TRAP_GETS 8212 9200
|
||||
8213 9800
|
||||
8214 D920
|
||||
8215 2004
|
||||
8216 0820
|
||||
8217 98FF
|
||||
8218 D97F
|
||||
8219 2004
|
||||
821A 021C
|
||||
821B 9800
|
||||
821C 9800
|
||||
READ 821D 9400
|
||||
821E D5FE
|
||||
821F 6480
|
||||
8220 07FC
|
||||
8221 9602
|
||||
8222 D7FE
|
||||
8223 6AC0
|
||||
8224 9C00
|
||||
8225 DD0D
|
||||
8226 2A06
|
||||
8227 040A
|
||||
8228 9C0A
|
||||
8229 2A06
|
||||
822A 0407
|
||||
822B 9C00
|
||||
822C 2A06
|
||||
822D 0404
|
||||
822E 1801 ADD R4, R0, R1
|
||||
822F 7B00
|
||||
8230 1261 ADD R1, R1, #1
|
||||
8231 0FEB
|
||||
DONE_GETS 8232 9C00
|
||||
8233 DD00
|
||||
8234 1801 ADD R4, R0, R1
|
||||
8235 1921 ADD R4, R4, #1
|
||||
8236 7D00
|
||||
DONE_GETS_NO_WRITE 8237 8000
|
||||
TRAP_PUTS 8238 9800
|
||||
8239 D920
|
||||
823A 2004
|
||||
823B 0812
|
||||
823C 98FF
|
||||
823D D97F
|
||||
823E 2004
|
||||
823F 020E
|
||||
8240 9800
|
||||
LOAD 8241 1500 ADD R2, R4, R0
|
||||
8242 6280
|
||||
8243 2300
|
||||
8244 0409
|
||||
8245 9404
|
||||
8246 D5FE
|
||||
8247 6480
|
||||
8248 07F8
|
||||
8249 9606
|
||||
824A D7FE
|
||||
824B 72C0
|
||||
824C 1921 ADD R4, R4, #1
|
||||
824D 0FF3
|
||||
DONE_PUTS 824E 8000
|
||||
TRAP_GETC_TIMER 824F 920A
|
||||
8250 D3FE
|
||||
8251 9608
|
||||
8252 D7FE
|
||||
8253 94D0
|
||||
8254 D507
|
||||
8255 7440
|
||||
AWAIT_LOOP 8256 68C0
|
||||
8257 0808
|
||||
8258 9000
|
||||
8259 D1FE
|
||||
825A 6000
|
||||
825B 0801
|
||||
825C 05F9
|
||||
READY_TO_READ 825D 9002
|
||||
825E D1FE
|
||||
825F 6000
|
||||
DONE_WAITING 8260 8000
|
||||
TRAP_DRAW_RECT 8261 7FBE
|
||||
8262 7BBD
|
||||
8263 1DBD ADD R6, R6, #-3
|
||||
8264 1BA0 ADD R5, R6, #0
|
||||
8265 1DBB ADD R6, R6, #-5
|
||||
8266 717F
|
||||
8267 737E
|
||||
8268 757D
|
||||
8269 777C
|
||||
826A 797B
|
||||
826B 2500
|
||||
826C 0C31
|
||||
826D 2700
|
||||
826E 0C2F
|
||||
826F 2300
|
||||
8270 0C2D
|
||||
8271 9E7C
|
||||
8272 2607
|
||||
8273 022A
|
||||
8274 9E80
|
||||
8275 2407
|
||||
8276 0227
|
||||
8277 2100
|
||||
8278 0825
|
||||
8279 2300
|
||||
827A 0823
|
||||
827B 16C1 ADD R3, R3, R1
|
||||
827C 1480 ADD R2, R2, R0
|
||||
VALIDATE_SIZE_AND_POSITION_Y 827D 9E7C
|
||||
827E 2607
|
||||
827F 0204
|
||||
VALIDATE_SIZE_AND_POSITION_X 8280 9E80
|
||||
8281 2407
|
||||
8282 0205
|
||||
8283 0C07
|
||||
FIX_Y 8284 1ED7 SUB R7, R3, R7
|
||||
8285 1017 SUB R0, R0, R7
|
||||
8286 16D7 SUB R3, R3, R7
|
||||
8287 0FF8
|
||||
FIX_X 8288 1E97 SUB R7, R2, R7
|
||||
8289 1017 SUB R0, R0, R7
|
||||
828A 1497 SUB R2, R2, R7
|
||||
SET_UP_NEW_ROW 828B 9E80
|
||||
828C 1E4F MUL R7, R1, R7
|
||||
828D 9800
|
||||
828E D9C0
|
||||
828F 1FC0 ADD R7, R7, R0
|
||||
8290 1FC4 ADD R7, R7, R4
|
||||
8291 1820 ADD R4, R0, #0
|
||||
8292 0E06
|
||||
DRAW_COLUMN 8293 757D
|
||||
8294 657B
|
||||
8295 75C0
|
||||
8296 657D
|
||||
8297 1921 ADD R4, R4, #1
|
||||
8298 1FE1 ADD R7, R7, #1
|
||||
UPDATE_ROW_IF_DONE 8299 2802
|
||||
829A 09F8
|
||||
829B 1261 ADD R1, R1, #1
|
||||
829C 2203
|
||||
829D 09ED
|
||||
DONE_DRAWING 829E 1D60 ADD R6, R5, #0
|
||||
829F 1DA3 ADD R6, R6, #3
|
||||
82A0 6BBD
|
||||
82A1 6FBE
|
||||
82A2 8000
|
||||
OS_GLOBALS_MEM A000 0000
|
||||
A001 0000
|
||||
A002 0000
|
||||
A003 0000
|
||||
A004 0000
|
||||
A005 0000
|
||||
A006 0000
|
||||
A007 0000
|
||||
A008 0000
|
||||
A009 0000
|
||||
A00A 0000
|
||||
A00B 0000
|
||||
A00C 0000
|
||||
A00D 0000
|
||||
A00E 0000
|
||||
A00F 0000
|
||||
OS_VIDEO_MEM C000 0000
|
||||
C001 0000
|
||||
C002 0000
|
||||
C003 0000
|
||||
C004 0000
|
||||
C005 0000
|
||||
C006 0000
|
||||
C007 0000
|
||||
C008 0000
|
||||
C009 0000
|
||||
C00A 0000
|
||||
C00B 0000
|
||||
C00C 0000
|
||||
C00D 0000
|
||||
C00E 0000
|
||||
C00F 0000
|
||||
C010 0000
|
||||
C011 0000
|
||||
C012 0000
|
||||
C013 0000
|
||||
C014 0000
|
||||
C015 0000
|
||||
C016 0000
|
||||
C017 0000
|
||||
C018 0000
|
||||
C019 0000
|
||||
C01A 0000
|
||||
C01B 0000
|
||||
C01C 0000
|
||||
C01D 0000
|
||||
C01E 0000
|
||||
C01F 0000
|
||||
C020 0000
|
||||
C021 0000
|
||||
C022 0000
|
||||
C023 0000
|
||||
C024 0000
|
||||
C025 0000
|
||||
C026 0000
|
||||
C027 0000
|
||||
C028 0000
|
||||
C029 0000
|
||||
C02A 0000
|
||||
C02B 0000
|
||||
C02C 0000
|
||||
C02D 0000
|
||||
C02E 0000
|
||||
C02F 0000
|
||||
C030 0000
|
||||
C031 0000
|
||||
C032 0000
|
||||
C033 0000
|
||||
C034 0000
|
||||
C035 0000
|
||||
C036 0000
|
||||
C037 0000
|
||||
C038 0000
|
||||
C039 0000
|
||||
C03A 0000
|
||||
C03B 0000
|
||||
C03C 0000
|
||||
C03D 0000
|
||||
8
obj files for student testing/test1.sol
Normal file
8
obj files for student testing/test1.sol
Normal file
@ -0,0 +1,8 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
BEGINING 000A 1201 ADD R1, R0, R1
|
||||
000B 1449 MUL R2, R1, R1
|
||||
000C 1691 SUB R3, R2, R1
|
||||
END 000D 0000
|
||||
VALUES 4020 0001
|
||||
4021 0002
|
||||
4022 0003
|
||||
13
obj files for student testing/test11.sol
Normal file
13
obj files for student testing/test11.sol
Normal file
@ -0,0 +1,13 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
L1 0000 1201 ADD R1, R0, R1
|
||||
0001 0000
|
||||
0002 1449 MUL R2, R1, R1
|
||||
0003 1691 SUB R3, R2, R1
|
||||
L2 000A 12DA DIV R1, R3, R2
|
||||
000B 5283
|
||||
000C 52D2
|
||||
000D 52DA
|
||||
L3 000E 0000
|
||||
L4 4020 000A
|
||||
4021 000B
|
||||
4022 000C
|
||||
49
obj files for student testing/test2.sol
Normal file
49
obj files for student testing/test2.sol
Normal file
@ -0,0 +1,49 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
INIT 0000 F001
|
||||
0001 90FF
|
||||
0002 D1FF
|
||||
0003 8000
|
||||
START 0005 1042 ADD R0, R1, R2
|
||||
0006 170D MUL R3, R4, R5
|
||||
0007 1DD0 SUB R6, R7, R0
|
||||
0008 12DA DIV R1, R3, R2
|
||||
IMMS_XB 000B 112F ADD R0, R4, #15
|
||||
000C 1FF0 ADD R7, R7, #-16
|
||||
BRANCH 000D 081B
|
||||
000E 0DFC
|
||||
000F 0BF5
|
||||
0010 0403
|
||||
0011 0607
|
||||
0012 03FA
|
||||
0013 0FF1
|
||||
LOGICALS 0014 5283
|
||||
0015 52D2
|
||||
0016 52DA
|
||||
0017 52BF
|
||||
0018 51C8
|
||||
COMPARES 0019 2001
|
||||
001A 2483
|
||||
001B 2940
|
||||
001C 2B3F
|
||||
001D 2DFF
|
||||
001E 2F80
|
||||
DMEM 001F 629F
|
||||
0020 72A0
|
||||
SHIFTERS_MOD 0021 A70F
|
||||
0022 AB90
|
||||
0023 AE2A
|
||||
0024 A2BB
|
||||
0025 0000
|
||||
JUMPS 0026 480F
|
||||
0027 4000
|
||||
0028 C040
|
||||
END 0029 0000
|
||||
SUBROUTINE 00F0 102A ADD R0, R0, #10
|
||||
00F1 CF2F
|
||||
END_SUBROUTINE 00F2 0000
|
||||
VALUES 2000 8000
|
||||
2001 7FFF
|
||||
2002 52D2
|
||||
2003 1042
|
||||
2004 0DFC
|
||||
2005 297B
|
||||
49
obj files for student testing/test2_.sol
Normal file
49
obj files for student testing/test2_.sol
Normal file
@ -0,0 +1,49 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
INIT 0000 F001
|
||||
0001 90FF
|
||||
0002 D1FF
|
||||
0003 8000
|
||||
START 0005 1042 ADD R0, R1, R2
|
||||
0006 170D MUL R3, R4, R5
|
||||
0007 1DD0 SUB R6, R7, R0
|
||||
0008 12DA DIV R1, R3, R2
|
||||
IMMS_XB 000B 112F ADD R0, R4, #15
|
||||
000C 1FF0 ADD R7, R7, #-16
|
||||
BRANCH 000D 081B
|
||||
000E 0DFC
|
||||
000F 0BF5
|
||||
0010 0403
|
||||
0011 0607
|
||||
0012 03FA
|
||||
0013 0FF1
|
||||
LOGICALS 0014 5283
|
||||
0015 52D2
|
||||
0016 52DA
|
||||
0017 52BF
|
||||
0018 51C8
|
||||
COMPARES 0019 2001
|
||||
001A 2483
|
||||
001B 2940
|
||||
001C 2B3F
|
||||
001D 2DFF
|
||||
001E 2F80
|
||||
DMEM 001F 629F
|
||||
0020 72A0
|
||||
SHIFTERS_MOD 0021 A70F
|
||||
0022 AB90
|
||||
0023 AE2A
|
||||
0024 A2BB
|
||||
0025 0000
|
||||
JUMPS 0026 480F
|
||||
0027 4000
|
||||
0028 C040
|
||||
END 0029 0000
|
||||
SUBROUTINE 00F0 102A ADD R0, R0, #10
|
||||
00F1 CF2F
|
||||
END_SUBROUTINE 00F2 0000
|
||||
VALUES 2000 8000
|
||||
2001 7FFF
|
||||
2002 52D2
|
||||
2003 1042
|
||||
2004 0DFC
|
||||
2005 297B
|
||||
4
obj files for student testing/testc.sol
Normal file
4
obj files for student testing/testc.sol
Normal file
@ -0,0 +1,4 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
4020 000A
|
||||
4021 000B
|
||||
4022 000C
|
||||
12
obj files for student testing/testc1.sol
Normal file
12
obj files for student testing/testc1.sol
Normal file
@ -0,0 +1,12 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
L1 0000 1201 ADD R1, R0, R1
|
||||
0001 1449 MUL R2, R1, R1
|
||||
0002 1691 SUB R3, R2, R1
|
||||
L2 000A 12DA DIV R1, R3, R2
|
||||
000B 5283
|
||||
000C 52D2
|
||||
000D 52DA
|
||||
L3 000E 0000
|
||||
L4 4020 000A
|
||||
4021 000B
|
||||
4022 000C
|
||||
12
obj files for student testing/testc2.sol
Normal file
12
obj files for student testing/testc2.sol
Normal file
@ -0,0 +1,12 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
L1 0000 1201 ADD R1, R0, R1
|
||||
0001 1449 MUL R2, R1, R1
|
||||
0002 1691 SUB R3, R2, R1
|
||||
L2 000A 12DA DIV R1, R3, R2
|
||||
000B 5283
|
||||
000C 52D2
|
||||
000D 52DA
|
||||
L3 000E 0000
|
||||
L4 4020 000A
|
||||
4021 000B
|
||||
4022 000C
|
||||
3
obj files for student testing/testlabel.sol
Normal file
3
obj files for student testing/testlabel.sol
Normal file
@ -0,0 +1,3 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
INIT 0000 1283 ADD R1, R2, R3
|
||||
END1 0001 0000
|
||||
2
obj files for student testing/testone.sol
Normal file
2
obj files for student testing/testone.sol
Normal file
@ -0,0 +1,2 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
0000 1283 ADD R1, R2, R3
|
||||
18
obj files for student testing/tests.sol
Normal file
18
obj files for student testing/tests.sol
Normal file
@ -0,0 +1,18 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
BEGIN 0000 5283
|
||||
0001 5448
|
||||
0002 5291
|
||||
0003 541B
|
||||
0004 5B27
|
||||
0005 5B39
|
||||
START 000A 0000
|
||||
INIT 0010 1041 ADD R0, R1, R1
|
||||
0011 14CC MUL R2, R3, R4
|
||||
0012 1F95 SUB R7, R6, R5
|
||||
0013 165A DIV R3, R1, R2
|
||||
0014 10A5 ADD R0, R2, #5
|
||||
0015 10BB ADD R0, R2, #-5
|
||||
CONST1 4000 0010
|
||||
4001 0005
|
||||
4002 0004
|
||||
CONST2 4003 0000
|
||||
23
obj files for student testing/user_draw.sol
Normal file
23
obj files for student testing/user_draw.sol
Normal file
@ -0,0 +1,23 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
MAIN 0000 9032
|
||||
0001 9205
|
||||
0002 940A
|
||||
0003 9605
|
||||
0004 9800
|
||||
0005 D97C
|
||||
0006 F009
|
||||
0007 900A
|
||||
0008 920A
|
||||
0009 9432
|
||||
000A 9628
|
||||
000B 98D0
|
||||
000C D903
|
||||
000D F009
|
||||
000E 9078
|
||||
000F 9264
|
||||
0010 941B
|
||||
0011 960A
|
||||
0012 98E0
|
||||
0013 D97F
|
||||
0014 F009
|
||||
END 0015 0000
|
||||
69
obj files for student testing/user_string_ec.sol
Normal file
69
obj files for student testing/user_string_ec.sol
Normal file
@ -0,0 +1,69 @@
|
||||
<label> <address> <contents> <assembly>
|
||||
MAIN 0000 9000
|
||||
0001 D140
|
||||
0002 F003
|
||||
ECHO_LOOP 0003 90D0
|
||||
0004 D107
|
||||
0005 F005
|
||||
0006 9200
|
||||
0007 D342
|
||||
0008 7040
|
||||
0009 2100
|
||||
000A 0407
|
||||
000B F001
|
||||
000C 9200
|
||||
000D D342
|
||||
000E 6040
|
||||
000F 218A
|
||||
0010 0406
|
||||
0011 CFF1
|
||||
TIMED_OUT 0012 900A
|
||||
0013 F001
|
||||
0014 901A
|
||||
0015 D140
|
||||
0016 F003
|
||||
END 0017 0000
|
||||
PROMPT 4000 0054
|
||||
4001 0079
|
||||
4002 0070
|
||||
4003 0065
|
||||
4004 0020
|
||||
4005 0048
|
||||
4006 0065
|
||||
4007 0072
|
||||
4008 0065
|
||||
4009 0020
|
||||
400A 0028
|
||||
400B 0045
|
||||
400C 004E
|
||||
400D 0054
|
||||
400E 0045
|
||||
400F 0052
|
||||
4010 0020
|
||||
4011 0074
|
||||
4012 006F
|
||||
4013 0020
|
||||
4014 0065
|
||||
4015 006E
|
||||
4016 0064
|
||||
4017 0029
|
||||
4018 003E
|
||||
4019 0000
|
||||
TIME_OUT_STR 401A 0053
|
||||
401B 006F
|
||||
401C 0072
|
||||
401D 0072
|
||||
401E 0079
|
||||
401F 0020
|
||||
4020 0074
|
||||
4021 0069
|
||||
4022 006D
|
||||
4023 0065
|
||||
4024 006F
|
||||
4025 0075
|
||||
4026 0074
|
||||
4027 0020
|
||||
4028 002E
|
||||
4029 002E
|
||||
402A 002E
|
||||
402B 0000
|
||||
27
submit/Makefile
Normal file
27
submit/Makefile
Normal file
@ -0,0 +1,27 @@
|
||||
#########################################################
|
||||
# file name : Makefile #
|
||||
# description : Makefile to automate compiling #
|
||||
# and linking #
|
||||
#########################################################
|
||||
#
|
||||
#
|
||||
|
||||
all: lc4
|
||||
|
||||
lc4_disassembler.o: lc4_disassembler.h lc4_disassembler.c
|
||||
clang -c -g lc4_disassembler.c
|
||||
|
||||
lc4_loader.o: lc4_loader.h lc4_loader.c
|
||||
clang -c -g lc4_loader.c
|
||||
|
||||
lc4_memory.o: lc4_memory.h lc4_memory.c
|
||||
clang -c -g lc4_memory.c
|
||||
|
||||
lc4: lc4.c lc4_memory.o lc4_loader.o lc4_disassembler.o
|
||||
clang lc4.c -g lc4_memory.o lc4_loader.o lc4_disassembler.o -o lc4
|
||||
|
||||
clean:
|
||||
rm -rf *.o
|
||||
|
||||
clobber: clean
|
||||
rm -rf lc4
|
||||
55
submit/lc4.c
Normal file
55
submit/lc4.c
Normal file
@ -0,0 +1,55 @@
|
||||
/************************************************************************/
|
||||
/* File Name : lc4.c */
|
||||
/* Purpose : This file contains the main() for this project */
|
||||
/* main() will call the loader and disassembler functions */
|
||||
/* */
|
||||
/* Author(s) : tjf and you */
|
||||
/************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lc4_memory.h"
|
||||
#include "lc4_loader.h"
|
||||
#include "lc4_disassembler.h"
|
||||
|
||||
/* program to mimic pennsim loader and disassemble object files */
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
|
||||
/* leave plenty of room for the filename */
|
||||
|
||||
char filename[100];
|
||||
|
||||
/**
|
||||
* main() holds the linked list &
|
||||
* only calls functions in other files
|
||||
*/
|
||||
|
||||
/* step 1: create head pointer to linked list: memory */
|
||||
/* do not change this line - there should no be malloc calls in main() */
|
||||
|
||||
row_of_memory* memory = NULL ;
|
||||
|
||||
|
||||
/* step 2: determine filename, then open it */
|
||||
/* TODO: extract filename from argv, pass it to open_file() */
|
||||
|
||||
|
||||
/* step 3: call function: parse_file() in lc4_loader.c */
|
||||
/* TODO: call function & check for errors */
|
||||
|
||||
|
||||
/* step 4: call function: reverse_assemble() in lc4_disassembler.c */
|
||||
/* TODO: call function & check for errors */
|
||||
|
||||
|
||||
/* step 5: call function: print_list() in lc4_memory.c */
|
||||
/* TODO: call function */
|
||||
|
||||
|
||||
/* step 6: call function: delete_list() in lc4_memory.c */
|
||||
/* TODO: call function & check for errors */
|
||||
|
||||
|
||||
/* only return 0 if everything works properly */
|
||||
return 0 ;
|
||||
}
|
||||
18
submit/lc4_disassembler.c
Normal file
18
submit/lc4_disassembler.c
Normal file
@ -0,0 +1,18 @@
|
||||
/************************************************************************/
|
||||
/* File Name : lc4_disassembler.c */
|
||||
/* Purpose : This file implements the reverse assembler */
|
||||
/* for LC4 assembly. It will be called by main() */
|
||||
/* */
|
||||
/* Author(s) : tjf and you */
|
||||
/************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lc4_memory.h"
|
||||
|
||||
int reverse_assemble (row_of_memory* memory)
|
||||
{
|
||||
/* if you use binary constants, they should be proceeded by a 0b as in 0b011 for decimal 3 */
|
||||
/* without the 0b, constants with leading zeroes will be considered octal constants, not binary */
|
||||
/* hex constants starting with 0x can also be used */
|
||||
return 0 ;
|
||||
}
|
||||
25
submit/lc4_disassembler.h
Normal file
25
submit/lc4_disassembler.h
Normal file
@ -0,0 +1,25 @@
|
||||
/************************************************************************/
|
||||
/* File Name : lc4_disassembler.h */
|
||||
/* Purpose : This function declares functions for lc4_dissembler.c */
|
||||
/* */
|
||||
/* */
|
||||
/* Author(s) : tjf */
|
||||
/************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lc4_memory.h"
|
||||
|
||||
/*
|
||||
* declarations of functions that must defined in lc4_disassembler.c
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* translates the hex representation of arithmetic instructions
|
||||
* into their assembly equivalent in the given linked list.
|
||||
*
|
||||
* returns 0 upon success, and non-zero if an error occurs.
|
||||
*/
|
||||
int reverse_assemble (row_of_memory* memory) ;
|
||||
|
||||
27
submit/lc4_loader.c
Normal file
27
submit/lc4_loader.c
Normal file
@ -0,0 +1,27 @@
|
||||
/************************************************************************/
|
||||
/* File Name : lc4_loader.c */
|
||||
/* Purpose : This file implements the loader (ld) from PennSim */
|
||||
/* It will be called by main() */
|
||||
/* */
|
||||
/* Author(s) : tjf and you */
|
||||
/************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lc4_memory.h"
|
||||
|
||||
/* declarations of functions that must defined in lc4_loader.c */
|
||||
|
||||
FILE* open_file(char* file_name)
|
||||
{
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
int parse_file (FILE* my_obj_file, row_of_memory** memory)
|
||||
|
||||
/* remember to adjust 16-bit values read from the file for endiannness
|
||||
* remember to check return values from fread() and/or fgetc()
|
||||
*/
|
||||
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
32
submit/lc4_loader.h
Normal file
32
submit/lc4_loader.h
Normal file
@ -0,0 +1,32 @@
|
||||
/************************************************************************/
|
||||
/* File Name : lc4_loader.h */
|
||||
/* Purpose : This file declares the functions for lc4_loader.c */
|
||||
/* */
|
||||
/* */
|
||||
/* Author(s) : tjf */
|
||||
/************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lc4_memory.h"
|
||||
|
||||
/* declarations of functions that must defined in lc4_loader.c */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* opens up name of the file passed in, returns a pointer
|
||||
* to the open file
|
||||
*
|
||||
* returns the FILE pointer upon success, else NULL.
|
||||
*/
|
||||
FILE* open_file(char* file_name) ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* parses the given input file into an ordered (by memory address)
|
||||
* linked list with the passed in row_of_memory as the head.
|
||||
*
|
||||
* returns 0 upon successs, non-zero if an error occurs.
|
||||
*/
|
||||
int parse_file (FILE* my_obj_file, row_of_memory** memory) ;
|
||||
94
submit/lc4_memory.c
Normal file
94
submit/lc4_memory.c
Normal file
@ -0,0 +1,94 @@
|
||||
/************************************************************************/
|
||||
/* File Name : lc4_memory.c */
|
||||
/* Purpose : This file implements the linked_list helper functions */
|
||||
/* to manage the LC4 memory */
|
||||
/* */
|
||||
/* Author(s) : tjf and you */
|
||||
/************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lc4_memory.h"
|
||||
|
||||
|
||||
/*
|
||||
* adds a new node to a linked list pointed to by head
|
||||
*/
|
||||
int add_to_list (row_of_memory** head,
|
||||
short unsigned int address,
|
||||
short unsigned int contents)
|
||||
{
|
||||
|
||||
/* check to see if there is already an entry for this address and update the contents. no additional steps required in this case */
|
||||
|
||||
/* allocate memory for a single node */
|
||||
|
||||
/* populate fields in newly allocated node w/ address&contents, NULL for label and assembly */
|
||||
/* do not malloc() storage for label and assembly here - do it in parse_file() and reverse_assemble() */
|
||||
|
||||
/* if *head is NULL, node created is the new head of the list! */
|
||||
|
||||
/* otherwise, insert node into the list in address ascending order */
|
||||
|
||||
/* return 0 for success, -1 if malloc fails */
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* search linked list by address field, returns node if found
|
||||
*/
|
||||
row_of_memory* search_address (row_of_memory* head,
|
||||
short unsigned int address )
|
||||
{
|
||||
/* traverse linked list, searching each node for "address" */
|
||||
|
||||
/* return pointer to node in the list if item is found */
|
||||
|
||||
/* return NULL if list is empty or if "address" isn't found */
|
||||
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
/*
|
||||
* search linked list by opcode field, returns node if found
|
||||
*/
|
||||
row_of_memory* search_opcode (row_of_memory* head,
|
||||
short unsigned int opcode )
|
||||
{
|
||||
/* opcode parameter is in the least significant 4 bits of the short int and ranges from 0-15 */
|
||||
/* see assignment instructions for a detailed description */
|
||||
|
||||
/* traverse linked list until node is found with matching opcode in the most significant 4 bits
|
||||
AND "assembly" field of node is NULL */
|
||||
|
||||
/* return pointer to node in the list if item is found */
|
||||
|
||||
/* return NULL if list is empty or if no matching nodes */
|
||||
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
|
||||
void print_list (row_of_memory* head )
|
||||
{
|
||||
/* make sure head isn't NULL */
|
||||
|
||||
/* print out a header */
|
||||
|
||||
/* traverse linked list, print contents of each node */
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
/*
|
||||
* delete entire linked list
|
||||
*/
|
||||
int delete_list (row_of_memory** head )
|
||||
{
|
||||
/* delete entire list node by node */
|
||||
/* set the list head pointer to NULL upon deletion */
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
43
submit/lc4_memory.h
Normal file
43
submit/lc4_memory.h
Normal file
@ -0,0 +1,43 @@
|
||||
/************************************************************************/
|
||||
/* File Name : lc4_memory.h */
|
||||
/* Purpose : This program contains the structure for the LC4 memory's */
|
||||
/* linked list and the declarations of the helper functions */
|
||||
/* */
|
||||
/* Author(s) : tjf */
|
||||
/************************************************************************/
|
||||
|
||||
#ifndef LC4_MEMORY_H
|
||||
#define LC4_MEMORY_H
|
||||
|
||||
/*
|
||||
* definition of linked list node
|
||||
*/
|
||||
|
||||
typedef struct row_of_memory_struct {
|
||||
short unsigned int address ;
|
||||
char * label ;
|
||||
short unsigned int contents ;
|
||||
char * assembly ;
|
||||
struct row_of_memory_struct *next ;
|
||||
} row_of_memory ;
|
||||
|
||||
|
||||
/*
|
||||
* declaration of linked list helper functions
|
||||
*/
|
||||
|
||||
int add_to_list (row_of_memory** head,
|
||||
short unsigned int address,
|
||||
short unsigned int contents) ;
|
||||
|
||||
row_of_memory* search_address (row_of_memory* head,
|
||||
short unsigned int address ) ;
|
||||
|
||||
row_of_memory* search_opcode (row_of_memory* head,
|
||||
short unsigned int opcode ) ;
|
||||
|
||||
void print_list (row_of_memory* head ) ;
|
||||
|
||||
int delete_list (row_of_memory** head ) ;
|
||||
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user