CSC231 Homework 1 2017

From dftwiki3
Revision as of 17:42, 16 September 2017 by Thiebaut (talk | contribs) (Created page with "--~~~~ ---- =Problem #1= <br /> Connect to your 231 account, and create this short assembly program, which you can call play1.asm: <br /> ::<source lang="asm"> ;;; ; play1.asm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--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
  1. Assemble, link and run the program. Verify that prints what it should be printing.
  2. Generate a listing file, by using the -l (minus ell)
nasm -f elf -l play1.lst play1.asm

  1. Edit the play1.lst file with emacs, and observe the relationship between the opcodes on the left and the corresponding instructions on the right.
  2. 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.
  3. Assemble, link and run the program. Notice that the output is now different.
  4. Generate a new listing file for the new play1.asm, and see how the opcodes of the two instructions you changed are now different.