HELLO-WORLD -------------------------------------------------------------------------------------------------- TOOL: Built-In ML-Monitor {Commodore C128} Language: Assembler Extra: Files are on floppy disk Author: Misel Zivanovic Note: (C) 11th DEC 2025 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- This just looks like the Text-Transfer example! Really! My honest word! Hmmm... Major difference is: we are transferring the HELLO-WORLD text just beneath our assembly code! And read it then from there. When you save the code from $1300 t0 $1319 with S command in ML-Monitor or in BASIC with BSAVE command then you have a finished Hello-World code which can be called with SYS 4864 -------------------------------------------------------------------------------------------------- hello-world t 0400 040a 130e d 1300 1319 . 01300 a2 00 ldx #$00 . 01302 bd 0e 13 lda $130e,x . 01305 9d 08 06 sta $0608,x . 01308 e8 inx . 01309 e0 0a cpx #$0a . 0130b d0 f5 bne $1302 . 0130d 60 rts . 0130e 08 php . 0130f 05 0c ora $0c . 01311 0c ??? . 01312 0f ??? . 01313 2d 17 0f and $0f17 . 01316 12 ??? . 01317 0c ??? . 01318 04 ??? . 01319 00 brk -------------------------------------------------------------------------------------------------- ALL EXPLAINED: We write HELLO-WORLD in the left upper corner {see screenshot} and use: t 0400 040a 130e to transfer it to $0130e location where we need it! You can write the code first or do the transfer! The code isn't going over $130d and won't overwrite HELLO-WORLD. a 01300 a2 00 ldx #$00 x register to zero a 01302 bd 0e 13 lda $130e,x load our data from $130e + x a 01305 9d 08 06 sta $0608,x and transfer it to $0608 + x a 01308 e8 inx increment the x register + 1 a 01309 e0 0b cpx #$0b check x register, is it $0b {dec 11} a 0130b d0 f5 bne $1302 it is not, then LOOP again a 0130d 60 rts Return To Subroutine . 0130e 08 php NOTE: This is not PHP mnemonic, it is our letter H . 0130f 05 0c ora $0c So all this below is actually HELLO-WORLD and . 01311 0c ??? not any kind of strange assembly code! . 01312 0f ??? Remember, we've transferred HELLO-WORLD to this location . 01313 2d 17 0f and $0f17 with ML-Monitor Transfer command, which is T . 01316 12 ??? After writing HELLO-WORLD in the left upper corner . 01317 0c ??? according to screenshot, this -> t 0400 040a 130e . 01318 04 ??? is transferring it to $0130e . 01319 00 brk Easy, right! --------------------------------------------------------------------------------------------------- MACHINE-LANGUAGE-MONITOR CODE LISTING: {If you paste this code into ML-Monitor of C128, then you can avoid manual corrections which} {are practically mandatory when you paste the assembled code from above} {This below is exactly the same code as above!} --------------------------------------------------------------------------------------------------- m 1300 >01300 a2 00 bd 0e 13 9d 08 06:B....... >01308 e8 e0 0b d0 f5 60 08 05:H..PU... >01310 0c 0c 0f 2d 17 0f 12 0c:...-.... >01318 04 00 --------------------------------------------------------------------------------------------------- HOW TO SAVE IT TO DISK? Machine Language Monitor: To save ML source code to floppy disk we can use ML-Monitor S command or BSAVE command in BASIC. {you must exit the ML-Monitor with X before you can use BSAVE command!} By now you have probably read the Commodore-C128-ML-Monitor.pdf file and know how S command can be used. If not, here you go: s "hello-world",08,$1300,$1319 NOTE: You can copy/paste this line to VICE emulator. That is why i wrote all small. The reason why i am including 1 bye more = $1319 and not $1318 {this is where the code actually ends} is because it needs one byte more to save everything! That is valid also for the BSAVE command in BASIC 7.0 From BASIC 7.0: BSAVE command is what is needed as mentioned. You need to convert the numbers to decimal values to save assembler code. You cannot directly use hexadecimal numbers with this command. However, there is a little help {command} which allows you to do exactly that! See further below!* $1300 = 4864 decimal, program size is $0019 bytes = 25 decimal So this here will do the magic: bsave"hello-world",b0,p4864top4864+25 With the time you'll have all the important start addresses in your head and that will be then your most faithful 'converter', hehe *= Now here is how also it is possible to save a machine code from BASIC 7.0 without sweating the converter grey cells: bsave"hello-w.ml",b0,p(dec("1300"))top(dec("1319")) saving 0:hello-w.ml ready. That was all smooth and nice! --------------------------------------------------------------------------------------------------- NOW LET'S TALK ABOUT THE PROBLEMS HERE! 1. You have no idea where this is going! {You can however say where to load it during the BLOAD process} 2. We clearly need smarter names for the files HOW CAN WE GET RID OF THIS ISSUES? 1. BLOAD can load ML-Code file to a specific location! e.g. bload"hello-w.ml",b0,p(dec("1400")) So it is here now, $1400, dec 5120 and can be called from BASIC with SYS 5120 WARNING!: Even if this code is small it is NOT relocatable! Most actually aren't and then your system will most likely crash when you try to start it. NOTE: This one will work anyway with SYS 5120 but only because it is taking HELLO-WORD from $1300. It will work even if you delete $130e - $1318, however it will deliver whatever is found later between $130e - $1318! Meaning, nothing or something! But it will NOT crash the system! In other words, loading ML-Code to a specific location is useful, but with good portion of precaution! 2. Much better solution is to choose a file name which is going to give you the needed information when you deal with standalone ML-Code. {Meaning those which aren't loaded from BASIC as part of the main Programm and you don't have to deal with them in first place} e.g. bsave"h1300-hworld.ml",b0,p4864top4864+25 e.g. bsave"d4864-hworld.ml",b0,p4864top4864+25 e.g. bsave"reloc-sprite.ml",b0,p3584top3584+64 {Sprite location of the 1st sprite} Now we know where it will go and we know if it can be relocated! h = hexadecimal d = decimal reloc = relocatable You'll know even in 20 years what you have and can do! Example of the code that is RELOCATABLE: As you can see, after the transfer to $1600 from $1500, it will still work! a 01500 a9 08 lda #$08 a 01502 8d 20 d0 sta $d020 a 01505 a9 09 lda #$09 a 01507 8d 21 d0 sta $d021 a 0150a a9 51 lda #$51 a 0150c a2 00 ldx #$00 a 0150e 9d 00 04 sta $0400,x a 01511 e8 inx a 01512 e0 c8 cpx #$c8 a 01514 d0 f8 bne $150e a 01516 60 rts ML-CODE: m 1500 >01500 a9 08 8d 20 d0 a9 09 8d:I.. PI.. >01508 21 d0 a9 51 a2 00 9d 00:!PIqB... >01510 04 e8 e0 c8 d0 f8 60 00:.H.HPX.. --------------------------------------------------------------------------------------------------- t 1500 1516 1600 d 1600 1616 . 01600 a9 08 lda #$08 . 01602 8d 20 d0 sta $d020 . 01605 a9 09 lda #$09 . 01607 8d 21 d0 sta $d021 . 0160a a9 51 lda #$51 . 0160c a2 00 ldx #$00 . 0160e 9d 00 04 sta $0400,x . 01611 e8 inx . 01612 e0 c8 cpx #$c8 . 01614 d0 f8 bne $160e . 01616 60 rts ML-CODE: m 1600 >01600 a9 08 8d 20 d0 a9 09 8d:I.. PI.. >01608 21 d0 a9 50 a2 00 9d 00:!PIpB... >01610 04 e8 e0 c8 d0 f8 60 00:.H.HPX.. ---------------------------------------------------------------------------------------------------