C128-ASSEMBLER-ASL-LSR-DUO --------------------------------------------------------------------------------------------------- TOOL: Built-in ML-Monitor {Commodore C128} Language: Machine Language {Assembler} Extra: none Author: Misel Zivanovic Note: (C) 22th of OCTOBER 2026 - www.lived.ch, mzretro.ch Doc Revision: 1.0 Last update: 14:32 22.10.2026 --------------------------------------------------------------------------------------------------- BOTH EXAMPLES BELOW CAN BE CALLED FROM BASIC with SYS 4864! Sooner or later, we all need to face this little gang we've been trying to avoid for decades, well... I was thinking what's the best way to show it. And perhaps this is the solution for this. THESE TWO EXAMPLES ARE SHOWING YOU RESULTS in DECIMAL NUMBERS! Much better than viewing graphical symbols, haha... You'll see exactly what you are dealing with! --------------------------------------------------------------------------------------------------- EXAMPLE: ASL - Arithmetic Shift Left = MULTIPLYING { by 2} --------------------------------------------------------------------------------------------------- This will multiply the accumulator value set in line $130d by 2 Calling it with SYS 4864 the 1st time will result in 2. Calling it the 2nd time, will result in 4, then 8, 16... That is because we are copying the result and saving it back to the location, to have it ready for the next multiplying proces when SYS 4864 is called. In real life situation, you would just need to use ASL 2x in cases you would wanna multiply the result with 4 {value of LDA #$06 * 2 * 2 }. LDA #$01, ASL, ASL We are simulating this by executing the SYS 4864 several times. . 01300 a9 00 lda #$00 . 01302 8d 00 ff sta $ff00 . 01305 a9 93 lda #$93 . 01307 20 d2 ff jsr $ffd2 . 0130a 20 42 c1 jsr $c142 . 0130d a9 01 lda #$01 . 0130f 0a asl . 01310 8d e8 07 sta $07e8 . 01313 85 60 sta $60 . 01315 20 b4 b8 jsr $b8b4 . 01318 20 07 ba jsr $ba07 . 0131b a9 00 lda #$00 . 0131d a2 08 ldx #$08 . 0131f a0 03 ldy #$03 . 01321 20 5d ba jsr $ba5d . 01324 ad e8 07 lda $07e8 . 01327 8d 0e 13 sta $130e . 0132a 60 rts --------------------------------------------------------------------------------------------------- EXAMPLE: LSR - Logical Shift Right = DIVIDE {by 2} --------------------------------------------------------------------------------------------------- The same as above, however in opposite direction. . 01300 a9 00 lda #$00 . 01302 8d 00 ff sta $ff00 . 01305 a9 93 lda #$93 . 01307 20 d2 ff jsr $ffd2 . 0130a 20 42 c1 jsr $c142 . 0130d a9 04 lda #$80 . 0130f 4a lsr . 01310 8d e8 07 sta $07e8 . 01313 85 60 sta $60 . 01315 20 b4 b8 jsr $b8b4 . 01318 20 07 ba jsr $ba07 . 0131b a9 00 lda #$00 . 0131d a2 08 ldx #$08 . 0131f a0 03 ldy #$03 . 01321 20 5d ba jsr $ba5d . 01324 ad e8 07 lda $07e8 . 01327 8d 0e 13 sta $130e . 0132a 60 rts ---------------------------------------------------------------------------------------------------