what if I want int5 and int3 in some places? (memory addressing and stack 
pointers)

As example here
    
    
    type                                # IoT 16bit
        cell  =  int16
        ucell = uint16
    
    
    Run

I run this bytecode interpreter in 64-bit systems. But I limit the "machine" 
word [u]CELL size to 16bit as it mostly will run in on-air microcontroller 
devices (Lora/NbIoT). There is lot of roaring about the power of rich type 
systems especially in Haskell community 8-) So I thought about using type 
checking in Nim code which will track the type clearance in memory and stacks 
fluffing code.

Next,
    
    
    const                               # memory sizes
        Msz = 0x1000
        Rsz = 0x100
        Dsz = 0x10
    
    
    Run

These constants limit VM memory sizes, they should be mostly the power of two. 
I can limit all registers by applying bitmask on every instruction or stack 
pointer increment. Here the Nim metaprogramming can play by automatically 
insertion addition checking and limiting code.
    
    
    var                                 # memory
        M : array[Msz,byte  ]
        Cp = cell(0)
        Ip = cell(0)
    var                               # data stack
        D : array[Dsz,int16 ]
        Dp = cell(0)
    
    
    
    Run

Reply via email to