johanberntsson / ozmoo

A Z-machine interpreter for the Commodore 64 and similar computers
GNU General Public License v2.0
117 stars 19 forks source link

Incorrect masks in print_vm_map? #39

Closed ZornsLemma closed 3 years ago

ZornsLemma commented 3 years ago

print_vm_map in vmem.asm does:

    lda vmap_z_h,y ; zmachine mem offset ($0 - 
    and #%11100000
    jsr print_byte_as_hex
    jsr space
    jsr dollar
    lda vmap_z_h,y ; zmachine mem offset ($0 - 
    and #%00011111
    jsr printa

I'm not sure those hard-coded ANDs are correct; wouldn't it be better to do something like:

    lda vmap_z_h,y ; zmachine mem offset ($0 - 
    and #$ff xor vmem_highbyte_mask
    jsr print_byte_as_hex
    jsr space
    jsr dollar
    lda vmap_z_h,y ; zmachine mem offset ($0 - 
    and #vmem_highbyte_mask
    jsr printa

In passing, I note that none of the tracing appears to shift the vmapz[hl] bytes one bit to the left to give the "true" Z-address high/mid bytes. Is this deliberate? I could see an argument for not worrying about this - it's debug code, perhaps best to keep it simple - but I thought I'd ask.

johanberntsson commented 3 years ago

Looks like bit rot since it is debug code which we haven't touched for ages. I'll look into this. Thanks for pointing it out.

fredrikr commented 3 years ago

Changed in Ozmoo 8.0.