8bitworkshop icon indicating copy to clipboard operation
8bitworkshop copied to clipboard

Workshop crashes editing 6502 assembly code, can't resume editing

Open sellam-i opened this issue 2 years ago • 4 comments

I'm having a weird problem. I don't think it's a local issue.

I have some 6502 assembly code I'm editing. I added a label called "Slot:". Right after I entered this, the environment crashed (the browser tab process crashes and Brave Browser is reporting a SIGILL signal received).

If I try to refresh the browser page with either an F5 or CTRL-F5 it brings the environment back up, looks like it's processing something, then goes right back to crashing again.

I'm stumped. Any ideas?

Sellam

sellam-i avatar Jul 10 '23 02:07 sellam-i

Very strange ... must be a bug in Brave. You can edit the browser URL to point to a new file (e.g. https://8bitworkshop.com/vx.y.z/?file=<something.else>") to temporarily work around the bug. If you want to recover your files, easiest way is to use "File | Download All Changes as ZIP")

sehugg avatar Jul 12 '23 16:07 sehugg

I think I figured out what is causing the crash.

I snipped the relevant code below. I had an identifier, "STRINGS", that wasn't associated with anything yet. The parser seems to be trying to find something not there, as the label ends without defining anything (yet). Once I removed that, I was able to continue editing the file. Seems like a bug in the platform.

processor 6502
seg.u ZEROPAGE	; uninitialized zero-page variables
org $0

seg CODE
org $7000	; starting address

cursor equ '_ ; cursor character blink equ #$ff ; cursor blink rate, 0 = none CH equ $24 ; cursor horizontal position CV equ $25 ; cursor vertical position BASL equ $2a ; screen base address (lo-byte) BASH equ $2b ; screen base address (hi-byte) STRL equ $ce ; string base address (lo-byte) STRH equ $cf ; string base address (hi-byte) scratch equ $fe ; scratch space

Print pha ; Save accumulator tya ; Transfer screen vertical position to Accumulator jsr BASCALC ; ...and calculate screen base address pla ; Recover string ID asl ; Multiply by 2 to get string base address tay lda STRINGS,y ; Setup string address sta STRL iny lda STRINGS,y sta STRH stx CH ; Set cursor horizontal position ldy #0 CharOut lda (STRL),Y ; get string character beq StrDone ; if terminator character ($00) then exit jsr COUT ; print it bne CharOut ; keep printing StrDone rts

STRINGS Slot DS "Slot:"

sellam-i avatar Jul 30 '23 03:07 sellam-i

I was able to reproduce this -- looks like an out of memory error in DASM. Maybe Brave handles these by crashing the tab process? In Firefox it throws an exception in the web worker. Glad you are able to move forward anyhow.

I am not sure if this is a bug that's fixed in a newer DASM version. The IDE uses DASM 2.20.11 (from 2008!) and I haven't upgraded it b/c so much code is written against the old version. In any case, your test case might be a good one to add to their test suite.

sehugg avatar Aug 01 '23 17:08 sehugg

And I finally found the bug in the code, this line:

Slot    DS  "Slot:"

DS means "define storage" and reserves the number of bytes in the operand. Since the operand is an ASCII string, it is probably translated to a very large integer. Newer versions of DASM give this message:

(39): error: Recursion too deep in code segment growing larger (655387) than max. allowed file size (655360)

While the old version of DASM just runs out of memory.

You can fix it like this:

Slot    byte  "Slot:"

sehugg avatar Aug 01 '23 20:08 sehugg