TXA-DO-IT -------------------------------------------------------------------------------------------------- TOOL: Built-In ML-Monitor {Commodore C128} Language: Assembler Extra: none Author: Misel Zivanovic Note: (C) 13th DEC 2025 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- The ways to do it and the impact of it. These assembler lines are filling first 5 rows with a little ball. And the next 5 rows then with characters and graphics symbols C128 is offering. As you can see, to switch between this two methods not much was necessary. One TXA did the job for us. {Transfer X-register to Accumulator} What is the difference between part one and part two? 1st part is taking the fill value directly from accumulator. which is a static value of #$51 or dec 81. And that is the value of the little ball. 2nd part is using also the accumulator to fill the rows, however it's not static any more because we are transferring the values from the X-register into accumulator. The X-register values are incremented by one {INX} we are getting different values which makes it possible to display different characters/symbols. d 1300 131a . 01300 a2 00 ldx #$00 . 01302 a9 51 lda #$51 . 01304 9d 00 04 sta $0400,x . 01307 e8 inx . 01308 e0 c8 cpx #$c8 . 0130a d0 f8 bne $1304 . 0130c ea nop . 0130d ea nop . 0130e a2 00 ldx #$00 . 01310 8a txa . 01311 9d c8 04 sta $04c8,x . 01314 e8 inx . 01315 e0 c8 cpx #$c8 . 01317 d0 f7 bne $1310 . 01319 60 rts . 0131a ff ??? --------------------------------------------------------------------------------------------------- ALL EXPLAINED: d 1300 131a a 01300 a2 00 ldx #$00 Set X-register to 0 a 01302 a9 51 lda #$51 load accumulator with #$51 {dec 81} which is a little ball a 01304 9d 00 04 sta $0400,x start from the screen address $0400, dec 1024 {left upper corner} a 01307 e8 inx increment X-register a 01308 e0 c8 cpx #$c8 Is it #$c8 or dec 200 already? a 0130a d0 f8 bne $1304 Not #$c8 then REPEAT. If yes then fall through here to continue! a 0130c ea nop NO Operation a 0130d ea nop {I put this just to visually separate the code a 0130e a2 00 ldx #$00 2-Part, Set X-register to 0 a 01310 8a txa TRANSFER X-register into accumulator a 01311 9d c8 04 sta $04c8,x Display from screen address $04c8 a 01314 e8 inx increment X-register a 01315 e0 c8 cpx #$c8 #$c8 reached? a 01317 d0 f7 bne $1310 No? Repeat a 01319 60 rts Return To Subroutine or BASIC if called from BASIC {SYS 4864} a 0131a ff ??? --------------------------------------------------------------------------------------------------- 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 131a >01300 a2 00 a9 51 9d 00 04 e8:B.Iq...H >01308 e0 c8 d0 f8 ea ea a2 00:.HPXJJB. >01310 8a 9d c8 04 e8 e0 c8 d0:..H.H.HP >01318 f7 60 ff ff ff ff 00 00:W....... --------------------------------------------------------------------------------------------------- OPTIMIZATION Can this code be optimized!? We wasted 26 bytes {incl. NOP's} to achieve the seen results! Not much actually... Well, it can and here it is. These 17 bytes are doing the same as previously 26 {or 24 if we exclude the NOP's) That is 7 bytes less! d 1300 a 01300 a2 00 ldx #$00 a 01302 a9 51 lda #$51 a 01304 9d 00 04 sta $0400,x a 01307 8a txa a 01308 9d c8 04 sta $04c8,x a 0130b e8 inx a 0130c e0 c8 cpx #$c8 a 0130e d0 f2 bne $1302 a 01310 60 rts a 01311 00 brk