Cheat Sheet127 2
Cheat Sheet127 2
• turtle.penup/down( ) - lifts pen up/down (up = draw, down = don’t draw) • == — Equality operator: if both values are equal, returns true. If unequal, returns false
• turtle always starts as (at angle): ➤ • != or <> — Equality operator: if both values are unequal, returns true. If equal, returns false
• += — Addition assignment: x+=3 is the same as x=x+3
add the element to total.
——————
(d) Set total to be zero.
(c) Load data into grid.
MIPS:
#Loop through characters this only prints ‘!’
ADDI $sp, $sp, -100 # Set up stack #Circuit example
ADDI $s3, $zero, 1 # Store 1 in a register
ADDI $t0, $zero, 33 # Set $t0 at 33 (!)
ADDI $s2, $zero, 99 # How many “!” chars are printed
SETUP: SB $t0, 0($sp) # Next letter in $t0
ADDI $sp, $sp, 1 # Increment the stack
SUB $s2, $s2, $s3 # Decrease the counter by 1
BEQ $s2, $zero, DONE # Jump to done if $s0 == 0
J SETUP # If not, jump back to SETUP for loop
DONE: ADDI $t0, $zero, 0 # Null (0) to terminate string
SB $t0, 0($sp) # Add null to stack
ADDI $sp, $sp, -99 # How many “!” chars are printed (not (in1 or in2) and (not in2)) or (((in2 and not in3) or in3) and not in3)
ADDI $v0, $zero, 4 # 4 is for print string
-read the circuit right to left ( to draw)
ADDI $a0, $sp, 0 # Set $a0 to stack pointer for printing
syscall # Print to the log
#Nand circuit
#This program asks the user for the name of a .png (image) file //Population Growth
and displays the upper right quarter of the image
#Import the packages for images and arrays: #include <iostream>
using namespace std;