1
1
הנבמ םיבשחמ
ta6
2006 Amar Lior
Based on lectures notes from Arie Schlesinger (aries@cs.columbia.edu)
Adapted from Computer Organization&Design, H/S interface, Patterson Hennessy@UCB,1999 2
Communicating with People
As soon as computers became commercial
they were used to process text
Most use 8-bit bytes to represent characters Using the American Standard Code for
Information Interchange (ASCII)
MIPS provide instructions to move bytes
lb $t0, 0($sp)
# Read byte from source
sb $t0, 0($gp)
# Write byte to destination
3
Strcpy example
strcpy: addi $sp, $sp, -4 sw $s0, 0($sp) add $s0, $zero, $zero L1: add $t1, $s0, $a1 lb $t2, 0($t1) add $t3, $s0, $a0 sb $t2, 0($t3) beq $t2, $zero, L2 addi $s0, $s0, 1 j L1 L2: lw $s0, 0($sp) addi $sp, $sp, 4 jr $ra
void strcpy (char x[], char y[]) { int i; i=0; while ((x[i] = y[i]) != ‘\0’) i++; }