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

Code for reading flow & generating serial output, Assembly Code for Reading...

Assembly Code for Reading Flow & Generating Serial Output The timer is timer 1 is set for the baud rate 9600, as the crystal used is of 11.0592 Hz.  Then the timer 1 is starte

Implement an assembly language program, A good starting point for your prog...

A good starting point for your program is the toupper.asm program shown in class. It already queries the user for input and sets up a loop that looks at each character of the input

Debug-microprocessor, Using DEBUG DEBUG.COM is a DOS efficacy that faci...

Using DEBUG DEBUG.COM is a DOS efficacy that facilitates the trouble-shooting and debugging of assembly language programs. In particular case of personal computers, all of th

Cmp-arithmetic instruction-microprocessor, CMP: Compare: - This instructio...

CMP: Compare: - This instruction compares the source operand, which can be a register or memory location an immediate data with a destination operand that might be a register or a

Hand shaking-microprocessor, Hand shaking : Handshaking, or 2-way hand...

Hand shaking : Handshaking, or 2-way handshaking, is 1 type of strobe operation. It typically involves 2 handshaking lines: an output line to denote when the board is ready an

Lods-stos-string manipulating instruction-microprocessor, LODS : Load Stri...

LODS : Load String Byte or String Word:- The LODS instruction loads AL/AX register by the content of a string pointed to by DS:SI register pair. The SI is automatically modifie

Third generation microprocessor, III rd Generation Microprocessor: T...

III rd Generation Microprocessor: The single 3rd generation microprocessor chip having 64-pins began with the introduction of 16-bit Intel 8086 in 1978. The other essential

Program, assembly language program to find larges number in an array

assembly language program to find larges number in an array

Flag manipulation and processor control instructions , Flag Manipulation an...

Flag Manipulation and Processor Control Instructions These instructions control the functioning of available hardware inside the processor chip. These are categorized into thes

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