php hit counter

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cs401
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#3
hey kindly check this out i have no idea about this but it might help u..


I'd like to know what the exact phrasing of the question was.

It looks to me like they want you to sort the arrays first, in which case the two lists will agree.
(Array2 is a jumbled up version of array1.)


First, you need to specify which assembly language. I'm going to assume x86.
Then, you need to specify which assembler you're using: TASM? MASM? GASM? I'm going to assume TASM.
Then, you need to specify whether it is going to be a .COM file, a .EXE file, or a function. I'm going to assume a function called CompareArrays, and the arrays are FIXED, not passed into the function.
Then, you need to specify the target. 32-bit? 16-bit? I'm going to assume 32-bit.
Then, you need to know whether the arrays are arrays of bytes? Words? DoubleWords? I'm going to assume bytes.
Then, you have to say what to do when you FIND the element in Array2. I'm going to assume that you put the index of the element found in Array2 (starting from 0) in a third 10-element array called Result. If it's not found, then the element is -1.

Array1 DB 10,15,20,25,30,35,40,45,50,55
NumArray1 EQU $-Array1
Array2 DB 15,10,20,35,40,30,55,50,25,45
NumArray2 EQU $-Array2
Result DB NumArray1 DUP (-1) ; Pre-initialise to -1 (not found)

CompareArrays PROC

CLD ; Search forwards
MOV CH,OFFSET NumArray1 ; Number of elements to search
MOV EBX,OFFSET Result ; Point to Result
MOV ESI,OFFSET Array1 ; Point to first element of Array1

CompareLoop:
LODSB ; Get first number from ESI into AL
MOV CL,OFFSET NumArray2 ; Number of elements to compare
MOV AH,CL ; Save this away
MOV EDI,OFFSET Array2 ; Compare in Array2

REPNE SCASB ; Scan through array while NOT equal
JNE SHORT NextCompare ; Not found, so skip (already at -1)
SUB AH,CL ; Subtract from original number
DEC AH ; ...less one more for last compare
MOV [EBX],AH ; Save away into Result

NextCompare:
INC EBX ; Point to next Result
DEC CH ; One less to compare
JNZ CompareLoop

RET
CompareArrays ENDP
Source(s):
25 years of x86 assembler programming.

Please note, I haven't tested (or even assembled!) this - but you should get the idea.
Reply


Messages In This Thread
Cs401 - by Anya - 05-09-2010, 07:11 PM
Cs401 - by Anya - 05-09-2010, 07:12 PM
Cs401 - by Awais - 05-09-2010, 08:49 PM
Cs401 - by Anya - 05-10-2010, 08:05 PM
Cs401 - by Awais - 05-10-2010, 09:08 PM
Cs401 - by Anya - 05-11-2010, 01:01 AM
Cs401 - by Guru - 05-11-2010, 01:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  required solution of cs401 assignment No 03.! waqas.aryan786 2 1,567 06-13-2012, 12:37 AM
Last Post: Vuhelper
  cs401 assignment no 3 solution required mc100200446 2 2,758 06-09-2011, 11:22 PM
Last Post: Vuhelper
  CS401 Assignment # 2- Help needed Anya 6 3,714 06-05-2011, 07:22 PM
Last Post: Vuhelper
  cs401 Virtual University Osama Bin laden sanam 5 1,390 05-04-2011, 10:48 AM
Last Post: Xpert
  CS401 assignment no 2 spring 2011 moon13 28 10,363 05-03-2011, 04:18 AM
Last Post: moon13
  Cs401 assignment no 1 spring 13 April 2011 moon13 21 6,200 04-19-2011, 02:29 AM
Last Post: Xpert
  Cs401-assignment no: 05 Anya 3 2,420 02-01-2011, 04:17 PM
Last Post: farahehsan
  CS401 assignment #1 fall 2010 solution required due date 08 Nov2010 falcon 1 3,107 11-28-2010, 03:24 AM
Last Post: Xpert
  CS401 Assignment # 3 Anya 6 3,638 05-26-2010, 04:44 AM
Last Post: viki

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support