hoglet67 / PiTubeDirect

Bare-metal Raspberry Pi project that attaches to the Acorn TUBE interface and emulates many BBC Micro Co Processors
GNU General Public License v3.0
187 stars 23 forks source link

Hang on entering commands in COMAL on copro=24 but not copro=0-3 #161

Closed mincebert closed 2 years ago

mincebert commented 2 years ago

This is with hognose-rc5: I don't run COMAL very often so I'm not sure if it was on rc4 or any other previous revision. I don't have the frame buffer enabled on either of these machines.

With copro=24 selected, after starting Acornsoft COMAL with COMAL, type in any command (valid or not) and it hangs, needing a BREAK to recover (the exception seems to be -commands, which work fine) — "NEW" is a simple one. This doesn't, however, happen with copro=0-3, which seem to work fine.

I've tried this on a Model B with a Pi Zero 2 W and an Electron with a Pi 3A+ and both behave the same. This happens straight away after turning on the machine — it doesn't need to be warmed up (just checking as we've been there before).

I've tried unplugging all the ROMs and the problem remains with just BASIC, COMAL and a filing system ROM remaining (doesn't matter which one, but I need one for the Tube Host), including the SWRAM version of MMFS that doesn't raise PAGE.

dp111 commented 2 years ago

Can you provide a link to the version of COMAL you are using ?

On Sat, 4 Jun 2022 at 00:09, Robert Franklin @.***> wrote:

This is with hognose-rc5: I don't run COMAL very often so I'm not sure if it was on rc4 or any other previous revision. I don't have the frame buffer enabled on either of these machines.

With copro=24 selected, after starting Acornsoft COMAL with COMAL, type in any command (valid or not) and it hangs, needing a BREAK to recover (the exception seems to be -commands, which work fine) — "NEW" is a simple one. This doesn't, however, happen with copro=0-3, which seem to work fine.

I've tried this on a Model B with a Pi Zero 2 W and an Electron with a Pi 3A+ and both behave the same. This happens straight away after turning on the machine — it doesn't need to be warmed up (just checking as we've been there before).

I've tried unplugging all the ROMs and the problem remains with just BASIC, COMAL and a filing system ROM remaining (doesn't matter which one, but I need one for the Tube Host), including the SWRAM version of MMFS that doesn't raise PAGE.

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIRUQPLJRZDD7X3FGMTVNKGENANCNFSM5X2NFZYA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

hoglet67 commented 2 years ago

Thanks for testing... this is likely an old issue, because nothing in Co Pro 24 has changed fora while, but we'll take a look.

mincebert commented 2 years ago

I'm using this one: https://mdfs.net/System/ROMs/Language/COMAL/COMAL100 (it doesn't display a version number with *HELP, so I'm guessing there is only one).

I'll try downgrading PiTubeDirect to an earlier hognose rc and see if that changes anything.

Also, to confirm, this is also happening on my Master running MOS 3.50 with a Pi 3A+ and rc5 also.

hoglet67 commented 2 years ago

It happens on Co Pro 24 with all versions of hognose (I tried alpha1, beta1 and rc0)

Just typing HELP and the -> prompt is suffient to hang it.

No clues on the debug console.

Also, it's not a hard crash; the debug console and the VDU continue running (so ARM interrupts are still working fine).

dp111 commented 2 years ago

Just looking at it now

On Sat, 4 Jun 2022 at 10:27, David Banks @.***> wrote:

It happens on Co Pro 24 with all versions of hognose (I tried alpha1, beta1 and rc0)

Just typing HELP and the -> prompt is suffient to hang it.

No clues on the debug console.

Also, it's not a hard crash; the debug console and the VDU continue running (so ARM interrupts are still working fine).

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146576925, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIRCOE2BC4PHSKAKKQTVNMOQPANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

hoglet67 commented 2 years ago

I've generated a trace of of this with the debugger (on Co Pro 16): capture7

It's ~12,000 instructions: comal2.log

I can't immediately spot anything unusual, and there doesn't appear to be any self-modifying code (i.e. all of code is executing from "ROM"), no use of decimal mode, and 6502 instructions only.

