// test some string things
chip "16f84";

area D0`16, foo;

#prefix that = x;

{
  alloc ?foo, { blah=byte, spof=bit };
}

alloc foo, { blah=bit, spof=bit`5 };

{
  {
    nop;
  }

  #prefix this = verbiage\;


  def const xa = 2;
  def ya;
  def ?this#b=2;

  print ?this#b;
  print verbiage\b;
  print that#a;

  code ?this#foo {
    nop;
    print @"!name";
  }

  print that#spaf(2);
  print that#spaf(4);
  mac(1);
  this#mac(2);
  link "this#foo";
}

{
  def localfoo = 5;
  
  nop;
  nop;
  {
    def localfoo = 6;
    
    nop;
    nop;
    nop;
    movlw localfoo;
    movlw ../localfoo;
    print end;
    print ../end;
    print ../../end;
  }
  nop;
  nop;
}
nop;


func xspaf(x)
{
  def const a = 1;
  
  return x*x;
}

{
  macro ?verbiage\mac(x)
  {
    print "second one ", x;
  }
}

def test = struct {
  spoing  = bit`4,
  spoing1 = bit.4`3,
  spoing2 = bit
};

def hufhru = struct {
  spoing = bit`5,
  spoing2 = bit`2,
  @("spoing3") = bit`3,
  spoing4 = bit`2,
  spoing5 = byte
};

def fooze = struct {			// fooze is unbased struct
  spif = bit.0,
  plok = bit.1`4,
  temp = bit`4,
  blah = byte.2`4,
  foo2 = hufhru`2,
  drdr = struct {
    plop = bit`3
  }`2
};

print bits(test);
print test;

print "bytes of hufhru: ", bytes(hufhru);
print " bits of hufhru: ", bits(hufhru);
print " bits of fooze: ", bits(fooze);
print "bytes of hufhru->spoing4: ", bytes(hufhru->spoing4);
print " bits of hufhru->spoing4: ", bits(hufhru->spoing4);
print "bytes of (D4`4)->hufhru->spoing4: ", bytes((D4`4)->hufhru->spoing4);
print " bits of (D4`4)->hufhru->spoing4: ", bits((D4`4)->hufhru->spoing4);

def x = (D40`13)->fooze;		// x is a based struct
def x2 = (D40`bytes(fooze))->fooze;
def y = x->foo2;		// y is a based fooze struct member
def z = x->foo2->spoing4;
def z2 = x->foo2[1]->spoing4;
def z3 = x->temp[1];


def sub1 = x->drdr[0];
def sub2 = x->drdr[1];
def sub3 = x->drdr[2];
def sub4 = x->drdr;

macro mac(x)
{
  print "first one ", x;
}

