In the continuation of the assembly language series, this episode goes over some of the principles of integer arithmetic in TI assembly, including addition, subtraction, multiplication, and division.
In this video, we cover the following:
Math in computing
Math in TI BASIC, in contrast to assembly
Integer format and size
Format of addition, subtraction, multiplication, and division in assembly
Single-byte math operations
Division and modulo
Increment, decrement, and absolute value operands
Perils of register use and readability
Program example - TRIANGLE
TRIANGLE (Assembly language)
Demonstration of assembly from the video. Displays a Sierpinski triangle in bitmap mode.
DEF RUN
REF VSBR,VSBW,VWTR,VMBW
*
VREGS DATA >0002,>01C0,>0206,>03FF
DATA >0403,>05F0,>0600,>07F1
DATA 768
PTS DATA 1,128,190,1,190,250
CURPT DATA 1,128
SEED DATA >23A3
RNDM DATA >1FB9
RNDA DATA >6EFB
INITCH DATA >0000,>0000,>0000,>0000
INITCO DATA >1F1F,>1F1F,>1F1F,>1F1F
CLC DATA 8,256,3,2,4
*
INIT
* SET VDP REGISTERS
LI R4,VREGS
MOV @CLC,R2
DOREG MOV *R4+,R0
BLWP @VWTR
DEC R2
JNE DOREG
* CLEAR SCREEN IMAGE
CLR R0
LI R1,INITCH
LI R2,8
MOV *R4,R3
INCHL1 BLWP @VMBW
A R2,R0
DEC R3
JNE INCHL1
* CLEAR COLOR TABLE
LI R0,>2000
LI R1,INITCO
MOV *R4,R3
INCHL2 BLWP @VMBW
A R2,R0
DEC R3
JNE INCHL2
* RESET PATTERN DESCRIPTOR TABLE
LI R0,>1800
CLR R1
MOV *R4,R3
INCHL3 BLWP @VSBW
AI R1,>0100
INC R0
DEC R3
JNE INCHL3
RT
* GENERATE RANDOM NUMBER
RGEN MOV @SEED,R2
MPY @RNDM,R2
A @RNDA,R3
MOV R3,@SEED
RT
* PLOT A PIXEL
PLOTPX
CLR R2
CLR R3
CLR R4
MOV R0,R5
DIV @CLC,R4
MPY @CLC,R4
A R5,R2
MOV R1,R5
CLR R4
DIV @CLC,R4
A R5,R2
MOV R1,R5
CLR R4
DIV @CLC,R4
MPY @CLC+2,R4
A R5,R2
* WHICH BIT
MOV R0,R5
CLR R4
DIV @CLC,R4
LI R4,>8000
MOV R5,R5
SFT JEQ SFTX
SRL R4,1
DEC R5
JMP SFT
SFTX MOV R2,R0
BLWP @VSBR
SOC R4,R1
BLWP @VSBW
RT
* MAIN LOOP
RUN
BL @INIT
LOOP
BL @RGEN
CLR R2
DIV @CLC+4,R2
MPY @CLC+8,R3
MOV R4,R2
* R2 IS (0,4,8)
* HALFWAY POINT X
MOV @PTS(R2),R3
MOV @CURPT,R4
A R3,R4
CLR R3
DIV @CLC+6,R3
MOV R3,R1
* HALFWAY POINT Y
INCT R2
MOV @PTS(R2),R3
MOV @CURPT+2,R4
A R3,R4
CLR R3
DIV @CLC+6,R3
MOV R3,R0
* STORE IN CURPT
MOV R0,@CURPT+2
MOV R1,@CURPT
BL @PLOTPX
* REPEAT
JMP LOOP
END
Posted in Assembly on 2020-09-23 16:03:00.
Hits: 1892