Your assigment has to be submitted electronically by midnight (i.e., 11:59 PM) on the due date to he e-mail address cs333 [at] cs.jhu.edu. Very important: Include in the subject your name and programming assignment number.
Notes:
Additional resources:
Questions
Questions
Questions
main () {
int i;
for (i=1;i<=10;i=i+1)
printf ("%d\n",i);
}
|
main () {
int i;
printf ("Input a number: ");
scanf ("%d",i)
if (i%2==0)
printf ("your number is: 2*%d\n",i/2);
else
printf ("your number is: 2*%d+1\n",i/2);
}
|
main () {
int i,s;
s=0;
while (s<10) {
printf ("Input a number: ");
scanf ("%d",i)
s=s+i;
}
}
|
Questions:
Questions
.data
message: .asciiz "...and the result is: "
.text
.globl main
main:
la $4, message
li $v0, 4
syscall
nop
move $20, $zero
move $17, $0
loop: slti $18, $17, 10
beq $18, $0, end_lop
mul $20, $20, $17
add $17, $17, 1
j loop
nop
end_lop: move $4, $20
li $v0,1
syscall
_exit:
li $v0,10
syscall
Questions
.data
message: .asciiz "Welcome to the world of MIPS programming\n"
message2: .asciiz "Iteration: "
message3: .asciiz "\n"
first: .word 21
.word 14
.word 26
.word 39
.text
.globl main
_start:
main:
la $4, message
jal putstr
nop
la $16, first
ori $20, 0x0
move $17, $0
loop:slt $18, $17, 0x03
beq $18, $0, end_lop
nop
lw $19, 0($16)
nop
add $20, $20, $19
add $16, $16, 0x4
addi $17, $17, 1
la $4, message2
jal putstr
nop
move $4, $17
jal writeint
nop
la $4, message3
jal putstr
nop
j loop
nop
end_lop: move $4, $20
jal writeint
j _exit
nop
Questions