Menu

#4068 uCsim issue with huc6280

closed-fixed
None
Simulator
5
2026-09-15
2026-08-27
No

uCsim has issues when using -t6280
many simulations fail with stack overflow.
attached files are from plain mos6502 build which should work unchanged on huc6280

uCsim commands:

set error stack on
set hw simif rom 0xfff0
step 500000000 vclk
state
gorlik@a64:/mnt/scratch/build/sdcc/sdcc-svnt/sdcc/support/regression$ ../../sim/ucsim/src/sims/mos6502.src/ucsim_mos6502 -t6502 gen/uc6502/tst_bug-2357.ihx 
uCsim 0.9.9, Copyright (C) 1997 Daniel Drotos.
uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
0> 1395 words read from gen/uc6502/tst_bug-2357.ihx
set error stack on
set hw simif rom 0xfff0
step 500000000 vclk
state0> 0> --- Running: bug-2357.c
Running testBug
--- Summary: 0/4/1: 0 failed of 4 tests in 1 cases.

Stop at 0x0004ec: (110) Program stopped itself
F 0x0004ec
Simulated 18936 ticks (1.894e-02 sec)
Host usage: 0.002859 sec, rate=6.623027
0> 
gorlik@a64:/mnt/scratch/build/sdcc/sdcc-svnt/sdcc/support/regression$ ../../sim/ucsim/src/sims/mos6502.src/ucsim_mos6502 -t6280 gen/uc6502/tst_bug-2357.ihx 
uCsim 0.9.9, Copyright (C) 1997 Daniel Drotos.
uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
0> 1395 words read from gen/uc6502/tst_bug-2357.ihx
set error stack on
set hw simif rom 0xfff0
step 500000000 vclk
state0> 0> Stack overflow, PC=0x0

Stop at 0x000320: (108) F 0x000320
Simulated 10 ticks (1.000e-05 sec)
Host usage: 0.000044 sec, rate=0.226719
0> 
8 Attachments

