neilsf / XC-BASIC

A compiling BASIC dialect for the Commodore-64
https://xc-basic.net/
MIT License
74 stars 15 forks source link

GOTO vs GOSUB (noob question) #121

Closed frenchfaso closed 4 years ago

frenchfaso commented 4 years ago

Hello there, what is the main difference between GOTO and GOSUB? is GOTO faster because there is no return to calling point? (but supposedly another GOTO to the continuation point..) Thanks and sorry for the noobnes!

PS: is it ok to post questions here?

neilsf commented 4 years ago

Sure, you can ask questions here. They're both super simple: GOTO translates to JMP and GOSUB translates to JSR. GOTO is indeed a little faster because JSR first pushes the return address onto the stack and then jumps to the destination. The difference is only 3 CPU cycles.

frenchfaso notifications@github.com ezt írta (időpont: 2020. aug. 28., P 18:10):

Hello there, what is the main difference between GOTO and GOSUB? is GOTO faster because there is no return to calling point? (but supposedly another GOTO to the continuation point..) Thanks and sorry for the noobnes!

PS: is it ok to post questions here?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/neilsf/XC-BASIC/issues/121, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHO444KI5GAXPDSDJXJMR3SC7JH7ANCNFSM4QOJGQOQ .

frenchfaso commented 4 years ago

that makes sense, thanks!