It does make use of the (ind, X) addressing mode.

I'll be very interested to hear how you approach debugging this Dominic.

hoglet67 commented 2 years ago

It is using the "bit" instruction to skip the next opcode....

8979 b0 15    bcs 8990
8990 18       clc
8991 24 38    bit 38
8993 60       rts

That's skipping an SEC instruction.

Lots of use of this pattern.

dp111 commented 2 years ago

Here is where I am.

I've enabled jit debugging ( also fixed a bug that had crept into to the debug code)

below is what the JITer is doing once in COMAL then *GO 7FFE ( starts debug output )

HELP

NB the below is only code that hasn't been jitted yet.

tube reset - copro 24 Jit : fa59 : pla Jit : fa5a : sta EE Jit : fa5c : sta F2 Jit : fa5e : pla Jit : fa5f : sta EF Jit : fa61 : sta F3 Jit : fa63 : pla Jit : fa64 : rts Jit : 855f : clc Jit : 8560 : rts Jit : 83bd : jmp 838F Jit : 8b48 : cmp #2E Jit : 8b4a : bne 8B88 Jit : 8b88 : jsr 8C8E Jit : 8c8e : lda (2B),Y Jit : 8c90 : jsr 896B Jit : 896b : cmp #7B Jit : 896d : bcs 8992 Jit : 896f : cmp #61 Jit : 8971 : bcs 8990 Jit : 8973 : cmp #5B Jit : 8975 : bcs 8992 Jit : 8977 : cmp #41 Jit : 8979 : bcs 8990 Jit : 8990 : clc Jit : 8991 : bit 38 Jit : 8993 : rts Jit : 8c93 : bcs 8C99 Jit : 8c95 : ora #20 Jit : 8c97 : sta (2B),Y Jit : 8c99 : rts Jit : 8b8b : sta 67 Jit : 8b8d : bcc 8BD7 Jit : 8bd7 : lda #FD Jit : 8bd9 : sta 6D Jit : 8bdb : lda #7C Jit : 8bdd : sta 29 Jit : 8bdf : lda #87 Jit : 8be1 : sta 2A Jit : 8be3 : ldy #FF Jit : 8be5 : iny Jit : 8be6 : lda (2B),Y Jit : 8be8 : jsr 896B Jit : 8beb : bcs 8BEF Jit : 8bed : and #DF Jit : 8bef : eor (29),Y Jit : 8bf1 : beq 8BE5 Jit : 8bf3 : cmp #80 Jit : 8bf5 : bne 8C3B Jit : 8c3b : lda (2B),Y Jit : 8c3d : cmp #2E Jit : 8c3f : beq 8C07 Jit : 8c41 : dey Jit : 8c42 : iny Jit : 8c43 : lda (29),Y Jit : 8c45 : bpl 8C42 Jit : 8c47 : tya Jit : 8c48 : sec Jit : 8c49 : adc 29 Jit : 8c4b : sta 29 Jit : 8c4d : bcc 8C51 Jit : 8c51 : dec 6D Jit : 8c53 : lda (29,X) Jit : 8c55 : bne 8BE3 Jit : 8c4f : inc 2A Jit : 8c51 : dec 6D Jit : 8c53 : lda (29,X) Jit : 8c55 : bne 8BE3 Jit : 8c57 : ldy #00 Jit : 8c59 : lda 67 Jit : 8c5b : cmp #2F Jit : 8c5d : beq 8C6F Jit : 8c5f : jsr 89C4 Jit : 8c62 : jsr 8C8E Jit : 8c65 : bcc 8C5F Jit : 897b : bcc 8992 Jit : 8c67 : jsr 897D Jit : 897d : jsr 896B Jit : 8980 : bcc 8990 Jit : 8982 : cmp #5F Jit : 8984 : beq 8990 Jit : 8c6a : bcc 8C5F Jit : 8c6c : jmp 8B88 Jit : 8b8f : cmp #2F Jit : 8b91 : beq 8BD7 Jit : 8b93 : cmp #0D Jit : 8b95 : beq 8B61 Jit : 8b97 : cmp #26 Jit : 8b99 : beq 8BB5 Jit : 8b9b : jsr 8986 Jit : 8b9e : bcc 8BC1 Jit : 8ba0 : cmp #2E Jit : 8ba2 : beq 8BC1 Jit : 8ba4 : cmp #22 Jit : 8ba6 : bne 8B83 Jit : 8b83 : jsr 89C4 Jit : 8b86 : ldy #00 Jit : 8b88 : jsr 8C8E Jit : 89c8 : inc 2C Jit : 89ca : lda (2B),Y Jit : 89cc : rts Jit : 8c6f : jmp 8B83 Jit : 8c07 : lda 6D Jit : 8c09 : sta (2B,X) Jit : 8c0b : jsr 8AB2 Jit : 8ab2 : cmp #ED Jit : 8ab4 : beq 8AB8 Jit : 8ab6 : cmp #EE Jit : 8ab8 : rts Jit : 8c0e : bne 8C18 Jit : 8c18 : iny Jit : 8c19 : lda (2B),Y Jit : 8c1b : cmp #20 Jit : 8c1d : beq 8C18 Jit : 8c1f : dey Jit : 8c20 : jsr 89C4 Jit : 8c23 : tya Jit : 8c24 : clc Jit : 8c25 : adc 2B Jit : 8c27 : sta 29 Jit : 8c29 : lda #00 Jit : 8c2b : tay Jit : 8c2c : adc 2C Jit : 8c2e : sta 2A Jit : 8c30 : lda (29),Y Jit : 8c32 : sta (2B),Y Jit : 8c34 : iny Jit : 8c35 : cmp #0D Jit : 8c37 : bne 8C30 Jit : 8c39 : beq 8C72 Jit : 8c72 : dey Jit : 8c73 : lda 6D Jit : 8c75 : cmp #CE Jit : 8c77 : bcc 8C7D Jit : 8c79 : cmp #D5 Jit : 8c7b : bcc 8C88 Jit : 8c7d : cmp #8C Jit : 8c7f : beq 8C8B Jit : 8c81 : cmp #93 Jit : 8c83 : beq 8C8B Jit : 8c85 : jmp 8B86 Jit : 8bf7 : lda (2B),Y Jit : 8bf9 : jsr 897D Jit : 8bfc : bcs 8C07 Jit : 8bfe : iny Jit : 8bff : lda (2B),Y Jit : 8c01 : jsr 897D Jit : 8c04 : dey Jit : 8c05 : bcc 8C43

