![]() |
Learning ASM and ZX Basic Compiler - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: Learning ASM and ZX Basic Compiler (/showthread.php?tid=371) |
Learning ASM and ZX Basic Compiler - oblo - 08-22-2011 Hi all I know it's a bit odd to ask this, because the compiler doesn't ask us to learn ASM but... I'm starting to learn some ASM and besides read some books, I'm trying to get some examples from <!-- m --><a class="postlink" href="http://stu.pido.us/wiki/retrogames:index">http://stu.pido.us/wiki/retrogames:index</a><!-- m --> and <!-- m --><a class="postlink" href="http://members.fortunecity.com/jonathan6/egghead/id2.html">http://members.fortunecity.com/jonathan ... d/id2.html</a><!-- m -->, but every piece of code I try to compile between ASM and END ASM, end with a compiler error, for instance: Code: ASM ...ends with "temp.bor:11: Error: illegal preprocessor character '$'. Compilation failed" And: Code: ASM ...ends with "temp.bor:3: Error: Syntax error. Unexpected token 'LD' [LD]. Compilation failed" Is there any consideration to use ASM code in the compiler, the code examples are wrong... or have I to use another compiler, like PASMO, to compile ASM? Thanks in advance and cheers EDIT: I've just found this post (<!-- l --><a class="postlink-local" href="http://www.boriel.com/forum/bug-reports/illegal-preprocessor-errors-on-some-files-solved-t603.html">bug-reports/illegal-preprocessor-errors-on-some-files-solved-t603.html</a><!-- l -->) but I can't manage to solve it ![]() Re: Learning ASM and ZX Basic Compiler - britlion - 08-24-2011 oblo Wrote:I know it's a bit odd to ask this, because the compiler doesn't ask us to learn ASM but... Actually, since I started playing with the compiler, I've learned a pile of assembly - up to doing some quite complex things (have a look at the library section of the wiki; I've put quite a few assembly routines in there). What you have to remember is that this is designed to compile code, so you are better off wrapping it in ZX basic, such that it's called from there. Also, different assemblers (or in this case, compilers) have their own little foibles. oblo Wrote: I've reworked this routine into a pattern that is probably good programming practice for such things. I've put the end on, even though it never really gets there - it jumps back to the loop bit forever. Code: SUB fastcall printstring () Things to note - I've wrapped this into a ZX Basic Subroutine, so it's called like any other ZX Basic Subroutine. Labels are followed with a colon. That was the main problem with the original version - it's loop: to have a label called loop. You can't do label EQU $, but you can subtract the value of one label from another in a very similar way. Quoting in a DEFB requires " each side, not ' For your other routines, try making labels with a : at the end. For some examples, have a look at the Wiki: <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Library">http://www.boriel.com/wiki/en/index.php ... IC:Library</a><!-- m --> Hope this helps! Re: Learning ASM and ZX Basic Compiler - boriel - 08-24-2011 Note: EQU $ is something that I don't think should be supported because It can be written this way: Code: Asm Re: Learning ASM and ZX Basic Compiler - britlion - 08-24-2011 boriel Wrote:Note: EQU $ is something that I don't think should be supported because It can be written this way: Exactly my solution! Using EQU $ is a bit long winded. It just means "a label which has a value of here" when all labels have that anyway! Re: Learning ASM and ZX Basic Compiler - oblo - 08-25-2011 Thanks to both! I hope learn a lot of ASM playing with it ![]() Cheers |