CSC231 Homework 1 2017
--D. Thiebaut (talk) 17:42, 16 September 2017 (EDT)
Problem #1
Connect to your 231 account, and create this short assembly program, which you can call play1.asm:
;;; ; play1.asm ;;; ; program for Homework 1 ;;; ; ------------------------------------------------------------------- ;;; ------------------------------------------------------------ ;;; data areas ;;; ------------------------------------------------------------ section .data msg1 db "Homework 1", 10 msgLen equ $-msg1 ;;; ------------------------------------------------------------ ;;; code area ;;; ------------------------------------------------------------ section .text global _start _start: mov eax, 4 mov ebx, 1 mov ecx, msg1 mov edx, msgLen int 0x80 ;;; exit() mov eax,1 mov ebx,0 int 0x80 ; final system call
- Assemble, link and run the program. Verify that prints what it should be printing.
- Generate a listing file, by using the -l (minus ell)
nasm -f elf -l play1.lst play1.asm
- Edit the play1.lst file with emacs, and observe the relationship between the opcodes on the left and the corresponding instructions on the right.
- Go back to the play1.asm and change the mov ecx, msg1 line to mov ecx, msg1+4, and change the mov edx, msgLen to mov edx, 5.
- Assemble, link and run the program. Notice that the output is now different.
- Generate a new listing file for the new play1.asm, and see how the opcodes of the two instructions you changed are now different.