; Initialize turtle state ; Set speed to max load r1, 11 ; Syscall code for set_sleep_ticks load r2, r29 ; how many ticks fast to go syscall ; Execute syscall load r1, 9 ; Syscall code for clear_screen syscall ; Clear the screen load r1, 5 ; Syscall code for pen_up syscall ; Execute syscall ; get width load r2, r30 div r2, 2 ; Move to the calculated x position load r1, 1 ; Syscall code for move_forward ; r2 already contains the distance syscall ; Execute syscall ; Turn right by 90 degrees load r1, 4 ; Syscall code for turn_right load r2, 90 ; Angle syscall ; Execute syscall ; get height load r2, r31 sub r2, 150 ; Move to the calculated y position load r1, 1 ; Syscall code for move_forward ; r2 already contains the distance syscall ; Execute syscall ; Turn left by 90 degrees load r1, 3 ; Syscall code for turn_left load r2, 90 ; Angle syscall ; Execute syscall load r1, 6 ; Syscall code for pen_down syscall ; Execute syscall ; Set pen size to 4.0 load r1, 8 ; Syscall code for set_pen_size load r2, 4 ; Pen size syscall ; Execute syscall load r8, 0x0000FF ; Set pen color load r1, 7 ; Syscall code for set_pen_color load r2, r8 ; Color (RGB in hex) syscall ; Execute syscall ; reset speed load r1, 11 ; Syscall code for set_sleep_ticks load r2, 980 ; how fast to go syscall ; Execute syscall ; set up how many times to loop load r5, 8 mul r5, 10 sub r5, 1 loop: ; Move forward by 50 units load r1, 1 ; Syscall code for move_forward load r2, 50 ; Distance syscall ; Execute syscall ; Turn right by 90 degrees load r1, 3 ; Syscall code for turn_left load r2, 90 ; Angle syscall ; Execute syscall ; Move forward by 50 units load r1, 1 ; Syscall code for move_forward load r2, 50 ; Distance syscall ; Execute syscall ; Turn left by 45 degrees load r1, 4 ; Syscall code for turn_right load r2, 45 ; Angle syscall ; Execute syscall ; Move forward by 70 units load r1, 1 ; Syscall code for move_forward load r2, 70 ; Distance syscall ; Execute syscall ; Change pen color dynamically ; Cycle through colors (Red -> Green -> Blue -> Red...) cmp r8, 0xFF0000 ; Compare current color with Red jne @set_green ; If not Red, jump to set Green ; Set Green set_green: cmp r8, 0x00FF00 ; Compare current color with Green jne @set_blue ; If not Green, jump to set Blue load r8, 0x0000FF ; Set color to Blue jmp @apply_color ; Set Blue set_blue: cmp r8, 0x0000FF ; Compare current color with Blue jne @set_red ; If not Blue, jump to set Red load r8, 0xFF0000 ; Set color to Red jmp @apply_color ; Set Red set_red: load r8, 0x00FF00 ; Set color to Green ; Apply the color apply_color: load r1, 7 ; Syscall code for set_pen_color load r2, r8 ; Color (RGB in hex) syscall ; Execute syscall cmp r5, r0 je @end sub r5, 1 jmp @loop end: ; End of program halt ; Stop execution