Then appears to hang.

In the disassembly of COMAL there is quite a lot of ldx #&FF TXS which could perhaps upset things ( the one at &838F) is of interest

On Sat, 4 Jun 2022 at 12:03, David Banks @.***> wrote:

I've generated a trace of of this with the debugger (on Co Pro 16): [image: capture7] https://user-images.githubusercontent.com/1951463/171996164-17328774-0361-4de1-8328-591c8b229d32.png

It's ~12,000 instructions: comal2.log https://github.com/hoglet67/PiTubeDirect/files/8837533/comal2.log

I can't immediately spot anything unusual, and there doesn't appear to be any self-modifying code (i.e. all of code is executing from "ROM").

It does make use of the (ind, X) addressing mode.

I'll be very interested to hear how you approach debugging this Dominic.

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146588708, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIUTCGHLBW6SEHLB5LDVNMZZRANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

hoglet67 commented 2 years ago

What did you type in at the -> prompt?

dp111 commented 2 years ago

*GO 7FFE HELP

On Sat, 4 Jun 2022 at 12:22, David Banks @.***> wrote:

What did you type in at the -> prompt?

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146591170, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIVFKCOGQ7YL657X3WDVNM4AXANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

hoglet67 commented 2 years ago

I understand I need to be careful interpretting your trace, as it represents only the first time each instruction is encountered (when it's jitted).

The first point of divergence looks like:

Jit : 8b8f : cmp #2F
Jit : 8b91 : beq 8BD7
Jit : 8b93 : cmp #0D
Jit : 8b95 : beq 8B61
Jit : 8b97 : cmp [#26]   <<<<< I never hit 8b97
Jit : 8b99 : beq 8BB5
Jit : 8b9b : jsr 8986

My trace (also of HELP) contains 8ab8 (rts) but not 8c0e

8b8f c9 2f    cmp #2F 
8b91 f0 44    beq 8BD7
8b93 c9 0d    cmp #0D
8b95 f0 ca    beq 8B61 <<<<<< I hit this instruction just once
8b61 c6 2c    dec 2C
8b63 e6 2b    inc 2B

I think 8b97 is the first instruction in your trace that isn't present in mine.

hoglet67 commented 2 years ago

Actually, looking right at the start or your trace, there is 855f clc - I never hit this instruction.

Can you get a more complete list of every jitted instruction?

dp111 commented 2 years ago

This is what I did go 7FFE COMAL HELP

these are just address as the disassembly is too slow.

Jit : fa59 Jit : fa5a Jit : fa5c Jit : fa5e Jit : fa5f Jit : fa61 Jit : fa63 Jit : fa64 Jit : 8fae Jit : 8fb0 Jit : 8fb2 Jit : 8fb3 Jit : 8fb4 Jit : 8fb6 Jit : 8fb8 Jit : 8fbb Jit : 8fc1 Jit : 8fc3 Jit : 8fc5 Jit : f9f0 Jit : f9f2 Jit : f9f5 Jit : fa20 Jit : fa22 Jit : fa25 Jit : f9c7 Jit : f9c9 Jit : f9cc Jit : f9ce Jit : f9d0 Jit : f9d3 Jit : f9d4 Jit : f9d6 Jit : f9d8 Jit : f9da Jit : fa28 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fdec Jit : fdef Jit : fdf0 Jit : fa2b Jit : fa2d Jit : 8000 Jit : 8364 Jit : 8366 Jit : 8368 Jit : 836a Jit : 836b Jit : 836d Jit : 836f Jit : 8372 Jit : 8375 Jit : 8377 Jit : 837a Jit : 837b Jit : 837e Jit : 837f Jit : 8381 Jit : 8384 Jit : 8387 Jit : aa41 Jit : aa43 Jit : aa46 Jit : aa48 Jit : aa4a Jit : aa4c Jit : aa4e Jit : aa50 Jit : aa52 Jit : aa54 Jit : aa56 Jit : aa58 Jit : aa5a Jit : aa5c Jit : aa5e Jit : aa5f Jit : aa61 Jit : aa63 Jit : aa65 Jit : aa67 Jit : aa69 Jit : aa6b Jit : aa6d Jit : aa6f Jit : aa71 Jit : aa74 Jit : aaa5 Jit : aaa7 Jit : aaa9 Jit : aaab Jit : aaad Jit : aaaf Jit : aab1 Jit : aab3 Jit : aab5 Jit : aa77 Jit : aa79 Jit : aa7b Jit : aa7d Jit : aa80 Jit : aa82 Jit : aa85 Jit : aa86 Jit : aa88 Jit : aa8a Jit : aa8c Jit : aa8e Jit : aa90 Jit : aa92 Jit : aa94 Jit : aaa2 Jit : a743 Jit : 8f43 Jit : 8f45 Jit : 8f48 Jit : 8f4a Jit : 8f4c Jit : 8f4e Jit : 8f50 Jit : 8f52 Jit : a746 Jit : 8a72 Jit : 8a74 Jit : 8a76 Jit : 8a78 Jit : 8a7a Jit : 8a7b Jit : a749 Jit : a758 Jit : a75a Jit : a75c Jit : a75d Jit : 838a Jit : 838f Jit : 8390 Jit : 8392 Jit : 8393 Jit : 8394 Jit : 8396 Jit : 8398 Jit : fa6b Jit : fa6c Jit : fa6e Jit : fa71 Jit : fa73 Jit : fa76 Jit : fa79 Jit : fa7b Jit : fa7e Jit : fa7f Jit : fa82 Jit : fa84 Jit : fa87 Jit : fa8a Jit : fce9 Jit : fcec Jit : fd0c Jit : fd0f Jit : fd2d Jit : fd2e Jit : fd30 Jit : fd32 Jit : fa8c Jit : fa8f Jit : 839b Jit : 839d Jit : 832d Jit : 832f Jit : 8331 Jit : 8332 Jit : 8334 Jit : 833f Jit : 8341 Jit : 8342 Jit : 8345 Jit : 8346 Jit : 83a0 Jit : 83c6 Jit : 83c7 Jit : 83c9 Jit : 83cb Jit : 83cd Jit : 83cf Jit : 83d1 Jit : 83d3 Jit : 83d5 Jit : 83d8 Jit : 83db Jit : 83dd Jit : 83e0 Jit : 83e1 Jit : 83e4 Jit : 83e6 Jit : 83e9 Jit : 83eb Jit : 83ed Jit : 83ef Jit : 83f1

Jit : 83f4 Jit : 83f6 Jit : 8406 Jit : 83a3 Jit : 83a5 Jit : 83a7 Jit : 8a27 Jit : b308 Jit : b309 Jit : b30b Jit : b30d Jit : b30f Jit : b311 Jit : b313 Jit : b314 Jit : b315 Jit : b316 Jit : 8a2a Jit : 8a2b Jit : 8986 Jit : 8988 Jit : 8992 Jit : 8993 Jit : 8a2e Jit : 8a30 Jit : 8a6f Jit : 83aa Jit : 83b1 Jit : 8407 Jit : 8b28 Jit : 8b17 Jit : 8b19 Jit : 8b1b Jit : 8b1d Jit : 8b1f Jit : 8b21 Jit : 8b22 Jit : 8b23 Jit : 8b25 Jit : 8b27 Jit : 8b2b Jit : 8b2d Jit : 8b2f Jit : 8b31 Jit : 8b33 Jit : 8b40 Jit : 8b42 Jit : 8b44 Jit : 8b46 Jit : 8b48 Jit : 8b4a Jit : 8b88 Jit : 8c8e Jit : 8c90 Jit : 896b Jit : 896d Jit : 896f Jit : 8971 Jit : 8973 Jit : 8975 Jit : 8977 Jit : 8979 Jit : 8990 Jit : 8991 Jit : 8993 Jit : 8c93 Jit : 8c95 Jit : 8c97 Jit : 8c99 Jit : 8b8b Jit : 8b8d Jit : 8bd7 Jit : 8bd9 Jit : 8bdb Jit : 8bdd Jit : 8bdf Jit : 8be1 Jit : 8be3 Jit : 8be5 Jit : 8be6 Jit : 8be8 Jit : 8beb Jit : 8bed Jit : 8bef Jit : 8bf1 Jit : 8bf3 Jit : 8bf5 Jit : 8c3b Jit : 8c3d Jit : 8c3f Jit : 8c41 Jit : 8c42 Jit : 8c43 Jit : 8c45 Jit : 8c47 Jit : 8c48 Jit : 8c49 Jit : 8c4b Jit : 8c4d Jit : 8c51 Jit : 8c53 Jit : 8c55 Jit : 8c4f Jit : 8c51 Jit : 8c53 Jit : 8c55 Jit : 8c57 Jit : 8c59 Jit : 8c5b Jit : 8c5d Jit : 8c5f Jit : 89c4 Jit : 89c6 Jit : 89ca Jit : 89cc Jit : 8c62 Jit : 8c65 Jit : 897b Jit : 8c67 Jit : 897d Jit : 8980 Jit : 8982 Jit : 8984 Jit : 8c6a Jit : 8c6c Jit : 8b8f Jit : 8b91 Jit : 8b93 Jit : 8b95 Jit : 8b97 Jit : 8b99 Jit : 8b9b Jit : 8b9e Jit : 8ba0 Jit : 8ba2 Jit : 8ba4 Jit : 8ba6 Jit : 8b83 Jit : 8b86 Jit : 8b88 Jit : 89c8 Jit : 89ca Jit : 89cc Jit : 8c6f Jit : 8c07 Jit : 8c09 Jit : 8c0b Jit : 8ab2 Jit : 8ab4 Jit : 8ab6 Jit : 8ab8 Jit : 8c0e Jit : 8c18 Jit : 8c19 Jit : 8c1b Jit : 8c1d Jit : 8c1f Jit : 8c20 Jit : 8c23 Jit : 8c24 Jit : 8c25 Jit : 8c27 Jit : 8c29 Jit : 8c2b Jit : 8c2c Jit : 8c2e Jit : 8c30 Jit : 8c32 Jit : 8c34 Jit : 8c35 Jit : 8c37 Jit : 8c39 Jit : 8c72 Jit : 8c73 Jit : 8c75 Jit : 8c77 Jit : 8c79 Jit : 8c7b Jit : 8c7d Jit : 8c7f Jit : 8c81 Jit : 8c83 Jit : 8c85 Jit : 8bf7 Jit : 8bf9 Jit : 8bfc Jit : 8bfe Jit : 8bff Jit : 8c01 Jit : 8c04 Jit : 8c05

On Sat, 4 Jun 2022 at 13:05, David Banks @.***> wrote:

Actually, looking right at the start or your trace, there is 855f clc - I never hit this instruction.

Can you get a more complete list of every jitted instruction?

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146596537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIWCR65UGB66NDPPLMTVNNBAFANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

hoglet67 commented 2 years ago

Here's a reference trace processed to show the first hit of each instruction: ref.txt Here's your trace above: dp11.txt It's useful to diff them with kdiff3.

I think it's safe to ignore differences in the client ROM.

8993 is jitted twice because of the jumping into the middle of a BIT instruction, which I think the jitter handles correctly.

Any idea why 8c51 is jitted twice?

First significant difference is my reference trace includes 898a; yours doesn't. Then soon after there is a lot of divergence.

dp111 commented 2 years ago

Thanks for the traces

8c51 gets jitted twice because the first time there is a jump to 8c51 second time it is 8c4f which flows into 8c51 jitting only stops when a branch /jump/ rts/rti occurs. Its not worth checking if an instruction has already been jitted as it is very to rejit and most of the time rejitting doesn't occur.

On Sat, 4 Jun 2022 at 14:39, David Banks @.***> wrote:

Here's a reference trace processed to show the first hit of each instruction: ref.txt https://github.com/hoglet67/PiTubeDirect/files/8837814/ref.txt Here's your trace above: dp11.txt https://github.com/hoglet67/PiTubeDirect/files/8837815/dp11.txt It's useful to diff them with kdiff3.

I think it's safe to ignore differences in the client ROM.

8993 is jitted twice because of the jumping into the middle of a BIT instruction, which I think the jitter handles correctly.

Any idea why 8c51 is jitted twice?

First significant difference is my reference trace includes 898a; yours doesn't. Then soon after there is a lot of divergence.

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146614026, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIRSLQCGCMDJRFRCAFLVNNMBDANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

hoglet67 commented 2 years ago

Can you force somehow every instruction to be re-jitted, so you then get a complete trace?

dp111 commented 2 years ago

Unfortunately not. When code gets jitted the arm instruction overwrites the table which contains branches to the jitting code

On Sat, 4 Jun 2022 at 14:56, David Banks @.***> wrote:

Can you force somehow every instruction to be re-jitted, so you then get a complete trace?

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146617252, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIWFKEYVAGOYNUEEAZLVNNOAHANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

hoglet67 commented 2 years ago

What about dumping the A, X, Y, S and P in the jit log?

Then we can see when the machine state diverges.

hoglet67 commented 2 years ago

So really the only atypical pattern here is the use of BIT to skip a 1-byte opcode.

Looking at the code I see this TODO flagged:

// Instructions that get used in smaller chunks to save a jump ( overlapping )
// BIT &0000 so B on first byte
// BIT &00 //TODO ?
// NOP6s &0000
// NOP6s &00

Is it possible the Jitter copes with this pattern with BIT but not bit ?

dp111 commented 2 years ago

I think you have it , let me play. I was just adding the start of a debugger.

On Sat, 4 Jun 2022 at 16:02, David Banks @.***> wrote:

So really the only atypical pattern here is the use of BIT to skip a 1-byte opcode.

Looking at the code I see this TODO flagged:

// Instructions that get used in smaller chunks to save a jump ( overlapping ) // BIT &0000 so B on first byte // BIT &00 //TODO ? // NOP6s &0000 // NOP6s &00

Is it possible the Jitter copes with this pattern with BIT but not bit ?

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146629503, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIVGIQVNMFR2MXYOIMLVNNVXLANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

dp111 commented 2 years ago

I've pushed a fix to the indigo branch.

On Sat, 4 Jun 2022 at 16:10, Dominic Plunkett @.***> wrote:

I think you have it , let me play. I was just adding the start of a debugger.

On Sat, 4 Jun 2022 at 16:02, David Banks @.***> wrote:

So really the only atypical pattern here is the use of BIT to skip a 1-byte opcode.

Looking at the code I see this TODO flagged:

// Instructions that get used in smaller chunks to save a jump ( overlapping ) // BIT &0000 so B on first byte // BIT &00 //TODO ? // NOP6s &0000 // NOP6s &00

Is it possible the Jitter copes with this pattern with BIT but not bit ?

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146629503, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIVGIQVNMFR2MXYOIMLVNNVXLANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

hoglet67 commented 2 years ago

I'd really like to include this fix in hognose, because I suspect it's a a pattern used quite widely at Acornsoft.

Looking at the fix on indigo-dev there are changes to JITDEBUG as well as to the BIT instruction. Are they a necessary part of this as well?

Also, there seems to be a mix of #if JITDEBUG and #ifdef JITDEBUG. Is this intentional?

dp111 commented 2 years ago

I think it should be on hognose too.

The JITDEBUG stuff fixes a bug that has been in for a while . also JITDEBUG is now always #if and not #ifdef

On Sat, 4 Jun 2022 at 19:00, David Banks @.***> wrote:

I'd really like to include this fix in hognose, because I suspect it's a a pattern used quite widely at Acornsoft.

Looking at the fix on indigo-dev there are changes to JITDEBUG as well as to the BIT instruction. Are they a necessary part of this as well?

Also, there seems to be a mix of #if JITDEBUG and #ifdef JITDEBUG. Is this intentional?

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146660052, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFIQ6SSYIPIFGKLS5NEDVNOKUHANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

hoglet67 commented 2 years ago

Dominic, I've cherry-picked 26b4bbb4 into hognose-dev and it seems to resolve this issue.

Dormann tests all still pass, and TubeElite runs fine.

Are you happy with that as the fix?

Dave

dp111 commented 2 years ago

I'm happy

On Sun, 5 Jun 2022 at 09:28, David Banks @.***> wrote:

Dominic, I've cherry-picked 26b4bbb https://github.com/hoglet67/PiTubeDirect/commit/26b4bbb42313185e8e26744e29553b92fe819f10 into hognose-dev and it seems to resolve this issue.

Are you happy with that as the fix?

Dave

— Reply to this email directly, view it on GitHub https://github.com/hoglet67/PiTubeDirect/issues/161#issuecomment-1146764267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVVFISNJ2UM5GNCOHCMWQ3VNRQK5ANCNFSM5X2NFZYA . You are receiving this because you commented.Message ID: @.***>

mincebert commented 2 years ago

Thanks -- that seems to have fixed it for me (at least briefly testing)!

As an aside, there appears to be a bug in src/framebuffer/teletext.c at line 298 introduced in commit 1db0a41485bf8ce9b55342953922852abc754132 preventing it from compiling — there's a 'default' in a switch block but without any block after it.

hoglet67 commented 2 years ago

I've just pushed a fix for that compile error.

What version of GCC ARM are you using?

I don't see any errors with 11.2

Dave

mincebert commented 2 years ago

I’m using 10.2.1, compiling on Raspberry Pi OS 11, so a little older. I’ve no idea what the C standard has to say about this — my knowledge of that froze in about 1994!

Anyway it compiles OK now and COMAL seems fine, thanks!

hoglet67 commented 2 years ago

Fix included in Hognose RC6 release.