Discussion

  • Gabriele Gorla

    Gabriele Gorla - 2026-08-27
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -2,6 +2,7 @@
     many simulations fail with stack overflow.
     attached files are from plain mos6502 build which should work unchanged on huc6280
    
    +uCsim commands:
     ~~~
     set error stack on
     set hw simif rom 0xfff0
    
     
  • RvS

    RvS - 2026-08-31

    Could it be that the reset() method of class cl_huc6280 should have called the cl_mos6502::reset() method instead of the cl_uc::reset() as the one in cl_mos6502 set the stack pointer? The processor is an extended WDC 65C02, which class inherits the mos6502 class, hence also it's reset() method.
    I do not have a working environment so I cannot test.

     
  • RvS

    RvS - 2026-09-01

    Patch to this effect, attached

     
  • Daniel Drotos

    Daniel Drotos - 2026-09-01
    • status: open --> closed-fixed
    • assigned_to: Daniel Drotos
     
  • Daniel Drotos

    Daniel Drotos - 2026-09-01
     

    Related

    Commit: [r16843]

  • Gabriele Gorla

    Gabriele Gorla - 2026-09-02
    • status: closed-fixed --> open
     
  • Gabriele Gorla

    Gabriele Gorla - 2026-09-02

    many tests still fail when -t6280 is passed to the simulator.
    changing EMU_PORT_FLAG=-t65c02 to EMU_PORT_FLAG=-t6280 in ports/uc6280/spec.mk

    produces:

    Summary for 'uc6280': 91 abnormal stops ( 16 invalid instructions, 120 Stack overflows, ), 22 failures, 32373 tests, 6236 test cases, 9020945 bytes, 7864220274 ticks
       Stack overflow: 
       Stack overflow: 
       abnormal stop: gen/uc6280/m4_compare_2_n
       Stack overflow: auto.c
       Stack overflow: auto.c
       abnormal stop: gen/uc6280/tst_bitfields
       Stack overflow: bitwise8reg.c
       abnormal stop: gen/uc6280/tst_blake2s
       Invalid instruction: gen/uc6280/tst_dhrystone
       abnormal stop: gen/uc6280/tst_dhrystone
       Invalid instruction: gen/uc6280/tst_falcon-ntt
       abnormal stop: gen/uc6280/tst_falcon-ntt
       Invalid instruction: gen/uc6280/tst_gcc-torture-execute-20021120-1
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-20021120-1
       Stack overflow: gcc-torture-execute-20031011-1.c
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-20031012-1
       Invalid instruction: gen/uc6280/tst_gcc-torture-execute-20041011-1
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-20041011-1
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-ashldi-1
       Stack overflow: gen/uc6280/tst_gcc-torture-execute-ashldi-1
       Stack overflow: gen/uc6280/tst_gcc-torture-execute-ashldi-1
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-ashrdi-1
       Stack overflow: gcc-torture-execute-dbra-1.c
       Stack overflow: gcc-torture-execute-dbra-1.c
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-divcmp-1
       Invalid instruction: gen/uc6280/tst_gcc-torture-execute-lshrdi-1
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-lshrdi-1
       Stack overflow: gcc-torture-execute-pr39339.c
       Stack overflow: gcc-torture-execute-pr39339.c
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-pr39501
       Invalid instruction: gen/uc6280/tst_gcc-torture-execute-pr47538
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-pr47538
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-pr91137
       Stack overflow: gcc-torture-execute-strlen-1.c
       Stack overflow: gcc-torture-execute-strlen-1.c
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-strlen-2
       Stack overflow: gcc-torture-execute-strlen-3.c
       Stack overflow: gcc-torture-execute-strlen-3.c
       abnormal stop: gen/uc6280/tst_gcc-torture-execute-strlen-4
       abnormal stop: gen/uc6280/tst_lonesha256
       Invalid instruction: gen/uc6280/tst_rabbit
       abnormal stop: gen/uc6280/tst_rabbit
       abnormal stop: gen/uc6280/tst_sieve
       Stack overflow: smallc.c
       Stack overflow: smallc.c
       abnormal stop: gen/uc6280/tst_string
       abnormal stop: gen/uc6280/tst_wcsto
       Invalid instruction: gen/uc6280/asconhash256/asconhash256_impl_bi8
       abnormal stop: gen/uc6280/asconhash256/asconhash256_impl_bi8
       Stack overflow: gen/uc6280/asconhash256/asconhash256_impl_bi8
       Stack overflow: gen/uc6280/asconhash256/asconhash256_impl_bi8
       abnormal stop: gen/uc6280/asconhash256/asconhash256_impl_opt32_lowsize
       Stack overflow: asconhash256_impl_opt8_mylowsize
       Stack overflow: asconhash256_impl_opt8_mylowsize
       abnormal stop: gen/uc6280/asconhash256/asconhash256_impl_ref
       Failure: bitfields-bits1_preBits_0_pattern_0_varType_1
       Failure: bitfields-bits1_preBits_0_pattern_0_varType_6
       Failure: bitfields-bits1_preBits_0_pattern_1_varType_1
       Failure: bitfields-bits1_preBits_0_pattern_1_varType_6
       Failure: bitfields-bits1_preBits_16_pattern_0_varType_2
       Failure: bitfields-bits1_preBits_16_pattern_0_varType_5
       Failure: bitfields-bits1_preBits_16_pattern_0_varType_6
       Failure: bitfields-bits1_preBits_16_pattern_1_varType_1
       Failure: bitfields-bits1_preBits_16_pattern_1_varType_5
       Failure: bitfields-bits1_preBits_16_pattern_1_varType_6
       Failure: bitfields-bits1_preBits_8_pattern_0_varType_2
       Failure: bitfields-bits1_preBits_8_pattern_1_varType_2
       Stack overflow: bitfields-nibbles_operation_0_pattern_0_varType_5
       Stack overflow: bitfields-nibbles_operation_0_pattern_0_varType_5
       abnormal stop: bitfields-nibbles_operation_0_pattern_0_varType_5
       Failure: bitfields-nibbles_operation_0_pattern_0_varType_6
       abnormal stop: bitfields-nibbles_operation_0_pattern_1_varType_1
       Failure: bitfields-nibbles_operation_1_pattern_0_varType_2
       Failure: bitfields-nibbles_operation_1_pattern_0_varType_5
       Failure: bitfields-nibbles_operation_1_pattern_1_varType_2
       Failure: bitfields-nibbles_operation_2_pattern_0_varType_1
       Failure: bitfields-nibbles_operation_2_pattern_1_varType_1
       abnormal stop: bitfields-nibbles_operation_2_pattern_1_varType_2
       Failure: bitfields-nibbles_operation_2_pattern_1_varType_5
       Failure: bitfields-nibbles_operation_3_pattern_0_varType_1
       Failure: bitfields-nibbles_operation_3_pattern_0_varType_5
       Failure: bitfields-nibbles_operation_3_pattern_1_varType_1
       Stack overflow: bitfields-nibbles_operation_3_pattern_1_varType_6
       Stack overflow: bitfields-nibbles_operation_3_pattern_1_varType_6
       abnormal stop: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_0
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_0
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_0
       abnormal stop: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_1
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_1
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_1
       abnormal stop: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_2
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_2
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_2
       abnormal stop: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_3
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_3
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_3
       abnormal stop: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_4
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_4
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_4
       abnormal stop: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_5
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_5
       Stack overflow: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_5
       abnormal stop: gen/uc6280/bitfields-nibbles/bitfields-nibbles_operation_4_pattern_0_varType_6
       Stack overflow: bitintarith_width_32
       Stack overflow: bitintarith_width_32
       abnormal stop: gen/uc6280/bitintarith/bitintarith_width_33
       Stack overflow: bitintarith_width_4
       Stack overflow: bitintarith_width_4
       abnormal stop: gen/uc6280/bitintarith/bitintarith_width_40
       Stack overflow: gen/uc6280/bitintarith/bitintarith_width_40
       Stack overflow: gen/uc6280/bitintarith/bitintarith_width_40
       abnormal stop: gen/uc6280/bitintarith/bitintarith_width_48
       abnormal stop: gen/uc6280/bitintarith/bitintarith_width_63
       abnormal stop: gen/uc6280/bitintarith/bitintarith_width_64
       Invalid instruction: gen/uc6280/float_single/float_single_func_ACOSF
       abnormal stop: gen/uc6280/float_single/float_single_func_ACOSF
       Invalid instruction: gen/uc6280/float_single/float_single_func_ASINF
       abnormal stop: gen/uc6280/float_single/float_single_func_ASINF
       Stack overflow: float_single_func_CEILF
       Stack overflow: float_single_func_CEILF
       abnormal stop: gen/uc6280/float_single/float_single_func_COSF
       Invalid instruction: gen/uc6280/float_single/float_single_func_COSHF
       abnormal stop: gen/uc6280/float_single/float_single_func_COSHF
       Invalid instruction: gen/uc6280/float_single/float_single_func_EXPF
       abnormal stop: gen/uc6280/float_single/float_single_func_EXPF
       Invalid instruction: gen/uc6280/float_single/float_single_func_SINF
       abnormal stop: gen/uc6280/float_single/float_single_func_SINF
       Stack overflow: gen/uc6280/float_single/float_single_func_SINF
       Stack overflow: gen/uc6280/float_single/float_single_func_SINF
       abnormal stop: gen/uc6280/float_single/float_single_func_SINHF
       Invalid instruction: gen/uc6280/float_single/float_single_func_TANF
       abnormal stop: gen/uc6280/float_single/float_single_func_TANF
       Stack overflow: gen/uc6280/float_single/float_single_func_TANF
       Stack overflow: gen/uc6280/float_single/float_single_func_TANF
       abnormal stop: gen/uc6280/float_single/float_single_func_TANHF
       Invalid instruction: gen/uc6280/float_trans/float_trans_func_POWF
       abnormal stop: gen/uc6280/float_trans/float_trans_func_POWF
       abnormal stop: gen/uc6280/float_trans/float_trans_func_TANF
       Stack overflow: gcc-torture-execute-stdarg-5_inlined_no
       Stack overflow: gcc-torture-execute-stdarg-5_inlined_no
       abnormal stop: gen/uc6280/gcc-torture-execute-stdarg-5/gcc-torture-execute-stdarg-5_inlined_yes
       abnormal stop: gen/uc6280/longlong/longlong_test_mul
       abnormal stop: gen/uc6280/ltoa/ltoa_test_ltoa_part_2
       Stack overflow: gen/uc6280/ltoa/ltoa_test_ltoa_part_2
       Stack overflow: gen/uc6280/ltoa/ltoa_test_ltoa_part_2
       abnormal stop: gen/uc6280/ltoa/ltoa_test_ltoa_part_3
       Stack overflow: gen/uc6280/ltoa/ltoa_test_ltoa_part_3
       Stack overflow: gen/uc6280/ltoa/ltoa_test_ltoa_part_3
       abnormal stop: gen/uc6280/ltoa/ltoa_test_ltoa_part_4
       Stack overflow: nullstring_storage_none
       Stack overflow: nullstring_storage_none
       abnormal stop: gen/uc6280/onebyte/onebyte_attrL_none_attrR_none
       Stack overflow: gen/uc6280/onebyte/onebyte_attrL_none_attrR_none
       Stack overflow: gen/uc6280/onebyte/onebyte_attrL_none_attrR_none
       abnormal stop: gen/uc6280/onebyte/onebyte_attrL_none_attrR_volatile
       Stack overflow: gen/uc6280/onebyte/onebyte_attrL_none_attrR_volatile
       Stack overflow: gen/uc6280/onebyte/onebyte_attrL_none_attrR_volatile
       abnormal stop: gen/uc6280/onebyte/onebyte_attrL_volatile_attrR_none
       abnormal stop: gen/uc6280/onebyte/onebyte_attrL_volatile_attrR_volatile
       Stack overflow: rotate_size_32_msb_1
       Stack overflow: rotate_size_32_msb_1
       abnormal stop: gen/uc6280/rotate/rotate_size_64_msb_0
       Invalid instruction: gen/uc6280/rotate/rotate_size_64_msb_1
       abnormal stop: gen/uc6280/rotate/rotate_size_64_msb_1
       abnormal stop: gen/uc6280/serpent/serpent_op_decrypt
       Stack overflow: gen/uc6280/serpent/serpent_op_decrypt
       Stack overflow: gen/uc6280/serpent/serpent_op_decrypt
       abnormal stop: gen/uc6280/serpent/serpent_op_encrypt
       Stack overflow: shifts2_size_32_right_1_vol_1_sign_u_goal_2
       Stack overflow: shifts2_size_32_right_1_vol_1_sign_u_goal_2
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_0
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_1
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_none_goal_2
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_0
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_1
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_0_sign_u_goal_2
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_0
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_1
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_none_goal_2
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_0
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_1
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_0_vol_1_sign_u_goal_2
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_0
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_1
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_none_goal_2
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_0
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_1
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_0_sign_u_goal_2
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_0
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_1
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_2
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_none_goal_2
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_u_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_u_goal_0
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_u_goal_0
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_u_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_u_goal_1
       Stack overflow: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_u_goal_1
       abnormal stop: gen/uc6280/shifts2/shifts2_size_64_right_1_vol_1_sign_u_goal_2
       Stack overflow: sizeof_size_8_test_5_vol_1
       Stack overflow: sizeof_size_8_test_5_vol_1
       abnormal stop: gen/uc6280/smallserpent/smallserpent_op_decrypt
       Stack overflow: gen/uc6280/smallserpent/smallserpent_op_decrypt
       Stack overflow: gen/uc6280/smallserpent/smallserpent_op_decrypt
       abnormal stop: gen/uc6280/smallserpent/smallserpent_op_encrypt
       Stack overflow: tcc/10_pointer
       Stack overflow: tcc/10_pointer
       abnormal stop: gen/uc6280/tcc_110_average
    
     
  • Gabriele Gorla

    Gabriele Gorla - 2026-09-06

    It seem some files fail to load properly when the -t6280 flag is set.
    Referring to the attached files:

    $ ../../sim/ucsim/src/sims/mos6502.src/ucsim_mos6502 -t6502 gen/uc6280/tst_gcc-torture-execute-20021120-1.ihx 
    uCsim 0.9.9, Copyright (C) 1997 Daniel Drotos.
    uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.
    0> 12286 words read from gen/uc6280/tst_gcc-torture-execute-20021120-1.ihx
    dump /x 0xfff8 0xffff
    0xfff8 00 00 cd 23 cd 23 cd 23 ...#.#.#
    0> 
    
    $ ../../sim/ucsim/src/sims/mos6502.src/ucsim_mos6502 -t6280 gen/uc6280/tst_gcc-torture-execute-20021120-1.ihx 
    uCsim 0.9.9, Copyright (C) 1997 Daniel Drotos.
    uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.
    0> 12286 words read from gen/uc6280/tst_gcc-torture-execute-20021120-1.ihx
    dump /x 0xfff8 0xffff
    0xfff8 8d b0 23 ad 51 22 8d af ..#.Q"..
    0> 
    

    the reset vector is wrong in the huc6280 case.

     
  • Daniel Drotos

    Daniel Drotos - 2026-09-07

    6280 harware document:

    At a system reset, MPR7 is set to 0 ("00₁₆"). Then the HuC6280 reads the low byte address at logical address FFFE₁₆ and the high byte address at logical address FFFF₁₆, and starts. Since MPR7 = 00₁₆, the program reads the low byte address at physical address 001FFE₁₆ and the high byte address at 001FFF₁₆, and starts.A system reset does not initialize the rest of the mapping registers (MPR0 - MPR6). The initial routine must be used to initialize these registers.

    This means that 6502 and 6280 use different memory layout which can be a problem for bigger programs. I can setup MPR regs to emulate a 6502's 64k system, but it will not be true for the real CPU.

    Daniel

     
  • Gabriele Gorla

    Gabriele Gorla - 2026-09-08

    thanks for the reply.
    I suspected the issue was due to the MPR mapping but that is inconsistent with two observations:

    • most of the regression pass. If the reset vector is at the wrong address, no test should ever pass.
    • issuing state right after loading shows PC = 0x2251 which is the value at 0xfffc

    I am not sure exactly what is the issue, but something is wrong (I don't exclude the crt0).

     
  • Daniel Drotos

    Daniel Drotos - 2026-09-08

    As the address space is mapped as 8k chunks, smaller programs will succseed, biggers will fail.

    I can init map registers to emulate 64k system, but there is an other problem, the doc says:

    2.1.4 Stack Pointer (S)
    The stack pointer (S) is an 8bit register which contains the loworder
    8 bits of the highest address of a free stack area. The stack pointer
    is decremented after the data is pushed into the stack, and
    incremented before it is pulled from the stack. After a system reset
    occurs, the contents of the stack pointer become invalid. The initial
    routine must set appropriate data in the stack pointer. When the stack
    pointer is output onto the address bus, the high byte should always be
    0x21. Therefore, the stack area of the HuC6280 consists of up to 256
    bytes at logical addresses from 0x21FF to 0x2100.

    So if a program is bigger than 0x2100, it will still fail, bc the stack will overwrite the code.

     
  • Daniel Drotos

    Daniel Drotos - 2026-09-08

    I've made high half of SP configurable, so you can create a non-real 6280 which uses the memory the same way as 6502 does:

    # Regression test specification for the huc6280 target running with uCsim
    
    # simulation timeout in cycles
    SIM_CYCLES = 1000000000
    
    EMU_PORT_FLAG=-t6280 -eSPh=0x100
    

    All tests will pass with that setting:

    Summary for 'uc6280': 0 failures, 36769 tests, 6402 test cases, 9036500 bytes, 395722633 ticks
    
     
  • Daniel Drotos

    Daniel Drotos - 2026-09-08
    • status: open --> closed-wont-fix
     
  • Philipp Klaus Krause

    Just an outside opinion, but I feel like the simulator should behave as close to the hardware as it reasonably can, so we can be confident that what passes the regression tests would also work on real hardware (naturally this might exclude the channel we use for communicating with the regression test infrastructure). So if programs needs some registers set up a certain way, it would be the job of the crt0 to do so (unless the real hardware does initialize them).

     
    • Daniel Drotos

      Daniel Drotos - 2026-09-08

      Understand your opinion, and I agree. But I think that configurability makes the simulator more usable. Altough you can "build" a non-real CPU with a special configuration setting, you don't have to. It's up to Gabriele how he uses the software.
      Besides that, I don't know how CPU inits MPR0-MPR6 registers, so I don't know how to simulate them.

       
      • Philipp Klaus Krause

        According to https://kikb.web.fc2.com/PCE/mpr.html, MPR0-MPR6 are preserved across reset, and their power-on values are 0xff.

         
  • Daniel Drotos

    Daniel Drotos - 2026-09-08

    Thank you Phlipp, it's new to me. Implemented in [r16853].

    Please note, that this breaks the regression testing completly.

    The content of the hex file should be loaded directly to the chip object, using the new method: inspec and MPR setting can be done later by the crt0. Hex file should contain reset vector at the correct address, expected by MPR7=0.

     

    Related

    Commit: [r16853]

  • Gabriele Gorla

    Gabriele Gorla - 2026-09-08

    thanks!
    the CRT setup the code start at 0x2200. ZP and stack should never be overwritten by code.
    I'll modify the CRT to initialize the MPR registers.
    How is the ihx file loaded?
    is the address in the ihx the physical address regradless of the MP mapping?

    BTW: I agree with Philipp. The simulator should be as close as the real HW as possible.

     

    Last edit: Gabriele Gorla 2026-09-08
  • Gabriele Gorla

    Gabriele Gorla - 2026-09-10
    • status: closed-wont-fix --> open
     
  • Gabriele Gorla

    Gabriele Gorla - 2026-09-10

    Daniel,
    I am sorry but I need to reopen this one.
    Either I completely don't understand how the mapping works in the simulator or there is something wrong.

    referring to the simple attached example:
    hex file starts at 0x2200. Reset/irq vectors at 0xfffa to 0xffff.
    dump seems to read from mapped memory as trying dump /x 0x1ffff8 0x1fffff has no effect.

    $ ../../sim/ucsim/src/sims/mos6502.src/ucsim_mos6502 -t6280 gen/uc6280/tcc_01_comment.ihx
    uCsim 0.9.9, Copyright (C) 1997 Daniel Drotos.
    uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.
    0> 3389 words read from gen/uc6280/tcc_01_comment.ihx
    
    0> state
    CPU state= OK PC= 0x00223f frequency= 1000000 HZ
    Operation since last reset= 0 vclks
    Inst= 0 Fetch= 0 Read= 0 Write= 0
    Total time since last reset= 0.000007000000000 sec (7 clks)
    Time in isr = 0.000000000000000 sec (0 clks) 0.00%
    Time in idle= 0.000000000000000 sec (0 clks) 0.00%
    Most value of stack pointer= 0x000000
    Simulation: stopped
    Runtime: 2.901125 sec
    0> info memory
    Memory chips:
      0x000000-0x0000ff      256 variable_storage (32,%08x,0x%02x)
      0x000000-0x1fffff  2097152 rom_chip (8,%02x,0x%06x)
      0x000000-0x000007        8 mpr_chip (8,%02x,0x%01x)
    Address spaces:
      0x000000-0x0000ff      256 variables (32,%08x,0x%02x)
      0x000000-0x00ffff    65536 rom (8,%02x,0x%04x)
      0x000000-0x000007        8 mpr_as (8,%02x,0x%01x)
    Address decoders:
      variables 0x00 0xff -> variable_storage 0x00 activated
      rom 0x0000 0x1fff -> banked
        bank selector: mpr_as[0x0] mask=0xff banks=256 act=255
        banks:
    
              0. rom_chip 0x000000
            ....
          * 255. rom_chip 0x1fe000
      rom 0x2000 0x3fff -> banked
        bank selector: mpr_as[0x1] mask=0xff banks=256 act=255
        banks:
              0. rom_chip 0x000000
            ....
          * 255. rom_chip 0x1fe000
      rom 0x4000 0x5fff -> banked
        bank selector: mpr_as[0x2] mask=0xff banks=256 act=255
        banks:
              0. rom_chip 0x000000
            ....
          * 255. rom_chip 0x1fe000
      rom 0x6000 0x7fff -> banked
        bank selector: mpr_as[0x3] mask=0xff banks=256 act=255
        banks:
              0. rom_chip 0x000000
            ....
          * 255. rom_chip 0x1fe000
      rom 0x8000 0x9fff -> banked
        bank selector: mpr_as[0x4] mask=0xff banks=256 act=255
        banks:
              0. rom_chip 0x000000
            ....
          * 255. rom_chip 0x1fe000
      rom 0xa000 0xbfff -> banked
        bank selector: mpr_as[0x5] mask=0xff banks=256 act=255
        banks:
              0. rom_chip 0x000000
            ....
          * 255. rom_chip 0x1fe000
      rom 0xc000 0xdfff -> banked
        bank selector: mpr_as[0x6] mask=0xff banks=256 act=255
        banks:
              0. rom_chip 0x000000
            ....
          * 255. rom_chip 0x1fe000
      rom 0xe000 0xffff -> banked
        bank selector: mpr_as[0x7] mask=0xff banks=256 act=0
        banks:
          *   0. rom_chip 0x000000
            ....
            255. rom_chip 0x1fe000
      mpr_as 0x0 0x7 -> mpr_chip 0x0 activated
    0> dump /x 0xfff8 0xffff
    0xfff8 00 00 3f 22 3f 22 3f 22 ..?"?"?"
    0> dump /x 0x1ff8 0x1fff
    0x1ff8 16 47 c6 52 4e ad 8a 54 .G.RN..T
    0> dump 0x223f   
    0x223f    a9 00                LDA    #$00
    0x2241    43 01                TMA    0
    0x2243    43 02                TMA    1
    0x2245    43 04                TMA    2
    0x2247    43 08                TMA    3
    0x2249    43 10                TMA    4
    0x224b    43 20                TMA    5
    0x224d    43 40                TMA    6
    0x224f    43 80                TMA    7
    0x2251    a2 ff                LDX    #$ff
    0> 
    

    Given the power on MPR values I should not see the reset vector at 0x1ffc and I should not see the startup code at 0x223f.

    it seems the code is loaded at 0x1fe200 instead of 0x2200.

    0> where rom_chip 0xa9 0x00 0x43 0x01 0x43 0x02     
    0x1fe23f a9 00 43 01 43 02 ..C.C.
    

    these are the first bytes of the startup code at 0x223f.

    the reset vectors are also loaded incorrectly

    0> dump /x 0xfff8 0xffff                       
    0xfff8 00 00 3f 22 3f 22 3f 22 ..?"?"?"
    0> where rom_chip 0x3f 0x22 0x3f 0x22 0x3f 0x22
    0x001ffa 3f 22 3f 22 3f 22 ?"?"?"
    0> 
    

    The mapping seems reversed. the reset vector should be at physical 0x00fffa and logical 0x1ffa.

     
  • Gabriele Gorla

    Gabriele Gorla - 2026-09-10

    I finally got it.

    $ ../../sim/ucsim/src/sims/mos6502.src/ucsim_mos6502 -t6280 gen/uc6280/tcc_01_comment.ihx@rom_chip
    

    adding @rom_chip makes the sim load the file correctly.

    However, I can't find any way to add this to the regression suite.

     
  • Gabriele Gorla

    Gabriele Gorla - 2026-09-15

    fixed in [r16875]

     

    Related

    Commit: [r16875]

  • Gabriele Gorla

    Gabriele Gorla - 2026-09-15
    • status: open --> closed-fixed
     

Log in to post a comment.