Author Topic: Goto statement support  (Read 5552 times)

0 Members and 1 Guest are viewing this topic.

Offline gumby

Goto statement support
« on: November 13, 2010, 08:28:13 AM »
EDIT: Whoops, this should probably have been posted in the 'SCI How To' forum (or maybe put into the tutorials).

It would have been a show-stopper without 'goto' support for my current project if I hadn't stumbled on this example in the Studio help files under 'Inline Assembly':
Code: [Select]
(if(something)
  (asm jmp _a_goto_label)
)
(asm _a_goto_label: )
I don't know why anyone would need this functionality under normal circumstances, but I certainly did (code conversion from Inform-ish to SCI).  Hope it helps someone out in the future.
« Last Edit: November 13, 2010, 08:31:13 AM by gumby »


In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline gumby

Re: Goto statement support
« Reply #1 on: February 17, 2011, 09:59:51 PM »
Okay, so I've attempted to use this & it doesn't work in Companion - won't compile.  I did find a comment in the Avoid script that might indicate that assembly calls aren't implemented yet.

It does work in Studio, however.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline lance.ewing

Re: Goto statement support
« Reply #2 on: February 18, 2011, 08:13:27 AM »
Okay, so I've attempted to use this & it doesn't work in Companion - won't compile.  I did find a comment in the Avoid script that might indicate that assembly calls aren't implemented yet.

It does work in Studio, however.

I'm surprised that even SCI Studio supports it. It diverges from the higher level language with snippets of vm code in there. Of course I've made use of such features in the C and Pascal compilers of old but in a language like SCI it doesn't quite feel right. I'd imagine that it would create all sorts of problems for a SCI decompiler if someone happened to be thinking of attempting to write one (ahem). A decompiler on seeing a jmp instruction would assume it was tied to an if/else or a loop of some sort. A jmp in insolation might confuse it a bit. It would have no option other than to represent it as a goto.

Offline gumby

Re: Goto statement support
« Reply #3 on: February 18, 2011, 10:37:00 AM »
It wasn't my first choice to use assembly for sure.  I'd prefer it if I could use looping constructs instead, but the code I'm attempting to port to SCI was the result of a decompilation itself, and it chose to utilize jumps instead of loops.

Must be something that Brian just decided to implement on his own; I couldn't find reference to it in the SCI specs.  For those interested, here is the 'Inline Assembly' doc in the SCI Studio Help file:  http://sierrahelp.com/SCI/SCIStudio3Help/SCC/Inline_Assembly.html
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.033 seconds with 23 queries.