Computer Organization, C++
;;;for the message below, put your first initial and last name with no spaces #msg aconfer ; define a variable called "THROTTLE" ; define a variable called "FORWARD_STEER" ; set THROTTLE to 100 ; set FORWARD_STEER to 0 ; create a label called "main" here ;;; Check to see whether we're moving forward, backward, or are stuck ; ipunt from the spedometer port to register ax ; compare ax to 0 ; if ax > 0, jmp to "!moving_forward" ; if ax < 0, jmp to "!moving_backward" ;;; Yikes! We're not moving... better get going ; add 32 to FORWARD_STEER ; use the steering port to turn FORWARD_STEER degrees ; delay for 25 cycles ; negate THROTTLE ; send THROTTLE to the throttle port ; jump back up to main ; create a label called "moving_forward" here ;;; steer a random amount between -15 and +15 degrees ; get a random number from the random port into the ax register ; perform a bitwise AND on ax with the hex value 001fh ; subtract 15 from ax ; steer ax degrees with the steering port ; jump back up to the "!main" label ; create a label called "moving_backward" here ;;; loop 5 times shooting and turning before going forward again ; set the cx register to 5 ; create a label called "do_bw" here ; send 0 to the weapon port to shoot straight ahead ; steer 16 degrees with the steering port ; delay for 10 cycles ; decrement the cx register ; compare the cx register to 0 ; if cx > 0, jump to "!do_bw" ; negate THROTTLE ; stop by sending 0 to the throttle port ; jump back up to the "!main" label