CSC231 Exercises with Mov, Arithmetic and Logic Instructions
The Mov Instruction
Assume that we have the following variables declared in the data segment.
section .data
msg1 db "hello world", 10
MSGLEN equ $-msg1
msg2 db " "
msg3 db " "
msg4 db "A man, a plan, a canal, Panama"
MSG3LEN equ $-msg4
msg5 db " "
fib1 db 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233
FIB1LEN equ $-fib1
fib2 db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
fib3 dw 1, 1, 2, 3, 5, 8, 13
FIB3LEN equ ($-fib3)/2
fib4 dw 0, 0, 0, 0, 0 ,0, 0
fib5 dd 1, 1, 2, 3, 5, 8, 13, 23
fib6 dd 0, 0, 0, 0, 0, 0, 0, 0
- Question 1
- Write the instructions necessary to move the contents of msg1 into msg2. Remember: we do not know loops yet, so don't try to use loops.
- Question 2
- Same as Question 1, but into msg3, and this time with as few instructions as possible.
- Question 3
- msg4 is a palyndrome. Reverse it into msg5 with MOV instructions.
- Question 4
- Copy the array fib1 into fib2 with MOV instructions.
- Question 5
- if the array fib1 were one byte longer, what would that byte contain, assuming that it represents the next fibonacci term of the series?
- Question 6
- Copy fib3 into fib4
- Question 7
- Copy fib5 into fib6