Yes, optimisation level was 2, and I don't use -q (NXT doesn't beep on successful download?). Those were the only differences.
0: ArrayLen displays different number each time - always a multiple of 8.
1: Same as 0.
2: ArrayLen always displays zero.
3: Same as 2.
4: Same as 2.
5: Same as 2.
6: Same as 2.
All other compile options are identical, so there must be something else different here.
I also checked the NBC code (included below). One weird thing I noticed, in the print() routine, in section that prints out the ArrayLen(), there is the following:
It seems to put the array len into _D0print, then overwrite it with a variable _DU0print if I'm reading it right? That seems wrong, and none of the other NumOut()s seem to do it. _DU0print is declared, but never initialised, hence why I get the zeroes, but why is it doing that assignment?
Code: Select all
dseg segment
;------- definitions -------
__foo_7qG2_vx_7qG2_000_def struct
a1 sword[]
__foo_7qG2_vx_7qG2_000_def ends
Location_def struct
X sword
Y sword
Location_def ends
__TextOutArgs_def struct
Result sbyte
Location Location_def
Text byte[]
Options dword
__TextOutArgs_def ends
__bar_7qG2_vx_7qG2_000_def struct
a1 sword[]
__bar_7qG2_vx_7qG2_000_def ends
__print_7qG2_vx_7qG2_000_def struct
a1 sword[]
__print_7qG2_vx_7qG2_000_def ends
__foo1_7qG2_vx_7qG2_000_def struct
a1 sword[]
__foo1_7qG2_vx_7qG2_000_def ends
v1_def struct
a1 sword[]
v1_def ends
;------- declarations -------
__signed_stack_001foo sdword
__signed_stack_002foo sdword
__D0two sdword
__D0print sdword
__DU0print dword
__signed_stack_001foobar sdword
__print_mutex mutex
__Wait_7qG2_ms_7qG2_000_inline_two dword
__unsigned_stack_002print dword
__signed_stack_001print sdword
__signed_stack_003print sdword
__D0foobar sdword
__D0bar sdword
__D0foo sdword
__TextOutMutex mutex
__D0foo1 sdword
__ArrHelper__print_73_0 sword
__foo_7qG2_s_7qG2_000 sword
__ArrHelper__foo_73_0 sword
__foo_7qG2_i_7qG2_001 sword
__bar_return byte
__ClearLine_7qG2_line_7qG2_000_inline_print byte
__print_return byte
__foo1_return byte
__foo_return byte
__constVal1 sbyte 1
____initialize_global_data_return byte
__zffoo byte
__zffoobar byte
__constVal0 sbyte
__zftwo byte
__print_7qG2_line_7qG2_000 byte
__foo_7qG2_vx_7qG2_000 __foo_7qG2_vx_7qG2_000_def
__TextOutArgs __TextOutArgs_def
__bar_7qG2_vx_7qG2_000 __bar_7qG2_vx_7qG2_000_def
__print_7qG2_vx_7qG2_000 __print_7qG2_vx_7qG2_000_def
__foo1_7qG2_vx_7qG2_000 __foo1_7qG2_vx_7qG2_000_def
v1 v1_def
v0 sword[] 0x1, 0x2, 0x3
__BlankLine byte[] ' '
dseg ends
;------- code -------
thread main
subcall __initialize_global_data, ____initialize_global_data_return
mov __foo_7qG2_vx_7qG2_000, v1
set __foo_7qG2_s_7qG2_000, 3
subcall foo, __foo_return
mov v1, __foo_7qG2_vx_7qG2_000
exit 0, 1
endt
;------------------------
subroutine print
mov __ClearLine_7qG2_line_7qG2_000_inline_print, __print_7qG2_line_7qG2_000
#pragma macro 7
acquire __TextOutMutex
mov __TextOutArgs.Location.X, __constVal0
mov __TextOutArgs.Location.Y, __ClearLine_7qG2_line_7qG2_000_inline_print
mov __TextOutArgs.Options, __constVal0
mov __TextOutArgs.Text, __BlankLine
syscall 13, __TextOutArgs
release __TextOutMutex
arrsize __D0print, __print_7qG2_vx_7qG2_000.a1
set __signed_stack_001print, 80
mov __unsigned_stack_002print, __print_7qG2_line_7qG2_000
mov __D0print, __DU0print
acquire __TextOutMutex
mov __TextOutArgs.Location.X, __signed_stack_001print
mov __TextOutArgs.Location.Y, __unsigned_stack_002print
set __TextOutArgs.Options, 0
numtostr __TextOutArgs.Text, __D0print
syscall 13, __TextOutArgs
mov __D0print, __TextOutArgs.Result
release __TextOutMutex
set __signed_stack_001print, 0
mov __unsigned_stack_002print, __print_7qG2_line_7qG2_000
set __signed_stack_003print, 0
index __ArrHelper__print_73_0, __print_7qG2_vx_7qG2_000.a1, __signed_stack_003print
mov __D0print, __ArrHelper__print_73_0
acquire __TextOutMutex
mov __TextOutArgs.Location.X, __signed_stack_001print
mov __TextOutArgs.Location.Y, __unsigned_stack_002print
set __TextOutArgs.Options, 0
numtostr __TextOutArgs.Text, __D0print
syscall 13, __TextOutArgs
mov __D0print, __TextOutArgs.Result
release __TextOutMutex
set __signed_stack_001print, 30
mov __unsigned_stack_002print, __print_7qG2_line_7qG2_000
set __signed_stack_003print, 1
index __ArrHelper__print_73_0, __print_7qG2_vx_7qG2_000.a1, __signed_stack_003print
mov __D0print, __ArrHelper__print_73_0
acquire __TextOutMutex
mov __TextOutArgs.Location.X, __signed_stack_001print
mov __TextOutArgs.Location.Y, __unsigned_stack_002print
set __TextOutArgs.Options, 0
numtostr __TextOutArgs.Text, __D0print
syscall 13, __TextOutArgs
mov __D0print, __TextOutArgs.Result
release __TextOutMutex
set __signed_stack_001print, 60
mov __unsigned_stack_002print, __print_7qG2_line_7qG2_000
set __signed_stack_003print, 2
index __ArrHelper__print_73_0, __print_7qG2_vx_7qG2_000.a1, __signed_stack_003print
mov __D0print, __ArrHelper__print_73_0
acquire __TextOutMutex
mov __TextOutArgs.Location.X, __signed_stack_001print
mov __TextOutArgs.Location.Y, __unsigned_stack_002print
set __TextOutArgs.Options, 0
numtostr __TextOutArgs.Text, __D0print
syscall 13, __TextOutArgs
mov __D0print, __TextOutArgs.Result
release __TextOutMutex
subret __print_return
ends
;------------------------
subroutine bar
#pragma safecalling
acquire __print_mutex
set __print_7qG2_line_7qG2_000, 0
mov __print_7qG2_vx_7qG2_000, __bar_7qG2_vx_7qG2_000
subcall print, __print_return
release __print_mutex
set __D0bar, 0
subret __bar_return
subret __bar_return
ends
;------------------------
thread foobar
__NXC_Label_642:
set __signed_stack_001foobar, 1
set __D0foobar, 0
cmp 1, __zffoobar, __signed_stack_001foobar, __D0foobar
mov __D0foobar, __zffoobar
brtst 4, __NXC_Label_643, __zffoobar
mov __bar_7qG2_vx_7qG2_000, v1
subcall bar, __bar_return
mov v1, __bar_7qG2_vx_7qG2_000
wait 10
jmp __NXC_Label_642
__NXC_Label_643:
exit -1, -1
endt
;------------------------
subroutine foo1
#pragma safecalling
acquire __print_mutex
set __print_7qG2_line_7qG2_000, 32
mov __print_7qG2_vx_7qG2_000, __foo1_7qG2_vx_7qG2_000
subcall print, __print_return
release __print_mutex
wait 2000
set __D0foo1, 0
subret __foo1_return
subret __foo1_return
ends
;------------------------
subroutine foo
arrinit __foo_7qG2_vx_7qG2_000.a1, __constVal0, __foo_7qG2_s_7qG2_000
set __foo_7qG2_i_7qG2_001, 0
__NXC_Label_654:
mov __signed_stack_001foo, __foo_7qG2_i_7qG2_001
mov __D0foo, __foo_7qG2_s_7qG2_000
cmp 0, __zffoo, __signed_stack_001foo, __D0foo
mov __D0foo, __zffoo
brtst 4, __NXC_Label_655, __zffoo
jmp __NXC_Label_656
__NXC_Label_657:
add __foo_7qG2_i_7qG2_001, __foo_7qG2_i_7qG2_001, __constVal1
jmp __NXC_Label_654
__NXC_Label_656:
mov __signed_stack_001foo, __foo_7qG2_i_7qG2_001
mov __signed_stack_002foo, __foo_7qG2_i_7qG2_001
index __ArrHelper__foo_73_0, v0, __signed_stack_002foo
mov __D0foo, __ArrHelper__foo_73_0
replace __foo_7qG2_vx_7qG2_000.a1, __foo_7qG2_vx_7qG2_000.a1, __signed_stack_001foo, __D0foo
jmp __NXC_Label_657
__NXC_Label_655:
#pragma safecalling
acquire __print_mutex
set __print_7qG2_line_7qG2_000, 40
mov __print_7qG2_vx_7qG2_000, __foo_7qG2_vx_7qG2_000
subcall print, __print_return
release __print_mutex
mov __foo1_7qG2_vx_7qG2_000, __foo_7qG2_vx_7qG2_000
subcall foo1, __foo1_return
mov __foo_7qG2_vx_7qG2_000, __foo1_7qG2_vx_7qG2_000
set __D0foo, 0
subret __foo_return
subret __foo_return
ends
;------------------------
thread two
set __Wait_7qG2_ms_7qG2_000_inline_two, 5
wait 5
__NXC_Label_674:
set __D0two, 1
tst 5, __zftwo, __D0two
brtst 4, __NXC_Label_675, __zftwo
#pragma safecalling
acquire __print_mutex
set __print_7qG2_line_7qG2_000, 56
mov __print_7qG2_vx_7qG2_000, v1
subcall print, __print_return
release __print_mutex
#pragma safecalling
acquire __print_mutex
set __print_7qG2_line_7qG2_000, 48
mov __print_7qG2_vx_7qG2_000, v1
subcall print, __print_return
release __print_mutex
set __Wait_7qG2_ms_7qG2_000_inline_two, 2000
wait 2000
jmp __NXC_Label_674
__NXC_Label_675:
exit -1, -1
endt
;------------------------
subroutine __initialize_global_data
subret ____initialize_global_data_return
ends
;------------------------