StrNCpyAsm, Assembly Language

Assignment Help:
;StrNCpyAsm - copy zero terminated string2 to zero terminated string1,
; but copy no more than count (parameter) characters
; or the length of string2, whichever comes first
; entry: - addStr1 contains the address of string1
; - addStr2 contains the address of string2
; - count contains the max number of characters to copy
; exit: NONE (no return value so do not use edi to return an address)
;
; Note: StrNCpyAsm does not zero terminate the copied string
; unless the 0 is within count characters copied.
;
; example1: char str1[]= {''h'',''e'',''l'',''l'',''o'','' '',''w'',''o'',''r'',''l'',''d'',0};
; char str2[]= {''G'',''o'',''o'',''d'',''-'',''b'',''y'',''e'',0};
; StrNCpyAsm(str1,str2,4);//terminating 0 not copied since only 4 characters copied
; ;//and terminating 0 not within the 4 characters
; after copy str1 contains: ''G'',''o'',''o'',''d'',''o'','' '',''w'',''o'',''r'',''l'',''d'',0
;
; example2: use str1 and str2 from example1
;
; StrNCpyAsm(str1,str2,9); //terminating 0 copied since terminating 0
; //within 9 characters copied
; str1 contains: ''G'',''o'',''o'',''d'',''-'',''b'',''y'',''e'',0,''l'',''d'',0
;
; example3: use str1 and str2 from example1
;
; StrNCpyAsm(str1,str2,20);//copy 20 characters upto and including 0,
; //whichever comes first
; //only 9 characters including 0 copied
; after copy str1 contains: ''G'',''o'',''o'',''d'',''-'',''b'',''y'',''e'',0,''l'',''d'',0
;
; The above is how you would call StrNCpyAsm from C++.
;
; To call StrNCpyAsm from an asm function use:
;
; push 20 ;max num of characters to copy
; push str2Add ;address of string 2
; push str1Add ;address of string 1
; call StrNCpyAsm
; ;no add esp, 12 needed because stack cleaup automatically done
;
;Do not use a loop in this function.
;Choose 2 instructions from the following string instructions to use:
; rep, repe, repne, movsb,stosb,cmpsb,scasb
;
; hint1: use StrLenAsm to get the number of characters in str2
; hint2: the length returned by StrLenAsm does not include terminating 0
; hint3: copy the lesser of the length of the string (including terminating 0)
; or count characters
;copy to ecx the lesser of count or the length of string2 (including terminating 0)
; Please note for the above, you need the length of string2 including terminating 0.
; StrLenAsm returns the length not including terminating 0
;populate esi and edi with the correct values
;clear the direction flag
;use rep and movsb to copy
;
;

StrNCpyAsm PROC uses eax esi edi ecx , ;save registers used
addStr1:DWORD, ;address of string1
addStr2:DWORD, ;address of string2
count:DWORD ;max chars to copy

Related Discussions:- StrNCpyAsm

Dec-micro processor, DEC : A powerful new Alpha 64 bit RISC computer ch...

DEC : A powerful new Alpha 64 bit RISC computer chip was introduced in the year 1977, as new VAX (Virtual Address Extension) Computer. The VAX was 32 bit computer line based on

Assebmly code, You have to write a subroutine (assembly language code using...

You have to write a subroutine (assembly language code using NASM) for the following equation.

16f877 7seg display, do you have experts that know 4 digit 7_Seg dispaly

do you have experts that know 4 digit 7_Seg dispaly

Xml, Write the structure of For…Next loop in VB.Net and also write a progra...

Write the structure of For…Next loop in VB.Net and also write a program to print integers from 1 to 10 on the console.

Program, move a byte string ,16 bytes long from the offset 0200H to 0300H i...

move a byte string ,16 bytes long from the offset 0200H to 0300H in the segment 7000H..

Memory interface-microprocessor, Memory Interface              ...

Memory Interface                                                                  Figure: Memory Modulation design The memory of a computer contain of number of memo

Odd and even numbers, hi, i''m new to assembly language and my teacher told...

hi, i''m new to assembly language and my teacher told us to look for an example of the odd and even numbers program using debug.exe in ms dos as a guide since we just started. plea

Ocw-microprocessor, There are 3 kinds of OCWs. The command word OCWI is u...

There are 3 kinds of OCWs. The command word OCWI is utilized for masking the interrupt requests; when the mask bit corresponding to an interrupt request is value 1, then the requ

String manipulation instruction-microprocessor, String Manipulation Instruc...

String Manipulation Instruction A series of words or data bytes are available in memory at consecutive locations, to be mention to individually or collectively, are known as by

Program, Write a program to separate out positive and negative numbers from...

Write a program to separate out positive and negative numbers from a given series of 16-bit hexadecimal numbers.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd