Difference between revisions of "CSC231 Homework 4 Solutions 2014"

From dftwiki3
Jump to: navigation, search
(Problem 3)
 
(6 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
__TOC__
 
__TOC__
 
<br />
 
<br />
 +
<onlydft>
 
=Problem #1=
 
=Problem #1=
 
<br />
 
<br />
Line 84: Line 85:
 
  int 0x80 ;print first letter in cap
 
  int 0x80 ;print first letter in cap
 
 
movzx ecx, byte[byte esi] ;move the integer to ecx
+
        mov  ecx, 0
 +
mov ecx, byte[esi] ;move the integer to ecx
 
dec ecx ;minus the already printed first letter
 
dec ecx ;minus the already printed first letter
 
inc dword[counter]
 
inc dword[counter]
Line 133: Line 135:
 
mov edx, line_len
 
mov edx, line_len
 
push  ecx
 
push  ecx
lea ecx, [newLine]
+
mov ecx, newLine
 
int 0x80
 
int 0x80
 
pop ecx
 
pop ecx
Line 273: Line 275:
 
                 push    ecx
 
                 push    ecx
 
                 mov    eax, dword[counter]
 
                 mov    eax, dword[counter]
 +
                inc    dword[counter] 
 
                 call    printFibMsg
 
                 call    printFibMsg
  
Line 299: Line 302:
 
;;; ; D. Thiebaut
 
;;; ; D. Thiebaut
 
;;; ;
 
;;; ;
;;; ; a description of the Hw4_4
+
;;; ; This program takes a number in eax and prints it in hex
 +
;;; ; on the screen.  The program provides a global function
 +
;;; ; called _printHex.
 
;;; ;
 
;;; ;
 
;;; ; to assemble and run:
 
;;; ; to assemble and run:
Line 305: Line 310:
 
;;; ;    nasm -f elf -F  stabs Hw4_4.asm
 
;;; ;    nasm -f elf -F  stabs Hw4_4.asm
 
;;; ;    ld -melf_i3896 -o Hw4_4 Hw4_4.o
 
;;; ;    ld -melf_i3896 -o Hw4_4 Hw4_4.o
;;; ;    ./program
+
;;; ;    ./Hw4_4
 
;;; ; -------------------------------------------------------------------
 
;;; ; -------------------------------------------------------------------
  
Line 371: Line 376:
 
index          dd      7
 
index          dd      7
 
          
 
          
 +
                section .text
 +
 
_printHex:      push    eax
 
_printHex:      push    eax
 
                 push    ebx
 
                 push    ebx
Line 424: Line 431:
 
</source>
 
</source>
 
<br />
 
<br />
 +
</onlydft>
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
<br />
 +
[[Category:CSC231]][[Category:Homework]]

Latest revision as of 16:06, 30 October 2015

--D. Thiebaut (talk) 16:16, 21 October 2014 (EDT)





...