-
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.
-Fixed xor -Made program auto read from given file name -Made registers print after instruction completes -Made debug mode print instruction address -Made bouncing ball example script -Made assembler flip unsigned to signed values for LDI instructions -Made assembler clone missing operands if necessary -Fixed extra lines being counted when removing function names
- Loading branch information
1 parent
ea9fb60
commit e438acd
Showing
8 changed files
with
490 additions
and
38 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
Sample script sets/Bouncing Ball/DO NOT USE/Bouncing Ball Example
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,55 @@ | ||
# Initialization | ||
CAL init | ||
loop: | ||
CAL update # Update ball position and check for collisions | ||
CAL draw # Draw the ball on the screen | ||
JMP loop # Repeat the loop | ||
# Subroutine to initialize variables | ||
init: | ||
LDI 0 0 # Set initial X position | ||
LDI 1 10 # Set initial Y position | ||
LDI 2 1 # Set X velocity (positive for rightward movement) | ||
LDI 3 1 # Set Y velocity (positive for downward movement) | ||
RTN | ||
# Subroutine to update ball position and check for collisions | ||
update: | ||
ADD 0 0 2 # Update X position based on X velocity | ||
ADD 1 1 3 # Update Y position based on Y velocity | ||
|
||
# Check for X boundary collision (assuming screen width of 256) | ||
LDI 4 255 # Load maximum X value (255 for 8-bit screen width) | ||
CMP 0 4 # Compare current X with maximum X | ||
JIZ 0 right_bounce # Jump to right_bounce if X is at the edge | ||
|
||
LDI 4 0 # Load minimum X value (0) | ||
CMP 0 4 # Compare current X with minimum X | ||
JIZ 0 left_bounce # Jump to left_bounce if X is at the edge | ||
|
||
# Check for Y boundary collision (assuming screen height of 256) | ||
LDI 4 255 # Load maximum Y value (255 for 8-bit screen height) | ||
CMP 1 4 # Compare current Y with maximum Y | ||
JIZ 0 bottom_bounce# Jump to bottom_bounce if Y is at the edge | ||
|
||
LDI 4 0 # Load minimum Y value (0) | ||
CMP 1 4 # Compare current Y with minimum Y | ||
JIZ 0 top_bounce # Jump to top_bounce if Y is at the edge | ||
RTN | ||
# Subroutines to handle bouncing on each edge | ||
right_bounce: | ||
LDI 2 -1 # Reverse X velocity | ||
RTN | ||
left_bounce: | ||
LDI 2 1 # Reverse X velocity | ||
RTN | ||
bottom_bounce: | ||
LDI 3 -1 # Reverse Y velocity | ||
RTN | ||
top_bounce: | ||
LDI 3 1 # Reverse Y velocity | ||
RTN | ||
# Subroutine to draw the ball on the screen | ||
draw: | ||
SPD 0 2 # Set X coordinate for pixel | ||
SPD 1 4 # Set Y coordinate for pixel | ||
SPD 255 0 # Set pixel color to white (assuming 255 is white) | ||
RTN |
111 changes: 111 additions & 0 deletions
111
Sample script sets/Bouncing Ball/DO NOT USE/Instructions UncompiledOld
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,111 @@ | ||
xpos = 0 | ||
ypos = 1 | ||
xvel = 2 | ||
yvel = 3 | ||
r4 = 4 | ||
rSP = 5 | ||
rFlags = 6 | ||
rPC = 7 | ||
|
||
r_col = 0 | ||
g_col = 1 | ||
b_col = 2 | ||
x_prop = 3 | ||
y_prop = 4 | ||
setpixel = 5 | ||
|
||
on = -1 | ||
off = 0 | ||
|
||
init: | ||
ldi xpos 1 # inital x pos | ||
ldi ypos 10 # initial y pos | ||
ldi xvel 1 # initial x vel | ||
ldi yvel 1 # initial y vel | ||
|
||
ldi r4 on # setting color | ||
spd r4 r_col | ||
spd r4 g_col | ||
spd r4 b_col | ||
cal display | ||
|
||
loop: | ||
cal update | ||
cal display | ||
jmp loop | ||
update: | ||
# x velocity | ||
ldi r4 1 # checking for right movement | ||
xor r4 xvel r4 | ||
jiz r4 increase_x | ||
breakpointE: | ||
ldi r4 -1 # checking for left movement | ||
xor r4 xvel r4 | ||
jiz r4 decrease_x | ||
breakpointF: | ||
# y velocity | ||
ldi r4 1 # checking for up movement | ||
xor r4 yvel r4 | ||
jiz r4 increase_y | ||
breakpointG: | ||
ldi r4 -1 # checking for down movement | ||
xor r4 yvel r4 | ||
jiz r4 decrease_y | ||
breakpointH: | ||
rtn | ||
ldi r4 -1 # for right wall collision | ||
xor r4 xpos r4 | ||
jiz r4 right_bounce | ||
breakpointA: | ||
ldi r4 0 # for left wall | ||
xor r4 xpos r4 | ||
jiz r4 left_bounce | ||
breakpointB: | ||
ldi r4 -1 # for top wall | ||
xor r4 ypos r4 | ||
jiz r4 top_bounce | ||
breakpointC: | ||
ldi r4 1 # for bottom wall | ||
xor r4 ypos r4 | ||
jiz r4 bottom_bounce | ||
breakpointD: | ||
rtn | ||
|
||
right_bounce: | ||
ldi xvel -1 | ||
jmp breakpointA | ||
|
||
left_bounce: | ||
ldi xvel 1 | ||
jmp breakpointB | ||
|
||
top_bounce: | ||
ldi yvel -1 | ||
jmp breakpointC | ||
|
||
bottom_bounce: | ||
ldi yvel 1 | ||
jmp breakpointD | ||
|
||
increase_x: | ||
inc xpos xpos | ||
jmp breakpointE | ||
|
||
decrease_x: | ||
dec xpos xpos | ||
jmp breakpointF | ||
|
||
increase_y: | ||
inc ypos ypos | ||
jmp breakpointG | ||
|
||
decrease_y: | ||
dec ypos ypos | ||
jmp breakpointH | ||
|
||
|
||
display: | ||
spd xpos x_prop | ||
spd ypos y_prop | ||
spd 0 setpixel | ||
rtn |
Oops, something went wrong.