smilebasic bytecode requests

umm I finally got to the point where I can extract compiled smilebasic representation fairly easily please use this thread to organize requests to see compiler output for smilebasic code snippets [US ver. 3.3.2]
~OPTION~
~GOTO @L:@L~ and ~GOTO(@L):@L~
3.3.2 is fake and ghey please describe your process so others can attempt work
>>24070 this comment rubbed me the wrong way but ok whatever maybe you weren't trying to be rude 1) Start citra with gdb stub active 2) Start gdb and run target SmileBASIC in citra You should have "Waiting for gdb to connect" in the citra log 3) ~(gdb) target remote localhost:port~ Now remember, we DO NOT have symbols, nor is citra what we can consider a "friendly machine." We also can't even set breakpoints without getting out of this boot trap 4) escape 0x0: I run ~(gdb) si~ twice to get to 0x100000 which is a lot more elegant than anything before. You'll know that you have it when the prompt lists any other address than ~0x00000000 in ?? ()~. This can also be easier to check with ~layout asm~. Do NOT use continue or you will lose control. (If you're still single-stepping, you might notice a loop at 0x100030 -- this is record's wait_for_load()) 5) set a breakpoint on the 'super tokenizer' function (in 3.3.2 this is 0x1CFCE8) ~(gdb) b *0x1CFCE8~ Now (assuming you set a good breakpoint) it's safe to continue. 6) ~(gdb) c~ and navigate in citra to the editor. Test your breakpoint by entering a garbage character in direct mode. If you DON'T get a Syntax Error immediately, it worked. (Note that super_tokenizer will get called multiple times even for the input "A" thus you will have to continue multiple times) 7) Before we can start reading bytecode, we need to find it in memory. In slot 0, enter ~?&HDEADBEEF~ and run it 8) the first break probably won't have loaded it, so continue twice, maybe three times. If you mess up and lose control, just run the program again. Run ~(gdb) find 0x200000, 0x888888, 0xDEADBEEF~ I get 0x2fffaa but again, US 3.3.2, no promises. 9) Now we can read memory: ~x/8x 0x2fffa6~ #+BEGIN_SRC 0x2fffa6: 0x74010000 0xdeadbeef 0xd7b09425 0x00010880 0x2fffb6: 0x00000030 0x00000000 0x00000000 0x00000000 #+END_SRC And there you go, watch for rolling socks in 0xDEADBEEF BLJs
In this post, I compare these results to those of (Otya, 2017), reiterate on some notes from previous work, and publish the results of requests. JP 3.2.1 [1] #+BEGIN_SRC ?&H1234 7001 1234 9425 C5CC 0880 0001 #+END_SRC US 3.3.2, via gdb #+BEGIN_SRC ?&H1234 0x2fffa6: 0x70010000 0x94251234 0x0880d7b0 0x00300001 0x2fffb6: 0x00000030 0x00000000 0x00000000 0x00000000 #+END_SRC Note that gdb's output is in bad endian, so converting this, we get #+BEGIN_SRC ?&H1234 7001 1234 9425 D7B0 0880 0001 #+END_SRC In addition, following [1], we strip the terminating 0x0030 symbol. Otya remarks that the results of previous compilations will not be cleared, and thus old data may be present after the 0x0030 symbol. Another comparison. JP 3.2.1 [1] #+BEGIN_SRC ?ATAN(1,2) 725B 0001 0002 9425 C5CC 0880 0001 #+END_SRC US 3.3.2 #+BEGIN_SRC ?ATAN(1,2) 725B 0001 0002 9425 D7B0 0880 0001 #+END_SRC (raw: ~0x2fffa6: 0x725b0000 0x00020001 0xd7b09425 0x00010880~) >>24069 This one is... strange. #+BEGIN_SRC GOTO @L:@L B41C FF9C 004F 0030 #+END_SRC #+BEGIN_SRC GOTO (@L):@L DC1D 0002 0040 004C #+END_SRC "ラベル名が変わってもコンパイル結果は同じ" [1] (The compilation result is the same even if the label name changes) >>24068 "OPTION自体はコンパイル後に何も残さない" [1] (OPTION by itself does not leave any compiled code) Confirmed here for the real case. [1] Otya 2017, [[http://old.otyakai.xyz/petitcom/?%E3%82%B3%E3%83%B3%E3%83%91%E3%82%A4%E3%83%AB%E7%B5%90%E6%9E%9C]["コンパイル結果" (Compilation results)]]
the GOTOs are different because GOTO @L uses a static label and is probably optimized more than GOTO(@L) which uses a string
~X=ABS(&H1234)~ ~ABS &H1234 OUT X~
>>24091 #+BEGIN_SRC X=ABS(&H1234) B048 1234 FF94 004F #+END_SRC #+BEGIN_SRC ABS &H1234 OUT X 00B5 7001 1234 1425 D3E4 0880 0101 A800 FF94 004F #+END_SRC Otya ran something similar: #+BEGIN_SRC X=ACOS(1) B059 0001 2BB8 006E #+END_SRC #+BEGIN_SRC ACOS 1 OUT X 00B5 7001 0001 1425 C464 0880 0101 A800 2BB8 006E #+END_SRC
`?X#==1` `?X#==1#`
#+BEGIN_SRC ?X%==1 0213 FF94 004F 0001 6002 9425 D7B0 0880 0001 #+END_SRC #+BEGIN_SRC ?X#==1 0213 FF94 004F 0001 6002 9425 D7B0 0880 0001 #+END_SRC #+BEGIN_SRC ?X#==1# 0313 FF94 004F 0000 0000 0000 3FF0 6002 9425 D7B0 0880 0001 #+END_SRC
~?#TRUE~ ~?TRUE~ ~?1~ ~?2*PI()~ ~?6.2831853071795862~
cool
>>24097 #+BEGIN_SRC ?#TRUE ?TRUE ?1 7001 0001 9425 d7b0 0880 0001 #+END_SRC all the same #+BEGIN_SRC ?2*PI() 7801 2D18 5444 21FB 4019 [PRINT:9425...] ?6.2831853071795862 7801 2D18 5444 21FB 4019 [PRINT:9425...] #+END_SRC also pre-evaluated.
#+BEGIN_SRC ? ABS 1 OUT A ? ACCEL OUT ,, ? ACLS ? ASC "A" OUT A ? ASIN 1 OUT A ? ATAN 0 OUT A ? ATAN 1,0 OUT A ? ATTR 0 ? BACKCOLOR 0 ? BACKCOLOR OUT A ? BACKTRACE ? BEEP ? BIN$ 0 OUT S$ 9425 D7B0 0880 0000 ;[?] 00B5 7001 0001 1425 D3E4 0880 0101 A800 EF98 004F ;[ABS 1 OUT A] 9425 D7B0 0880 0000 ;[?] 01B5 1425 DD94 0880 0300 0800 0800 8800 ;[ACCEL OUT ,,] 9425 D7B0 0880 0000 ;[?] 9425 DE24 0880 0000 ;[ACLS] 9425 D7B0 0880 0000 ;[?] 00B5 7C00 0001 0041 1425 D2A0 0880 0000 0101 A800 EF98 004F ;[ASC "A" OUT A] 9425 D7B0 0880 0000 ;[?] 00B5 7001 0001 1425 D624 0880 0101 A800 EF98 004F ;[ASIN 1 OUT A] 9425 D7B0 0880 0000 ;[?] 00B5 7001 0000 1425 D66C 0880 0101 A800 EF98 004F ;[ATAN 0 OUT A] 9425 D7B0 0880 0000 ;[?] 00B5 7001 0000 7001 0001 1425 D66C 0880 0102 A800 EF98 004F ;[ATAN 1,0 OUT A] 9425 D7B0 0880 0000 ;[?] 7001 0000 9425 D084 0880 0001 ;[ATTR 0] 9425 D7B0 0880 0000 ;[?] 7001 0000 9425 DE90 0880 0001 ;[BACKCOLOR 0] 9425 D7B0 0880 0000 ;[?] 00B5 1425 DE90 0880 0100 A800 EF98 004F ;[BACKCOLOR OUT A] 9425 D7B0 0880 0000 ;[?] 9425 D234 0880 0000 ;[BACKTRACE] 9425 D7B0 0880 0000 ;[?] 9425 DF68 0880 0000 ;[BEEP] 9425 D7B0 0880 0000 ;[?] 00B5 7001 0000 1425 D354 0880 0101 A800 EF88 004F ;[BIN$ 0 OUT S$] #+END_SRC
?1 || 2 ?1 + 2
(oops I just remembered 1+2 is precompiled (though 1||2 isn't)) maybe try ?A||B and ?A+B too I guess
.
>>26136 sorry about that, here it is #+BEGIN_SRC A=1 B=2 ?&HDEADBEEF ?1||2 ?&HDEADBEEF ?A||B ?&HDEADBEEF ?A+B b001 0001 ff94 004f ;A = 1 b001 0002 ef88 004f ;B = 2 [7401 beef dead 9425 d7b0 0880 0001] 1214 0001 0000 1420 002f ffd8 1214 0002 0000 6002 [..] ;1||2 [..] 0214 ff94 004f 0000 1420 0006 0030 0214 ef88 004f 0000 6002 [..] ;A||B [..] 6008 ff94 004f ef88 004f [..] ;A+B 0030 ;terminating #+END_SRC