when to use memset function

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
JWinters
Posts: 106
Joined: Mon Feb 04, 2008 4:56 pm
Location: North Carolina, USA
Contact:

when to use memset function

Post by JWinters » Sat Mar 28, 2009 10:16 pm

I'm not sure if anyone will be able to answer this, but I'll ask anyway.

I use the TCP/IP stack that David ported over for the ENC28J60. It makes extensive use of structures and unions.

I've noticed in the NETUtils.bas module, there is a routine called memset which appears to set a variable with a value.

When am I supposed to use memset as opposed to just setting the variable with the normal X=Y type statement?

There seems to be a difference. I was tweaking some code in the DHCP module and using X=Y to set the remote IP address didn't work. However, using memset did work.

Here is the code for memset in case you are curious:

Code: Select all

Public Sub memset(pAddress As Word, pValue As Byte, pSize As Word)
   FSR0 = pAddress
   While pSize > 0
      POSTINC0 = pValue
      Dec(pSize)
   Wend
End Sub

User avatar
JWinters
Posts: 106
Joined: Mon Feb 04, 2008 4:56 pm
Location: North Carolina, USA
Contact:

Post by JWinters » Sun Aug 30, 2009 3:48 pm

I understand now.... memset is for setting the RAM directly from a pointer.

Post Reply