MERLIN 7501 ASSEMBLER - FOR COMMODORE PLUS4 --------------------------------------------------------------------------------------------------- By mzretro.ch , lived.ch - 13:33 17.07.2026 --------------------------------------------------------------------------------------------------- LATEST UPDATE: 15.08.2026 --------------------------------------------------------------------------------------------------- This one looks good and it is the first assembler i tried. I was probably attracted by the name MERLIN, haha.. It is using a BASIC editor for its source code. Unfortunately, i can't find any instructions about it and that is why i have explore it and made little manual which will help you to start with the MERLIN 7501 ASSEMBLER for Commodore Plus4. Probably there are more features, but so far this is all I was able to figure out about it! If I'll be able to find more in the future, I'll add it! In general, this is a fun to use little assembler. Not complicated and it's fast enough to enjoy the assembly coding. I like it! MERLIN 7501 ASSEMBLER, LET'S DO IT: --------------------------------------------------------------------------------------------------- The most important DIRECT Command {no line numbers} is: ASM - this will assemble the code and it can then be called with - SYS {START ADDRESS}, see next lines below! - It's important to keep the command left aligned or you'll get an error message! --------------------------------------------------------------------------------------------------- According to examples on the disk, COM is equal to .ORG $3000 or * = $3000 for the start address like it's used in other assemblers. Following line: 100 COM $3000 - is the start address. - so it's the location where the source code will be assembled. - I noticed that $1000 and $2000 cannot be used! {*occupied by Merlin Assembler} - And then, your source code is also in that area in addition to Merlin 7501. It's basically going up from $2000 - Your SOURCE CODE is starting from $2100. dec 8448 and going up! *=messages for com $1000 asm and com $2000 merlin: 7501 plus 4/c16 assembler. assembling not possible! (c) wizard 1986. by s.northcott. warning:merlin's residence. If the start address is $3000 and your source code is located from $2100 and going up, it means that you have around 3840 bytes for the source code {$3000 - $2100} If you are using custom characters from $3800, as you can see, the start address $3000 will allow you only 2048 bytes of assembly code {$3800 - $3000 = $0800} 2048 BYTES!!! IS THAT A LOT? ------------------------------- It depends! In any case, already a 512 bytes of assembly code is a lot! {IRQ ANIM CHARACTERS is offering 16 animated and 10 still custom characters in } {normal/inverse mode. It is only 412 bytes small! IRQ driven and can be disabled! } I NEED MORE! WHAT CAN BE DONE!? ------------------------------ There actually is a solution. Not even a complicated one! Default MERLIN 7501 Assembler Source Code address is obviously $2100. As I was interested too in moving that away from that area which is actually a great ground for the assembly code, when you do not use high resolution graphics! ******************************************************************* Just type this in {choose what you need}, in DIRECT Mode BEFORE you start coding or LOAD a SOURCE CODE FROM the FLOPPY DISK! ******************************************************************* ------------------------------------------------------------------- This will move YOUR MERLIN SOURCE CODE from default $2100 to $7000: DIRECT MODE COMMAND: poke 43,1:poke44,112:poke 28672,0:new ------------------------------------------------------------------- ------------------------------------------------------------------- This will move YOUR MERLIN SOURCE CODE from default $2100 to $6000: DIRECT MODE COMMAND: poke 43,1:poke44,96: poke 24576,0:new ------------------------------------------------------------------- ------------------------------------------------------------------- This will move YOUR MERLIN SOURCE CODE from default $2100 to $5000: DIRECT MODE COMMAND: poke 43,1:poke44,80: poke 20480,0:new ------------------------------------------------------------------- ------------------------------------------------------------------- This will move YOUR MERLIN SOURCE CODE from default $2100 to $4000: DIRECT MODE COMMAND: poke 43,1:poke44,64: poke 16384,0:new ------------------------------------------------------------------- This small changes will makes it possible to use $2100 as the start address {100 COM $2100} for your assembly code {the so called object file} If you have moved the source code to any above mentioned location, that would give you a close to 6KB memory! That is: Until $3800! Which is the area used for the custom characters) for the assembly code. Custom characters would be from $3800 - $4000! And {later} in BASIC, with the commands: 10 GRAPHIC 1:GRAPHIC 0 you can move BASIC START to $4000 and have around 40KB free from there for the BASIC ideas and the access to your assembly routines between $2100 - $3800 and custom characters form $3800 to $4000. Well, if that isn't just GREAT! Now only your imagination is your limit! NOTE: This is only so with the MERLIN 7501 Assembler. In case you of using other assemblers or code in an Cross-Assembler environment, this is then a completely other story! --------------------------------------------------------------------------------------------------- 100 LIST - will list the assembled code {optional}. - if no list is used, you'll just get this message and a "ready" "merlin: 7501 plus 4/c16 assembler. (c) wizard 1986. by s.northcott." ready. If the LIST command is added at the beginning of the source code, assembled code will be shown: This view is needed in case you want to see if your low and high byte addresses are correct. And also if you need to POKE a specific address to change a color or maybe to just PEEK the address value and see from BASIC if it is the one you need to continue with the program execution. 3000 ad 1d ff lda $ff1d 3003 a2 0b ldx #$0b 3005 ca dex 3006 ea nop 3007 ea nop 3008 ea nop 3009 ea nop 300a d0 f9 bne $3005 300c cd 1d ff cmp $ff1d 300f f0 fb beq $300c 3011 ad 15 ff lda $ff15 3014 18 clc 3015 69 10 adc #$10 3017 8d 15 ff sta $ff15 301a 29 f0 and #$f0 301c c9 00 cmp #$00 301e d0 e0 bne $3000 3020 ee 15 ff inc $ff15 3023 ea nop 3024 ea nop 3025 ea nop 3026 4c 00 30 jmp $3000 Do you need to list the code? In some cases yes, in some not. When you have the code so far that all is set and only small changes are necessary, then no LISTING is needed. However, there are cases when you need to see the address in order to adapt your code! Example: {code is readdressing the IRQ, changing the border color and exiting IRQ, setting the default values!} It looks like there is no way to enter LOW and HIGH byte like that is possible with the other assemblers {or I can't find out how to do it} LIST command can be used to find out the correct addresses {LOW and HIGH byte} This below will NOT WORK! This below WILL WORK, HOWEVER...! 100 com $3000 100 com $3000 105 sei 105 list 108 ; 108 sei 110 lda #<.start 110 lda #$00 ;place holder LB 120 sta $0314 120 sta $0314 130 lda #>.start 130 lda #$00 ;place holder HB 140 sta $0315 140 sta $0315 150 cli 150 cli 160 rts 160 rts 170 .start 170 .start 180 inc $ff19 180 inc $ff19 258 sei ;safe exit 258 sei ;safe exit 259 lda #14 ;no reset needed! 259 lda #14 ;no reset needed! 260 sta $0314 260 sta $0314 261 lda #206 261 lda #206 262 sta $0315 262 sta $0315 263 cli 263 cli 264 pla 264 pla 265 tay 265 tay 266 pla 266 pla 267 tax 267 tax 268 pla 268 pla 269 rti 269 rti 270 rts 270 rts asm asm {according to the listing below, LB = #$0d and HB=#$30} {this is what you'd need to enter ABOVE in the source code!} {AND NOT in the assembled listing below!!!} merlin: 7501 plus 4/c16 assembler. 3000 78 sei (c) wizard 1986. by s.northcott. 3001 a9 00 lda #$00 3003 8d 14 03 sta $0314 warning: no end 3006 a9 00 lda #$00 line:00110 ;syntax error 3008 8d 15 03 sta $0315 line:00130 ;syntax error 300b 58 cli warning: no end 300c 60 rts syntax error 300d ee 19 ff inc $ff19 3010 78 sei ready. 3011 a9 0e lda #$0e 3013 8d 14 03 sta $0314 3016 a9 ce lda #$ce 3018 8d 15 03 sta $0315 301b 58 cli 301c 68 pla 301d a8 tay 301e 68 pla 301f aa tax 3020 68 pla 3021 40 rti 3022 60 rts I hope i managed to explain this understandable! --------------------------------------------------------------------------------------------------- HOW TO LOOP IN MERLIN 7501 ASSEMBLER AND THE USAGE OF LABELS! --------------------------------------------------------------------------------------------------- 100 LDX #$00 110 .JUMP - Label 120 INX 130 LDA #$51 140 STA $0C00,x 150 CPX #$28 160 BNE .JUMP - Branch if Not Equal to Zero {it's like a FOR NEXT LOOP in BASIC} - Basically, it's branching as long as X-Register is less than 28! is a label to use with BRANCH {BEQ, BNE, BCC etc.} or JUMP {JMP, JSR} instructions --------------------------------------------------------------------------------------------------- Variable is a thing you just must? use with the time. Especially when the project gets big! How do you assign a value to a variable? 100 .SCREEN=$0C00 - from now on, SCREEN has a value of $0C00 or dec 3072 - you noticed, it is the same as a label, just with equal = sign and - the assigned value. To us it when needed, is also easy and done like this: 100 STA .SCREEN,x - start from the first screen line 100 STA .SCREEN+40,x - start from the 2nd screen line --------------------------------------------------------------------------------------------------- HANDLING AND ACCESSING: TEXT, NUMBERS, BYTES --------------------------------------------------------------------------------------------------- Basically, you need a label and a prefix to correctly read the data. 100 .title 110 *tx "today is a wonderful day. i like it!" 120 .stats 130 *da 20,10,50,90,75 140 .sprite 150 *da $ff,$ff,$81,$81,$81,$81,$ff,$ff 160 .combo 170 *da $0a,20,$01,$ff,20,20,80,$b0 You would access this like: 10 ldx #$00 20 .loop 30 lda .title,x 40 sta $0C00,x 50 inx 60 bne .loop 70 rts --------------------------------------------------------------------------------------------------- SAVING YOUR WORK {SOURCE CODE} and THE ASSEMBLED CODE! --------------------------------------------------------------------------------------------------- These two guys are very important too. Can't live without it. Loading {source code} files is done with LOAD "file name",8 Saving {source code} files is done with SAVE "file name",8 UNFORTUNATELY!! I see no BSAVE command to save the object code which then can be called with SYS command But this isn SAVING THE ASSEMBLED CODE: --------------------------------------------------------------------------------------------------- FORTUNATELY! Plus4 has a built-in Machine Language Monitor which is accessible while Merlin 8501 Assembly/Editor is running and that means: You can enter the MLM with the MONITOR command and save your assembled code with the 'S' command which is straight forward: S "file name",8,3000,3029 NOTE: As you can see in the assemble listing above, this:"3026 4c 00 30 jmp $3000" is the last line of the assembled code. Now the last address to be saved is +1 or Line: 3026 4c 00 30 jmp $3000 Address: 26 27 28 +1 = 29 or $3029 +1 is VERY IMPORTANT. SO REMEMBER IT! --------------------------------------------------------------------------------------------------- ONE MORE INFORMATION RELATED TO OBJECT SAVING AND END ADDRESS! --------------------------------------------------------------------------------------------------- ... 5118 ad ea 0f lda $0fea 511b 8d 30 3a sta $3a30 511e ad eb 0f lda $0feb 5121 8d 38 3a sta $3a38 5124 ad ec 0f lda $0fec 5127 8d 40 3a sta $3a40 512a a0 00 ldy #$00 512c 8c e8 0b sty $0be8 512f 4c 67 50 jmp $5067 5132 data _ data 513a data _ data 5142 data _ data 514a data _ data 5152 data _ data 515a data _ data 5162 data _ data 516a data _ data 5172 data _ data 517a data _ data 5182 data _ data 518a data _ data 5192 data _ data The END ADDRESS is NOT $5192, but $5192 + 8 BYTES DATA {unless you have more} + 1 = $519b To save the object data properly {assuming the start address is $5000, enter the monitor with the MONITOR command and type: S"animchars5k",8,5000,519b One more time:! This will save the object code, not the source code of MERLIN 7501 assembler! Object code can be loaded from BASIC when Merlin is not present with LOAD "animchars5k",8,1 and then run with sys 20480 {that's why 5k=$5000 or decimal 20480!} --------------------------------------------------------------------------------------------------- COMMENTS --------------------------------------------------------------------------------------------------- Semicolon is used to write comments. It can be used like this {as you have seen already in examples} 100 .ammo 110 lda #$00 ;ammo counter 120 ; 130 .lives 140 lda #$00 ;lives --------------------------------------------------------------------------------------------------- LOW AND HIGH BYTE INCREMENT DECREMENT --------------------------------------------------------------------------------------------------- That's what folks needs and that is what folks will get! Right! All this below is about the +1 in the line 310 so you can see how to access the LOW BYTE in specific memory address. Th access to HIGH BYTE which is the NEXT memory address is similar! Just use +2 and there you go! Of course it must be a 16-bit address {2 BYTES} there and not just 8-bit {1 BYTE} This would work in line 190 {$0c00} where we could INCrement the HIGH BYTE! LOW BYTE is always 1st and the 2nd is the HIGH BYTE! That is why $0c00 is written as $00 {LOW} $0c {HIGH} byte! 99 is a TOKEN for STA! LITTLE ENDIAN System {NOT INDIAN, haha} 3006 99 {0} 00 {+1} 0C {+2} NEVER INC THE ADDRESS {0} because that would change the TOKEN and mostly CRASH YOUR COMPUTER! NOTE: If you have a byte address as a variable for something, little .life example below, then you could/can INC .life without +1 because there is no command, just the value 0! 1000 .life 1010 *da $00 SOURCE with BRANCHING Where the access is going? 100 com $3000 110 .screen=$0c00 120 list 130 ; 140 ldx #$00 3000 a2 00 ldx #$00 150 .loop1 160 ldy #$00 3002 a0 00 ldy #$00 170 .add 180 lda #$00 3004 a9 00 lda #$00 190 sta .screen,y 3006 99 00 0c sta $0c00,y 200 iny 3009 c8 iny 210 cpy #$10 300a c0 10 cpy #$10 220 bne .add 300c d0 f6 bne $3004 230 ldy #$00 300e a0 00 ldy #$00 240 .delay 250 iny 3010 c8 iny 260 lda #100 3011 a9 64 lda #$64 270 .rast 280 cmp $ff1d 3013 cd 1d ff cmp $ff1d 290 bne .rast 3016 d0 fb bne $3013 295 cpy #$10 3018 c0 10 cpy #$10 300 bne .delay 301a d0 f4 bne $3010 310 inc .add+1 301c ee 05 30 inc $3005 320 inx 301f e8 inx 330 cpx #$10 3020 e0 10 cpx #$10 340 bne .loop1 3022 d0 de bne $3002 350 rts 3024 60 rts 360 end --------------------------------------------------------------------------------------------------- END --------------------------------------------------------------------------------------------------- At the end of the code, you can place the END command, e.g. It is not mandatory as it looks, but you'll get rid of the warning every time you run ASM command! End of the code is BEHIND the DATA statement which are usually at the bottom of the code! 1000 END --------------------------------------------------------------------------------------------------- INFORMATION RELATED TO A BLACK SCREEN BACKGROUND! --------------------------------------------------------------------------------------------------- If your screen background is black and you do assemble the code, the cursor will switch to black @ DATA statements and you won't see the memory addresses, just DATA <- DATA and also the cursor won't be visible! Just use C= + colors {1-8} or CONTROL + colors {1-8} to change the cursor color! Or better, don't use the black background! poke 65301,x {1-15} can change it! --------------------------------------------------------------------------------------------------- Plus4 has no RESTORE Key like the C64 or C128 --------------------------------------------------------------------------------------------------- You might end up using this a lot! It's an endless loop where you might run your code and it will exit to BASIC as soon as you press ENTER/RETURN! You can also choose/use any other ASCII code {cmp #$0d = ENTER} . 033c 20 e4 ff jsr $ffe4 . 033f c9 0d cmp #$0d . 0341 f0 03 beq $0346 . 0343 4c 3c 03 jmp $033c . 0346 60 rts This is an example: (SYS 8192) It is using the GRAPHIC area. Do not use GRAPHIC x,1 command or this program will be deleted! YOU MUST HELD down the ENTER key to EXIT! a 3000 a2 00 ldx #$00 a 3002 a9 30 lda #$30 a 3004 cd 1d ff cmp $ff1d a 3007 d0 fb bne $3004 a 3009 a9 0c lda #$0c a 300b 8d 15 ff sta $ff15 a 300e a9 50 lda #$50 a 3010 cd 1d ff cmp $ff1d a 3013 d0 fb bne $3010 a 3015 ee 15 ff inc $ff15 a 3018 ca dex a 301b 20 e4 ff jsr $ffe4 a 301e c9 0d cmp #$0d a 3020 f0 03 beq $2025 a 3019 d0 e7 bne $3002 a 3022 4c 00 20 jmp $3000 a 3025 60 rts a 3026 d 3000 2026 . 3000 a2 00 ldx #$00 . 3002 a9 30 lda #$30 . 3004 cd 1d ff cmp $ff1d . 3007 d0 fb bne $3004 . 3009 a9 0c lda #$0c . 300b 8d 15 ff sta $ff15 . 300e a9 50 lda #$50 . 3010 cd 1d ff cmp $ff1d . 3013 d0 fb bne $3010 . 3015 ee 15 ff inc $ff15 . 3018 ca dex . 3019 20 e4 ff jsr $ffe4 . 301c c9 0d cmp #$0d . 301e f0 05 beq $3025 . 3020 d0 e0 bne $3002 . 3022 4c 00 20 jmp $3000 . 3025 60 rts . 3026 00 brk --------------------------------------------------------------------------------------------------- WHEN INTERRUPTS ARE USED {usually you must reset the PLUS4 to get out} --------------------------------------------------------------------------------------------------- When you read the Commodore Plus4 reference manual, this is what is adviced when IRQ is used!: "When you are finished with this example, reset the computer by typing G FFF6 so as to restore the IRQ vector to its default value." However, it can be done differently, without to force the computer reset!: Use this routine to end the active 0314/0315 IRQ and return to MERLIN assembler where you can continue coding. Your source code will remain untouched! This is also setting to ROM characters access! {remove 251-257 if not needed} Check the IRQ-ANIM-CHARACTERS for the full source code and how it is used there! ... 177 lda $0c00 ;press shift+q 178 cmp #81 ;to exit the 189 beq .out ;interrupt mode! 190 .exit ;where: 191 jmp $ce0e ;left upper corner! 200 ; ;in capitol char mode 250 .out ;exit to basic, no irq 251 lda $ff12 ;read status 252 ora #4 ;set characters 253 sta $ff12 ;back to 254 lda $ff13 ;original 255 and #3 ;rom 256 ora #$d0 ;source 257 sta $ff13 ;$d000-53248 258 sei ;safe exit 259 lda #14 ;no reset needed! 260 sta $0314 261 lda #206 262 sta $0315 263 cli 264 pla 265 tay 266 pla 267 tax 268 pla 269 rti 270 rts --------------------------------------------------------------------------------------------------- OTHER COMMANDS!? --------------------------------------------------------------------------------------------------- I cannot tell if there are more native MERLIN commands, but you can use normal BASIC commands to LIST the source code and do also other things with regular BASIC commands which will impact the MERLIN source code! LIST 100-200 {listing from 100 to 200 LIST -100 {listing until 100} LIST 300- {listing from 300 and up} RENUMBER 10,10 {line renumber from 10 in 10 steps} RENUMBER 100,10 {line renumber from 10 in 10 steps} NEW {and your source code is gone!} AUTO 10 {auto line numbering in 10 steps! E.g. 100, 110, 120 etc.}