i have changed my first PHPpage interface but it seem err not like what i want... it's look like so typical web. maybe im too new about this... have to learn and read more and more... ok leave my PHP for a while ...i will explain in my next post bout that.. hehe now. i want to do 3 task with assembly language. this is a quite famaous questions to google for.. believe me. :P no. im not doing this in my nano. im doing this coding using windows. (Microsoft c++ 2010 Express). im just try because i dont know wth of output i can get from the code. Still blur-ing. 6. Fibonacci Numbers Write a program that uses a loop to calculate the first seven values of the Fibonaccinumber sequence,described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n - 1) + Fib(n - 2). Place each value in the EAX register and display it with a call DumpRegsstatement (see Section 3.2) inside the loop.This is the output that i get :: noted :: this is the wrong answer. why .? because the question want the first seven values... but it show you 8 in that output. The answer should be like this. pic below. But the coding must change a bit, you cant start the number from = 0, but = 1 . so the answer for this task is :: 110 1100 7. Arithmetic Expression Write a program that implements the following arithmetic expression: EAX = −val2 + 7 − val3 + val1 Use the following data deļ¬nitions: val1 SDWORD 8 val2 SDWORD -15 val3 SDWORD 20 In comments next to each instruction, write the hexadecimal value of EAX. Insert a call DumpRegsstatement at the end of the program.TITLE Question6 assignment1 (main.asm) ; Description: ; This progam adds and subtracts 32-bit unsigned ; integers and stores the sum in a variable ; Revision date: INCLUDE Irvine32.inc main PROC mov eax,1 call DumpRegs ;1st value call DumpRegs ;2nd value mov ebx,0 ; initial setup mov edx,1 mov ecx,6 ; count L1: mov eax,ebx ; eax = ebx + edx add eax,edx call DumpRegs ; display eax mov ebx,edx mov edx,eax Loop L1 exit main ENDP END mainThis is the output that i get :: ** double checking := −val2 + 7 − val3 + val1 = 15 + 7 - 20 + 8 = 10 8. Copy a String Backwards Write a program using the LOOP instruction with indirect addressing that copies a string from source to target, reversing the character order in the process. Use the following variables: source BYTE "This is the source string",0 target BYTE SIZEOF source DUP('#') Insert the following statements immediately after the loop to display the hexadecimal contents of the target string: movesi,OFFSET target ; offset of variable mov ebx,1 ; byte format movecx,SIZEOF target ; counter callDumpMem If your program works correctly, it will display the following sequence of hexadecimal bytes: 67 6E 69 72 74 73 20 65 63 72 75 6F 73 20 65 68 74 20 73 69 20 73 69 68 54TITLE Question7 assignment1 (main.asm) ; Description: ; This progam adds and subtracts 32-bit unsigned ; integers and stores the sum in a variable ; Revision date: INCLUDE Irvine32.inc .data val1 SDWORd 8 val2 SDWORD -15 val3 SDWORD 20 finalVal SDWORD ? .code main PROC mov eax, val2 neg eax ; eax=-15 add eax, 7; -val2 + 7 mov ebx, val3 add ebx, val1 ; val3+val1 sub eax,ebx mov finalVal, eax call DumpRegs ; display the registers exit main ENDP END mainThis is the output that i get :: the different is... there is extra space in the output compare the answer that already give in the question. to solve this... ** mov esi, (OFFSET source) + (SIZEOF source) - 2 change that 2 to 1. ** mov esi, (OFFSET source) + (SIZEOF source) - (1) then u'll get the output exactly like shown above in the question. :) done. (",)v . got 10 marks for this.TITLE Question8 assignment1 (main.asm) ; Description: ; This progam adds and subtracts 32-bit unsigned ; integers and stores the sum in a variable ; Revision date: INCLUDE Irvine32.inc .data source BYTE " This is the source string", 0 target BYTE SIZEOF source DUP('#') .code main PROC mov esi, (OFFSET source) + (SIZEOF source) - 2 mov edi, OFFSET target mov ecx, SIZEOF source L1: mov al, [esi] mov [edi], al dec esi ; pointer to source string inc edi ; pointer to target string loop L1 mov esi, OFFSET target ; offset of variable mov ebx, 1 ; byte format mov ecx, SIZEOF target-1 ; counter call Dumpmem exit main ENDP END main
Wednesday, December 26, 2012
Assembly Language
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment