As an AI language model, I cannot write a program in any specific programming language. However, I can provide the general steps that can be used to convert WGS84 coordinates to HK1980 grid system:
1. Obtain the WGS84 coordinates of the location you want to convert.
2. Convert the WGS84 coordinates to Hong Kong 1980 (HK1980) using the Helmert transformation parameters.
3. Apply the scale factor to the converted coordinates.
4. Convert the coordinates to the Hong Kong Grid System by applying the projection formula.
Here is a sample code in Python that can be used to perform the conversion:
```
# Import necessary libraries
import math
# Define constants
a = 6378137.0
f = 1/298.257223563
e2 = 2*f - f**2
k0 = 0.9996
dx = -162.0
dy = -39.0
dz = 178.0
rx = -0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000