+Gemintronic #1 Posted July 27, 2010 SeaGtGruff tried to explain how different assembly kernels can be use via gosub and inline asm code. As an experiment I tried to gosub an asm example on Random Terrains web-site and it will not go. What is poor, confused TheLoon doing wrong? rem Compiler options set smartbranching on set kernel_options no_blank_lines rem Declare constants playfield: ................................ .XXX..XX..X..X.XX..X.X.XXX.X..X. .X..X.X.X.X..X.X.X.XX..X...XX.X. .X..X.XX..X..X.X.X.X.X.XX..X.XX. .XXXX.X.X..XX..X.X.X.X.XXX.X..X. ................................ ...XXX...XX...XX..XXX..XXX.XX... ...X..X.X..X.X..X.X..X.X...X.X.. ...XXX..X..X.X..X.XXX..XX..XX... ...X.....XX...XX..X....XXX.X.X.. ................................ end draw_title drawscreen if joy0fire then gosub pfclear goto draw_title pfclear asm ldx #47 lda #0 playfieldclear sta playfield,x dex bne playfieldclear end return Quote Share this post Link to post Share on other sites
+batari #2 Posted July 27, 2010 My guess would be this: sta playfield,x That should be: sta playfield,x Quote Share this post Link to post Share on other sites
+Gemintronic #3 Posted July 27, 2010 It worked! Random Terrain might and to update his awesome pages. Batari to the rescue!! I have to say, I get the feeling that one of the original intentions of Batari BASIC was to ease people into assembly. My initial reaction is that, if BASIC is a better, more understandable tool then assembly is unnecessary. My new view is that assembly doesn't always have to be incomprehensible or incompatible with BASIC. Batari and people making mini kernels like RevEng are slowly broadening my horizons on the subject. Quote Share this post Link to post Share on other sites
SeaGtGruff #4 Posted July 28, 2010 I have to say, I get the feeling that one of the original intentions of Batari BASIC was to ease people into assembly. You are exactly right. If you read the README.txt file that came with the first release of batari Basic (version 0.1), it started out as follows: Atari 2600 BASIC Compiler By Fred Quimby __________________________________________ First and foremost: Why did I do this? Answer: Atari 2600 BASIC is intended as a beginner's platform so that one may become accustomed to the intricacies of the system. Although Atari 2600 BASIC is a viable development platform on its own, its real purpose is as a stepping stone toward 2600 programming using assembly language. (Yes, I still have versions 0.1, 0.2, 0.3, 0.35, and 0.99 of batari Basic archived on my computer, as well as various in-between versions from 0.99 to 1.0. And yes, at first Fred called it "Atari 2600 BASIC," before everybody convinced him to call it "batari Basic.") Michael Quote Share this post Link to post Share on other sites
SeaGtGruff #5 Posted July 28, 2010 draw_title drawscreen if joy0fire then gosub pfclear goto draw_title pfclear asm ldx #47 lda #0 playfieldclear sta playfield,x dex bne playfieldclear end return Although batari already solved your problem, I want to point out something about mixing inline assembly routines with batari Basic routines. When you compile a batari Basic program, the batari Basic compiler adds a dot in front of each batari Basic line label, but it leaves any line labels between "asm" and "end" unaltered. For example, consider the following: myroutine asm ; bunch of assembly code here anotherlabel ; some more assembly code here end return When you compile the program, the "myroutine" label will end up being called ".myroutine" in the compiled assembly listing, but "anotherlabel" will be left as just "anotherlabel" (i.e., without a leading period). This won't affect your "gosub," because you would just type "gosub myroutine," which will be compiled into "jsr .myroutine" (i.e., the dot will be added for you. But if you want an instruction within your inline assembly code to call or jump to a batari Basic line label, you'll need to include the leading dot manually, as in the following example: loop drawscreen if joy0fire then goto myroutine rem * Notice that I changed the "gosub" to a "goto" goto loop myroutine asm ; bunch of assembly code here cpx something beq anotherlabel ; some more assembly code here anotherlabel ; yet more assembly code here dex bne .myroutine jmp .loop end Both "loop" and "myroutine" are line labels in the batari Basic code. When the batari Basic compiler compiles the batari Basic code into its equivalent assembly code, "loop" will be changed to ".loop," "goto loop" will be changed to "jmp .loop," "myroutine" will be changed to ".myroutine," and "goto myroutine" will be changed to "jmp .myroutine." On the other hand, "anotherlabel" is inside the inline assembly code, so it will be left as "anotherlabel." Therefore, if you want to branch or "jmp" or "jsr" to either "loop" or "myroutine" from within your inline assembly code, you need to reference them as ".loop" and ".myroutine," as shown above. But if you want to branch or "jmp" or "jsr" to "anotherlabel" from within your inline assembly code, you need to reference it as just "anotherlabel," as shown above. Michael Quote Share this post Link to post Share on other sites