biged_bbcmicro_6502_vc3-2022 Author: BigEd Category: Christmas Challenge System: Acorn BBC Micro Language: Assembler as built in to BBC Basic 2 Len source code: not applicable Len exe file: 59 Len code only: 59 Instructions: Visit owlet with a recent browser using this URL https://bbcmic.ro/#%7B%22v%22%3A1%2C%22program%22%3A%22REM%20PROCbas%3AEND%5Cn%5CnM%3D%264F%20%3A%20REM%20an%20uninitialised%20variable%5CnC%3DM%2B1%5Cn%5Cnzp%3DC%5Cnord0%3Dzp%3A%20zp%3Dzp%2B1%20%3A%20%3Ford0%3DASC%5C%22*%5C%22%5Cnord1%3Dzp%3A%20zp%3Dzp%2B1%20%3A%20REM%20Y%5Cnord2%3Dzp%3A%20zp%3Dzp%2B1%20%3A%20REM%20X%5Cnord3%3Dzp%3A%20zp%3Dzp%2B1%20%3A%20%3Ford3%3D31%20%3A%20REM%20TAB%28x%2Cy%29%5Cn%5CnFOR%20I%3D0%20TO%202%20STEP%202%5CnP%25%3Dzp%3A%5B%20OPT%20I%5CnLDY%20%2317%5Cn.loopy%20STY%20M%5Cn.X0%20%20%20%20LDX%20%236%5Cn.loopx%5Cn.Y2%20%20%20%20LDA%20%2318%20%3A%20JSR%20twostar%5Cn.Y1%20%20%20%20LDA%20%2310%20%3A%20JSR%20twostar%5CnINX%20%3A%20DEC%20M%5CnBNE%20loopx%5CnINC%20X0%2B1%20%3A%20INC%20Y1%2B1%20%3A%20DEC%20Y2%2B1%5CnDEY%20%3A%20DEY%5CnBPL%20loopy%5Cn%5Cn.done%20%20BMI%20done%20%20%5C%5C%20silent%20exit%20costs%20a%20byte%5Cn%5C%5CRTS%20%5C%5C%20back%20to%20basic%20prints%20ugly%20prompt%5Cn%5Cn.twostar%20%20JSR%20onestar%5Cn.onestar%20%20STA%20ord1%20%3A%20STX%20ord2%5CnLDX%20%233%5Cn.vduloop%20%20LDA%20ord0%2CX%20%3A%20JSR%20%26FFEE%5CnDEX%5CnBPL%20vduloop%5CnLDA%20ord2%20%3A%20LDX%20ord1%5CnRTS%5Cn%5Cn%5D%5CnNEXT%5Cn%5CnREM%20*SAVE%20STAR%2050%208B%2054%5CnVDU%2030%5CnPRINT%20%3BP%25-C%5C%22%20bytes%20from%20%26%5C%22~C%5C%22%20to%20%26%5C%22~P%25%5CnREM%20STOP%5CnPRINT%20~USR%20zp%5CnEND%5Cn%5CnREM%20original%20BASIC%5CnDEF%20PROCbas%5CnY1%3D10%3AY2%3D18%5CnX0%3D6%5CnL%3D17%5CnREPEAT%5CnX%3DX0%5CnFOR%20M%3D1%20TO%20L%5CnVDU%2031%2CX%2CY2%2C42%5CnVDU%2031%2CY2%2CX%2C42%5CnVDU%2031%2CX%2CY1%2C42%5CnVDU%2031%2CY1%2CX%2C42%5CnX%3DX%2B1%5CnNEXT%20M%5CnX0%3DX0%2B1%5CnY1%3DY1%2B1%3AY2%3DY2-1%5CnL%3DL-2%5CnUNTIL%20L%3C-1%5CnENDPROC%22%7D OR Visit jsbeeb with a recent browser using this URL https://bbc.godbolt.org/ From the menu, choose "Discs" and then "From Examples or Local" Select "Choose File" In your file chooser find and select "biged6502.ssd" Type */STAR STAR has a load address of 0050 and an execution address of 0054 Description: Drawing four triangles, two at a time by flipping X and Y Using the (decreasing) length of the line drawn as the termination condition Only using increment and decrement, no arithmetic Managing to use both X and Y registers as globals Using and modifying literals in the code to avoid variable allocation and initialisation Equivalent basic would be something like 440 Y1=10:Y2=18 450 X0=6 460 L=17 470 REPEAT 480 X=X0 490 FOR M=1 TO L 500 VDU 31,X,Y2,42 510 VDU 31,Y2,X,42 520 VDU 31,X,Y1,42 530 VDU 31,Y1,X,42 540 X=X+1 550 NEXT M 560 X0=X0+1 570 Y1=Y1+1:Y2=Y2-1 580 L=L-2 590 UNTIL L<-1 600 ENDPROC Comments: Decided to go into an infinite loop at the end, which costs one byte compared to RTS. But the RTS to Basic would then print the ">" prompt which spoils the pattern a bit.