Jump to content

CargoCult interpreter


rje
 Share

Recommended Posts

I've started (and stopped) writing a bytecode-interpreted small language for a few years now.  I call the language "Cargo Cult" mainly because it's a cool-sounding name.

But... its specs are kind of hazy.  The bytecode interpreter is bog-standard, but the language it compiles to is fluid: it changes based largely on my whims.

So, what better way to start again than to target an 8 bit architecture, says I.  Forces me into constraints.

Here's kind of what I'm aiming for in CargoCult 1.0.   I *think* the key difference between it and a structured BASIC is the array notation and use, which is more or less borrowed from Perl.  That, and the importance of the newline character in block declarations and endings.

 

fn int buildZones totalSectors, startTrack, @zones
   for |index| 0..@zones.length  
      my track = 1 + GLOBAL.totalTracks + startTrack;
      my sectorCount = @zones[index][1];
      my endTrack = 1 + GLOBAL.totalTracks + @zones[index][0];
     
      GLOBAL.totalTracks += @zones[index][0];
     
      for |jdex| track..endTrack
         GLOBAL.@trackOffset[ jdex ] = totalSectors * 0x100;
         GLOBAL.@sectorOffset[ jdex ] = totalSectors;
         GLOBAL.@sectorsInTrack[ jdex ] = sectorCount;
        
         totalSectors += sectorCount;
      endfor
   endfor
   return totalSectors;
endfn

Edited by rje
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use