Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sellam-i opened this issue Jul 10, 2023 · 4 comments
Open

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

sellam-i opened this issue Jul 10, 2023 · 4 comments

Comments

@sellam-i
Copy link

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

@sehugg
Copy link
Owner

sehugg commented Jul 12, 2023

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")

@sellam-i
Copy link
Author

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:"

@sehugg
Copy link
Owner

sehugg commented Aug 1, 2023

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
Copy link
Owner

sehugg commented Aug 1, 2023

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:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants