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

Full crash on either assemble or autocorrect with a program, don't know what is triggering it. #8

Open
circuitgamer77 opened this issue Aug 30, 2022 · 3 comments

Comments

@circuitgamer77
Copy link

Here's the Command Prompt output after restarting the compiler, pasting in my current program, and clicking the autocorrect button.

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 229288618
at Assembler.Assemble(Assembler.java:2413)
at Assembler.jButtonAssembleActionPerformed(Assembler.java:2345)
at Assembler.jButtonAutocorrectActionPerformed(Assembler.java:2869)
at Assembler.access$2000(Assembler.java:17)
at Assembler$30.actionPerformed(Assembler.java:1078)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Here's the program:

; Program to implement reverse polish notation to some degree

; can't use interrupts due to address not pushing to stack

#CSTACK EQU FFFFH
#DSTACK EQU F000H

#main EQU 0100H
#datapsh EQU E000H
#datapp EQU E100H

#test EQU 0200H

LXI H, CSTACK
SPHL
LXI H, DSTACK

; PROGRAM START
CALL main
HLT

#ORG main
;temporary test
CALL test
RET

#ORG test
MVI A, AAH
CALL datapsh
MVI A, BBH
CALL datapsh
MVI A, CCH
CALL datapp
CALL datapp
RET

#ORG datapush
STAX H
INX
RET

#ORG datapop
DCX
LDAX H
RET

@circuitgamer77
Copy link
Author

Update on this: I got it to a point where it worked, tweaked it a bit, and now I'm running into a different problem which I think is from the same error. When I don't use any named labels it compiles and runs fine, but when I just make a few of the calls use labels instead of baked-in values it puts the assembled instructions in the wrong place. For example, I have my "main" label set to 0100H, but after it is assembled the instructions following the "#ORG main" directive get put at 0AAA, and all of the other labels are scrambled. The program still tries to jump to 0100H, but the instructions aren't there, and sometimes overwrite each other (I think that's part of what caused the crash the first time). The only solution I've found so far is to just not use labels, which is doable but tedious to work with on larger programs.

@circuitgamer77
Copy link
Author

Update on this: I got it to a point where it worked, tweaked it a bit, and now I'm running into a different problem which I think is from the same error. When I don't use any named labels it compiles and runs fine, but when I just make a few of the calls use labels instead of baked-in values it puts the assembled instructions in the wrong place. For example, I have my "main" label set to 0100H, but after it is assembled the instructions following the "#ORG main" directive get put at 0AAA, and all of the other labels are scrambled. The program still tries to jump to 0100H, but the instructions aren't there, and sometimes overwrite each other (I think that's part of what caused the crash the first time). The only solution I've found so far is to just not use labels, which is doable but tedious to work with on larger programs.

Here's the current program that assembles incorrectly:
; Program to implement reverse polish notation to some degree

; can't use interrupts due to address not pushing to stack

#main EQU 0100
#test EQU 0200
#dpush EQU E000
#dpop EQU E100

LXI H, FFFF
SPHL
LXI H, F000

; PROGRAM START
CALL main
HLT

#ORG main
;temporary test
CALL test
RET

#ORG test
MVI A, AA
CALL dpush
MVI A, BB
CALL dpush
MVI A, CC
CALL dpop
CALL dpop
RET

#ORG dpush
XCHG
STAX D
XCHG
INX H
RET

#ORG dpop
DCX H
XCHG
LDAX D
XCHG
RET

@circuitgamer77
Copy link
Author

Update on this: I got it to a point where it worked, tweaked it a bit, and now I'm running into a different problem which I think is from the same error. When I don't use any named labels it compiles and runs fine, but when I just make a few of the calls use labels instead of baked-in values it puts the assembled instructions in the wrong place. For example, I have my "main" label set to 0100H, but after it is assembled the instructions following the "#ORG main" directive get put at 0AAA, and all of the other labels are scrambled. The program still tries to jump to 0100H, but the instructions aren't there, and sometimes overwrite each other (I think that's part of what caused the crash the first time). The only solution I've found so far is to just not use labels, which is doable but tedious to work with on larger programs.

Here's the current program that assembles incorrectly: ; Program to implement reverse polish notation to some degree

; can't use interrupts due to address not pushing to stack

#main EQU 0100 #test EQU 0200 #dpush EQU E000 #dpop EQU E100

LXI H, FFFF SPHL LXI H, F000

; PROGRAM START CALL main HLT

#ORG main ;temporary test CALL test RET

#ORG test MVI A, AA CALL dpush MVI A, BB CALL dpush MVI A, CC CALL dpop CALL dpop RET

#ORG dpush XCHG STAX D XCHG INX H RET

#ORG dpop DCX H XCHG LDAX D XCHG RET

And here's a part of the incorrectly assembled program:
image

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

1 participant