DEV Community

Charles Anthony
Charles Anthony

Posted on

2024-01-23 Debugging ZIP

The division problem above was caused by an error in TIL; in D/MOD the line

mov1:     ld      d,a     ; store divisor
Enter fullscreen mode Exit fullscreen mode

Should be

mov1:     ld      e,a     ; store divisor
Enter fullscreen mode Exit fullscreen mode

This sets up the arguments to $UD/ correctly, resulting in a correct division.

Now ZIP can print numbers:

    DP .
Enter fullscreen mode Exit fullscreen mode

yields

   FA  OK
Enter fullscreen mode Exit fullscreen mode
  DP @ .
Enter fullscreen mode Exit fullscreen mode

yields

   C4F OK
Enter fullscreen mode Exit fullscreen mode

Started in on the number interpreter….

Debugging revealed a couple of transcription errors, and a assembly dialect issue:

Where TIL codes “ADC  A”, z80asm needs “ADC   A,A”, otherwise it assembles an “ADC  A,IXL” instruction.

Now zip can

   1000 . 
Enter fullscreen mode Exit fullscreen mode

yielding

   1000 OK
Enter fullscreen mode Exit fullscreen mode

ZIP is printing a garbage character at the end of the “.” string. TIL pushes a space character with the high bit set as an end-of-string marker. I suspect that on Loeliger’s system the terminal ignored the high bit and printed an ordinary space. I am adding a bit of code to clear the high bit.

Works:

   !    C!    @   C@   
Enter fullscreen mode Exit fullscreen mode
1 2 + 
0 OK
Enter fullscreen mode Exit fullscreen mode

Plus not working.

plus:   dw      $+2     
        pop     hl      ; get first word
        pop     de      ; get second word
        add     hl,de   ; add them
        push    hl      ; push sum
        nxt   
Enter fullscreen mode Exit fullscreen mode

That sure looks ok

Heh.  I traced “1 2 + .” and it never executed that code.  I made a typo; the “=” keyword has an incorrect entry “+”.

Ok, + works.

1 2 + .                3  OK
Enter fullscreen mode Exit fullscreen mode
2000 @ .              0  OK
1234 2000 ! 2000 @ .                1234  OK
56 2000 C!  2000 @ .                1256  OK
2000 C@ .                            56  OK
2000 @ . 10 2000 +! 2000 @ .           1256 1266  OK
Enter fullscreen mode Exit fullscreen mode

+! works

DP @ .                            C52  OK
1234 ,  DP @ .                
Enter fullscreen mode Exit fullscreen mode

Crash….  comma not working.

Transcription error; forgot the nxt.

DP @ .                C54  OK
1234 , DP @ .          C56  OK
C54 @ .               1234  OK
Enter fullscreen mode Exit fullscreen mode

comma works

2 1 - .              -1  OK
Enter fullscreen mode Exit fullscreen mode

That’s wrong…

Typo in -1

   db 1, “-1 “
Enter fullscreen mode Exit fullscreen mode

should be

   db 2,”-1”
Enter fullscreen mode Exit fullscreen mode
2 1 - .           1  OK
1 2 - .            -1  OK
-1 .  -1  OK
Enter fullscreen mode Exit fullscreen mode

minus works

1 0= .               0  OK
0 0= .                1  OK
-1 0= .             0  OK
8000 0= .            0  OK
Enter fullscreen mode Exit fullscreen mode

0=  works.

1 2+ . 3  OK
Enter fullscreen mode Exit fullscreen mode

2+ works

1 ABS .          1  OK
-1 ABS .         1  OK

0 ASCII .         30  OK
F ASCII .          46  OK

ASPACE .          20  OK

BASE @ . 10  OK

12 C,       crash
Enter fullscreen mode Exit fullscreen mode

Forgot nxt

DP @ .          C56  OK
DP @ C@ .        2  OK
12 C, C56 C@ .    12  OK
Enter fullscreen mode Exit fullscreen mode

C, works

1234 2000 !  2000 C0SET 2000 @ .             1200  OK
Enter fullscreen mode Exit fullscreen mode

C0SET works

Skipping CA!

3 CCONSTANT 3 
`
RESTART
Enter fullscreen mode Exit fullscreen mode

Not good.

CREATE FOO      
RESTART
Enter fullscreen mode Exit fullscreen mode

The problem seems to be in CREATE.

Forgot the trailing semi

CREATE FOO  OK
3 CCONSTANT FOO  OK
FOO . 
FOO ?
DP @ .                 C58  OK
3 CCONSTANT FOO               OK
C58 C@ .                      3  OK
C59 C@ .                      46  OK
C5A C@ .                      4F  OK
C5B C@ .                      4F  OK
FOO 
FOO ?
Enter fullscreen mode Exit fullscreen mode

It is building the dictionary entry correctly, but not finding it.  Almost certainly a problem in the vocabulary words.

CURRENT @ .   A11  OK
Enter fullscreen mode Exit fullscreen mode
0a11 3c                         inc     a       ; else bump high
Enter fullscreen mode Exit fullscreen mode

That’s not right.

CURRENT . 0  OK
Enter fullscreen mode Exit fullscreen mode

Ahh. Not initialized?

Ahh. SYS needs to be page aligned.

CURRENT .           10E  OK
CURRENT @ .         9AF  OK
3 CCONSTANT FOO     OK
FOO .               3  OK
Enter fullscreen mode Exit fullscreen mode

Skipping COMPILER, CORE, CONTEXT, CURRENT, DOES>

(Can’t test DOES> without <BUILDS)

1 2 DROP .    1  OK
3 DUP . .        3 3  OK
ENTRY .    
ENTRY ?
Enter fullscreen mode Exit fullscreen mode

Typo; length byte wrong.

ENTRY .      C46  OK
HERE .      C58  OK
LBP .        
LBP ?
Enter fullscreen mode Exit fullscreen mode

Length byte wrong

LBP .       104  OK
1 2 OVER . . .       1 2 1  OK
Enter fullscreen mode Exit fullscreen mode

Skipping R>

 

1 2 SWAP . .         1 2  OK
Enter fullscreen mode Exit fullscreen mode

Skipping VOCABULAARY

That’s all of the defined words.

Added tick; crashes.

aspace token dp    OK
context @ @ search     OK
. 0  OK
. 
Enter fullscreen mode Exit fullscreen mode

Hangs when the address is printed??

Back jump address in *END

' dp .             A9E  OK
Enter fullscreen mode Exit fullscreen mode

Committed and pushed.

Added *

But:

zip.l.asm:841: error: `,' expected. Remainder of line: _uds ; multiply 16x8 

        call    _isign  ; field input signs
        call    p_uds   ; multiply 16x8
        call    _posign ; Justify result
Enter fullscreen mode Exit fullscreen mode

I have no idea what it is complaining about

Huh. no embedded underscores…  Ok when defined, fail when referenced… only when referenced by call; jumping to them is okay.

2 2 * . 4  OK
Enter fullscreen mode Exit fullscreen mode

Added

*+LOOP
*/
*/MOD
*C+LOOP
*CDO
*CLEAVE
*CLOOP
*DO
*LEAVE
*LOOP
Enter fullscreen mode Exit fullscreen mode

Top comments (0)