CSC231 Mini Lab 1 Solution and Discussion

From dftwiki3
Revision as of 08:40, 12 September 2012 by Thiebaut (talk | contribs) (Solution 2)
Jump to: navigation, search

--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