Modbus protocol over 125 register

Hi guys!
It is my first time and i’m a newbie with Arduino.
I have an Arduino Ethernet and I try to build a modbus slave and publish some values in my memory register:
Here the code:

#include <SPI.h>
#include <Ethernet.h>

#include "Mudbus.h"

Mudbus Mb;
//Function codes 1(read coils), 3(read registers), 5(write coil), 6(write register)
//signed int Mb.R[0 to 125] and bool Mb.C[0 to 128] MB_N_R MB_N_C
//Port 502 (defined in Mudbus.h) MB_PORT

void setup()
  uint8_t mac[]     = { 0x90, 0xA2, 0xDA, 0x0e, 0xd9, 0x45 };
  uint8_t ip[]      = { 192, 168, 100, 220 };
  uint8_t gateway[] = { 192, 168, 100, 254 };
  uint8_t subnet[]  = { 255, 255, 255, 0 };
  Ethernet.begin(mac, ip, gateway, subnet);
  //Avoid pins 4,10,11,12,13 when using ethernet shield
int i;
void loop()
  Mb.R[1] = i;
  analogWrite(6, Mb.R[6]); //pin ~6 from Mb.R[6]


With this code code I’m able to read with modbus master the registry [1] and I can see the variable called “i”.
My question is: Why can I use only 125 registers?
Is it possible to use a SD memory to store my register?

Thank you!!

You just have to modify Mudbus.h. Look for this line

#define MB_N_R 125 //Max 16 bit registers for Modbus is 125

I have not tried extending the size but I have decreased it to conserve memory.