Vous êtes sur la page 1sur 4

ISLAMIC UNIVERSITY OF GAZA

COMPUTER ENGINEERING DEPARTMENT

ASSEMBLY LANGUAGE
Homework # 3

:INSTRUCTIONS
Show your work (i.e., how you derived your answer or the
.reason behind your thinking) in addition to your answer

.1

Copied Solutions = ZERO .2


Please apply procedures using TASM or MASM Programs .3
Deadline : Tuesday, 17/5/2011 .3

:Student Name

:Student Number

MARK / 10

1. Write a procedure named Str_concat that concatenates a source string to the end of a
target string. Sufficient space must be available in the target string before this
procedure is called. Pass pointers to the source and target strings. Here is a sample
call:
. data
targetStr BYTE "ABCDE", l0 DUP(0)
sourceStr BYTE "FGH",0
.code
INVOKE Str_concat, ADDR_targetStr, ADDR_sourceStr
Solution :

2. Write a procedure named Str_find that searches for the first matching occurrence of a
source string inside a target string and returns the matching position. The input
parameters should be a pointer to the source string and a pointer to the target string. If
a match is found. the procedure sets the Zero flag and EAX points to the matching
position in the target string . Otherwise, the Zero flag is clear. The following code , for
example, searches for "ABC" and returns with EAX pointing to the "A" in the target
string:
.data
Target BYTE "123ABC342432",0
Source BYTE "ABC",0
pos DWORD?
. code
INVOKE Str_find , ADDR_source, ADDR _target
jnz notFound
mov pos, eax
; store t he position value
Solution :

Note:
Please apply procedures using TASM or MASM Programs

With my Best Wishes

Vous aimerez peut-être aussi