Initial commit
This commit is contained in:
BIN
Assigments/3/A3.pdf
Normal file
BIN
Assigments/3/A3.pdf
Normal file
Binary file not shown.
38
Assigments/3/A3a.asm
Normal file
38
Assigments/3/A3a.asm
Normal file
@ -0,0 +1,38 @@
|
||||
;first, clean registers
|
||||
;second, load x4002 into a register
|
||||
;third, determine if negative or positive
|
||||
;fourth depending on what it is, add it to memory location
|
||||
;stop when reaching a memory location of zero
|
||||
.ORIG x3000 ;start point
|
||||
|
||||
AND R6, R6, #0 ;clean R6
|
||||
AND R5, R5, #0 ;clean R5
|
||||
AND R4, R4, #0 ;clean R4
|
||||
AND R3, R3, #0 ;clean R3
|
||||
STI R3, NEGATIVEPOS ;clean memory at location
|
||||
STI R3, POSITIVEPOS ;clean memory at location
|
||||
|
||||
|
||||
LOOP LD R6, POSITION ;load position into register
|
||||
ADD R6, R6, #1 ;Add one to register
|
||||
ST R6, POSITION ;Store new value in memory
|
||||
LDI R3, POSITION ;Load from new value
|
||||
ADD R3, R3, #0 ;test for negative
|
||||
BRz DONE ;Halt if result is zero
|
||||
BRn NEGATIVE ;Branch if negative
|
||||
BRp POSITIVE ;branch if positive
|
||||
|
||||
NEGATIVE LDI R4, NEGATIVEPOS ;load negatve total into r4
|
||||
ADD R4, R4, R3 ;add stored value together with new value
|
||||
STI R4, NEGATIVEPOS ;store the new total back to negative total
|
||||
BR LOOP ;loop back
|
||||
|
||||
POSITIVE LDI R5, POSITIVEPOS ;load positive total into r5
|
||||
ADD R5, R5, R3 ;add stored value together with nuew value
|
||||
STI R5, POSITIVEPOS ;store the new total back into positive total
|
||||
BR LOOP ;loop back
|
||||
DONE HALT ;kill program
|
||||
POSITIVEPOS .fill x4000
|
||||
NEGATIVEPOS .fill x4001
|
||||
POSITION .fill x4001
|
||||
.END
|
BIN
Assigments/3/A3a.obj
Normal file
BIN
Assigments/3/A3a.obj
Normal file
Binary file not shown.
42
Assigments/3/A3b.asm
Normal file
42
Assigments/3/A3b.asm
Normal file
@ -0,0 +1,42 @@
|
||||
;clean registers
|
||||
;load starting pos and starting pos +1 into memory
|
||||
;subtract first value (starting pos) from second value (starting pos +1)
|
||||
;if result is negative or zero, write 0 to x4000
|
||||
;if positive, loop back and do the same with the next two memory locations
|
||||
.ORIG x3000 ;start point
|
||||
|
||||
AND R6, R6, #0 ;clean R6
|
||||
AND R5, R5, #0 ;clean R5
|
||||
AND R4, R4, #0 ;clean R4
|
||||
AND R3, R3, #0 ;clean R3
|
||||
|
||||
LOOP LD R6, FIRSTPOS ;block loads first pos into register increments memory value by one and store back
|
||||
ADD R6, R6, #1
|
||||
ST R6, FIRSTPOS
|
||||
|
||||
LD R6, SECONDPOS ;block loads second pos into register increments memory value by one and store back
|
||||
ADD R6, R6, #1
|
||||
ST R6, SECONDPOS
|
||||
|
||||
LDI R3, FIRSTPOS ;load values into memory and then create negative out of it
|
||||
LDI R4, SECONDPOS
|
||||
ADD R4, R4, #0 ;see if the array ends
|
||||
BRz FINISH
|
||||
NOT R3, R3
|
||||
ADD R3, R3, #1
|
||||
|
||||
ADD R5, R3, R4 ;add R3 and R4 into R5
|
||||
BRp LOOP
|
||||
LD R6, ZERO
|
||||
STI R6, RESULT
|
||||
HALT
|
||||
FINISH LD R6, ONE
|
||||
STI R6, RESULT
|
||||
DONE HALT
|
||||
|
||||
FIRSTPOS .fill x4000
|
||||
SECONDPOS .fill x4001
|
||||
RESULT .fill x4000
|
||||
ONE .fill x0001
|
||||
ZERO .fill x0000
|
||||
.END
|
BIN
Assigments/3/A3b.obj
Normal file
BIN
Assigments/3/A3b.obj
Normal file
Binary file not shown.
15
Assigments/3/Example.asm
Normal file
15
Assigments/3/Example.asm
Normal file
@ -0,0 +1,15 @@
|
||||
.ORIG x3000
|
||||
LD R2, ZERO
|
||||
LD R0, M0
|
||||
LD R1, M1
|
||||
LOOP BRz DONE
|
||||
ADD R2, R2, R0
|
||||
ADD R1, R1, #-1
|
||||
BR LOOP
|
||||
DONE ST R2, RESULT
|
||||
HALT
|
||||
RESULT .FILL x0000
|
||||
ZERO .FILL x0000
|
||||
M0 .FILL x0004
|
||||
M1 .FILL x0803
|
||||
.END
|
BIN
Assigments/3/Isaac_Shoebottom_A3.docx
Normal file
BIN
Assigments/3/Isaac_Shoebottom_A3.docx
Normal file
Binary file not shown.
BIN
Assigments/3/Isaac_Shoebottom_A3.pdf
Normal file
BIN
Assigments/3/Isaac_Shoebottom_A3.pdf
Normal file
Binary file not shown.
BIN
Assigments/3/Isaac_Shoebottom_A3.zip
Normal file
BIN
Assigments/3/Isaac_Shoebottom_A3.zip
Normal file
Binary file not shown.
BIN
Assigments/3/Screenshot 2021-10-14 100530.png
Normal file
BIN
Assigments/3/Screenshot 2021-10-14 100530.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
Assigments/3/Screenshot 2021-10-14 100554.png
Normal file
BIN
Assigments/3/Screenshot 2021-10-14 100554.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
Assigments/3/Screenshot 2021-10-14 100753.png
Normal file
BIN
Assigments/3/Screenshot 2021-10-14 100753.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
BIN
Assigments/3/Screenshot 2021-10-14 100813.png
Normal file
BIN
Assigments/3/Screenshot 2021-10-14 100813.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
BIN
Assigments/3/Screenshot 2021-10-14 100838.png
Normal file
BIN
Assigments/3/Screenshot 2021-10-14 100838.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Reference in New Issue
Block a user