Difference between revisions of "CSC231 Mini Lab 1 Solution and Discussion"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- =Solution 1= <br /> <source lang="asm"> ;;; minilab1.asm ;;; D. Thiebaut ;;; prints this string on the screen: ;;; ;;; ********************************* ;;; * ...")
 
(Solution 2)
Line 45: Line 45:
 
<source lang="asm">
 
<source lang="asm">
  
;;; minilab1.asm
+
;;; minilab1_v1.asm
 
;;; D. Thiebaut
 
;;; D. Thiebaut
 
;;; prints this string on the screen:
 
;;; prints this string on the screen:
Line 89: Line 89:
  
 
<br />
 
<br />
 +
=What is the trade-off?=
  
 +
* Generate the listing of the assembly:
 +
 +
      nasm -f elf -F stabs minilab1_v1
 
<br />
 
<br />
  

Revision as of 08:40, 12 September 2012

--D. Thiebaut 09:38, 12 September 2012 (EDT)


Solution 1


;;; minilab1.asm
;;; D. Thiebaut
;;; prints this string on the screen:
;;;
;;; 	*********************************
;;;     * Welcome to CSC231             *
;;;     * Home of the Assembly Language *
;;;     *********************************


	section	.data

msg	db	"*********************************", 10
	db	"* Welcome to CSC231             *", 10
	db	"* Home of the Assembly Language *", 10	
	db	"*********************************", 10, 10
	
msgLen	equ	$-msg

	section	.text
	global	_start
_start:
	mov	eax,4
	mov	ebx,1
	mov	ecx,msg
	mov	edx,msgLen
	int	0x80

;;; exit
	mov	eax,1
	mov	ebx,0
	int	0x80


Solution 2


;;; minilab1_v1.asm
;;; D. Thiebaut
;;; prints this string on the screen:
;;;
;;; 	*********************************
;;;     * Welcome to CSC231             *
;;;     * Home of the Assembly Language *
;;;     *********************************


	section	.data

msg	db	"*********************************", 10
msgLen1	equ	$-msg	
	db	"* Welcome to CSC231             *", 10
	db	"* Home of the Assembly Language *", 10	
msgLen2	equ	$-msg
	
	section	.text
	global	_start
_start:
	
;;; print first 3 lines
	mov	eax,4
	mov	ebx,1
	mov	ecx,msg
	mov	edx,msgLen2
	int	0x80

;;; print first line back, to close box
	mov	eax,4
	mov	ebx,1
	mov	ecx,msg
	mov	edx,msgLen1
	int	0x80

;;; exit
	mov	eax,1
	mov	ebx,0
	int	0x80



What is the trade-off?

  • Generate the listing of the assembly:
      nasm -f elf -F stabs minilab1_v1