Você está na página 1de 2

Assignment 1

CMPT 295

Jimmy Tran #301218618

2.

Matz’s Ruby Interpreter or Ruby MRI(also known as CRuby) for Ruby

Cint interpreter for C++

3.a)

N:15, Value:6

N:14, Value:6

N:13, Value:6

N:12, Value:5

N:11, Value:4

N:10, Value:4

N:9, Value:4

N:8, Value:4

N:7, Value:3

N:6, Value:2

N:5, Value:2

N:4, Value:2

N:3, Value:2

N:2, Value:1

N:1, Value:0

N:0, Value:0

3b) Given a sentence, tell me how many letter o’s there are.

3c) Purpose of %rcx is see which character to compare with character with the 0x6f (“o”) .
3d) Goes backwards through str. The loop will repeat itself only if the value in %rcx is less than %rdi
meaning that %rcx should be the number of characters to read starting from the beginning of %rdi.
Within the loop: the call to decq rcx is made leading to the conclusion that the str is being read
backwards.

4)

Mul.s

.globl times

#Multiply two unsigned integers using addition

#The algorithm consists of adding a to the return b times.

times:

#move value 0 into eax or the return

mov $0,%eax

#compare argument in b with 1

#if its less than 1 jump to endloop

#otherwise add edi or argument a to eax

#return to loop

loop:

cmp $1, %esi

jl endloop

add %edi,%eax

dec %esi

jmp loop

#return product of a and b

endloop:

ret

Você também pode gostar