16.3. Asserting code

The assert directive has a second form which makes it possible to compare pieces of assembled code:

.assert "Test2", { lda $1000 }, {ldx $1000}

.assert "Test", {
    .for (var i=0; i<4; i++)
        sta $0400+i
}, {
    sta $0400
    sta $0401
    sta $0402
    sta $0403
}

The assert directive will give an ok or failed message and the assembled result as output. The output of the above example is as follows:

  Test1 – FAILED! | 2000:ad,00,10  -- 2000:ae,00,10
  Test2 – OK. | 2000:8d,00,04,8d,01,04,8d,02,04,8d,03,04