Skip to content

Java exception #53

@adrian4096

Description

@adrian4096
Exception in thread "Timer-1" java.util.EmptyStackException
        at java.base/java.util.Stack.peek(Stack.java:103)
        at java.base/java.util.Stack.pop(Stack.java:85)
        at sic.sim.vm.Machine.popJSUB(Machine.java:340)
        at sic.sim.vm.Machine.execSICF3F4(Machine.java:210)
        at sic.sim.vm.Machine.execute(Machine.java:318)
        at sic.sim.Executor.timerTickUntil(Executor.java:70)
        at sic.sim.Executor$1.run(Executor.java:117)
        at java.base/java.util.TimerThread.mainLoop(Timer.java:572)
        at java.base/java.util.TimerThread.run(Timer.java:522)

I don't wanna debug this, so here's my entire program that causes this fault.

Details

main START 0
    JSUB INIT_STDLIB

    LDT x
    JSUB PUSH

    LDT y
    JSUB PUSH

    LDT #arith
    JSUB PUSH
    JSUB CALL

    JSUB POP
    STT rez

    J HALT

    END main

x WORD 123
y WORD 321
rez RESW 1

arith
    JSUB POP
    RMO T,S
    JSUB POP
    LDA #0
    ADDR T,A
    ADDR S,A
    RMO A,T
    JSUB PUSH
    J RET




. stdlib
INIT_STDLIB LDA #stack
    STA stack_ptr
    LDA #call_stack
    STA call_stack_ptr
    RSUB

POP LDA stack_ptr
    SUB #3
    STA stack_ptr
    LDT @stack_ptr
    RSUB

PUSH STT @stack_ptr
    LDA stack_ptr
    ADD #3
    STA stack_ptr
    RSUB

RET LDA call_stack_ptr
    SUB #3
    STA call_stack_ptr

    LDL @call_stack_ptr
    RSUB . bug here

call_tmp_src RESW 1
call_tmp_des RESW 1

CALL STL @call_stack_ptr
    LDA call_stack_ptr
    ADD #3
    STA call_stack_ptr
    JSUB POP
    RMO T,L
    RSUB


HALT J HALT

stack_ptr WORD -1
stack RESW 64
call_stack_ptr WORD -1
call_stack RESW 64
. end stdlib

the problem is in RET subrutine
with the RSUB instruction.

Best regards & plsfix
Adrian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions