This episode provides an introduction to assembly language on the TI.
We cover the following:
What assembly language is and what its relationship to the processor, the TMS9900, is
How assembly differs from how BASIC works
Basic usage of and information on TI Editor/Assembler
Benefits of TI-99 emulation when using assembly
Savings of code execution in assembly over BASIC
Machine architecture with assembly
Use of symbols and user-defined labels
Inserting comments
Syntax of general operations
Practical comparison with a joystick check program, BASIC versus assembly language
THINKBAS
The TI BASIC version of displaying a letter 'X' in the center of the screen.
10 CALL CLEAR
20 CALL HCHAR(12,16,88)
30 GOTO 30
THINKASM
The assembly version of displaying a letter 'X' in the center of the screen.
DEF RUN
REF VSBW
RUN
LI R0,367
LI R1,88
SWPB 1
BLWP @VSBW
LOOP JMP LOOP
END
JOYCHECK
The BASIC version of a joystick checking utility, for comparison. When using joysticks on the actual TI-99 console, remember to have the Alpha Lock key disengaged.
10 CALL CLEAR
20 PRINT " JOYSTICK TESTER"
30 PRINT " MOVE THE JOYSTICKS TO TEST"
40 PRINT
50 P1X=0
60 P1Y=0
70 P2X=0
80 P2Y=0
90 P1K=0
100 P2K=0
110 CALL CHAR(110,"18244281FF000000")
120 CALL CHAR(111,"000000FF81422418")
130 CALL CHAR(112,"1828488888482818")
140 CALL CHAR(113,"1814121111121418")
150 CALL CHAR(114,"3C4281818181423C")
160 CALL CHAR(120,"183C7EFFFF000000")
170 CALL CHAR(121,"000000FFFF7E3C18")
180 CALL CHAR(122,"183878F8F8783818")
190 CALL CHAR(123,"181C1E1F1F1E1C18")
200 CALL CHAR(124,"3C7EFFFFFFFF7E3C")
201 CALL HCHAR(10,11,110)
202 CALL HCHAR(12,11,111)
203 CALL HCHAR(11,10,112)
204 CALL HCHAR(11,12,113)
205 CALL HCHAR(9,9,114)
210 CALL JOYST(1,C1X,C1Y)
220 CALL JOYST(2,C2X,C2Y)
230 CALL KEY(1,C1K,S)
240 CALL KEY(2,C2K,S)
250 IF (C1X-P1X+C1Y-P1Y+C2X-P2X+C2Y-P2Y+C1K-P1K+C2K-P2K)=0 THEN 1100
260 CALL SOUND(-40,2500,0)
270 IF C1Y<>0 THEN 300
280 CALL HCHAR(10,11,110)
290 CALL HCHAR(12,11,111)
295 GOTO 360
300 IF C1Y<>4 THEN 330
310 CALL HCHAR(10,11,120)
320 CALL HCHAR(12,11,111)
325 GOTO 360
330 IF C1Y<>-4 THEN 360
340 CALL HCHAR(10,11,110)
350 CALL HCHAR(12,11,121)
360 IF C1X<>0 THEN 390
370 CALL HCHAR(11,10,112)
380 CALL HCHAR(11,12,113)
385 GOTO 450
390 IF C1X<>-4 THEN 420
400 CALL HCHAR(11,10,122)
410 CALL HCHAR(11,12,113)
415 GOTO 450
420 IF C1X<>4 THEN 450
430 CALL HCHAR(11,10,112)
440 CALL HCHAR(11,12,123)
450 IF C1K=18 THEN 480
460 CALL HCHAR(9,9,114)
470 GOTO 490
480 CALL HCHAR(9,9,124)
490 REM
570 IF C2Y<>0 THEN 600
580 CALL HCHAR(10,21,110)
590 CALL HCHAR(12,21,111)
595 GOTO 660
600 IF C2Y<>4 THEN 630
610 CALL HCHAR(10,21,120)
620 CALL HCHAR(12,21,111)
625 GOTO 660
630 IF C2Y<>-4 THEN 660
640 CALL HCHAR(10,21,110)
650 CALL HCHAR(12,21,121)
660 IF C2X<>0 THEN 690
670 CALL HCHAR(11,20,112)
680 CALL HCHAR(11,22,113)
685 GOTO 750
690 IF C2X<>-4 THEN 720
700 CALL HCHAR(11,20,122)
710 CALL HCHAR(11,22,113)
715 GOTO 750
720 IF C2X<>4 THEN 750
730 CALL HCHAR(11,20,112)
740 CALL HCHAR(11,22,123)
750 IF C2K=18 THEN 780
760 CALL HCHAR(9,19,114)
770 GOTO 790
780 CALL HCHAR(9,19,124)
790 REM
1000 P1X=C1X
1010 P1Y=C1Y
1020 P2X=C2X
1030 P2Y=C2Y
1040 P1K=C1K
1050 P2K=C2K
1100 GOTO 210
JCHASM/S
The assembly version of a joystick checking utility. When using joysticks on the actual TI-99 console, remember to have the Alpha Lock key disengaged.
* JOYSTICK CHECKER - 2019.04.01 NL99
DEF RUN
REF KSCAN,VSBW,VMBW
* TITLE MESSAGE
MSGT TEXT 'CONTROLLER CHECK - READY'
EVEN
* SET CHARACTER DEFINITIONS
CHLEN DATA >0058
CHDEF DATA >0000,>0000,>0000,>0000
DATA >1028,>4482,>FE00,>0000
DATA >0000,>00FE,>8244,>2810
DATA >1828,>4888,>4828,>1800
DATA >1814,>1211,>1214,>1800
DATA >3C42,>8181,>8181,>423C
DATA >1038,>7CFE,>FE00,>0000
DATA >0000,>00FE,>FE7C,>3810
DATA >1838,>78F8,>7838,>1800
DATA >181C,>1E1F,>1E1C,>1800
DATA >3C7E,>FFFF,>FFFF,>7E3C
* KEYBOARD SCAN ADDRESS, POSITIONS, VALUES
KSCMOD EQU >8374
KSCJB EQU >8375
KSCJX EQU >8376
KSCJY EQU >8377
JOYPOS DATA >0189,>01C9,>01A8,>01AA,>0167
DATA >0193,>01D3,>01B2,>01B4,>0171
JOYBY1 BYTE >00,>00,>00,>01,>01,>02
JOYBY2 BYTE >00,>04,>04,>05,>05,>06
JOYVAL BYTE >00,>04,>FC,>FC,>04,>12
JSTATE BSS 8
* PROGRAM START, DISPLAY TITLE
RUN
LI R0,5
LI R1,MSGT
LI R2,24
BLWP @VMBW
* SET CHARACTER DEFINITIONS
LI R0,>0800
LI R1,CHDEF
MOV @CHLEN,R2
BLWP @VMBW
* CHECK AND COPY JOYSTICK STATES
MLOOP
LIMI 2
LIMI 0
LI R1,>0100
MOVB R1,@KSCMOD
BLWP @KSCAN
MOV @KSCJX,R1
MOV R1,@JSTATE
CLR R1
MOVB @KSCJB,R1
MOV R1,@JSTATE+2
LI R1,>0200
MOVB R1,@KSCMOD
BLWP @KSCAN
MOV @KSCJX,R1
MOV R1,@JSTATE+4
CLR R1
MOVB @KSCJB,R1
MOV R1,@JSTATE+6
* SET UP LOOP TO DISPLAY JOYSTICK STATES
LI R4,JOYPOS
LI R10,>0001
LI R2,>0006
LI R3,>000A
* LOAD JOYSTICK STATES INTO REGISTERS
DLOOP
CLR R5
CLR R6
CLR R7
MOVB @JOYBY1(R10),R5
MOVB @JOYBY2(R10),R6
MOVB @JOYVAL(R10),R7
* JOYSTICK 1 COMPARE STATE
SWPB R5
MOVB @JSTATE(R5),R9
MOV R10,R1
CB 7,9
JNE J1PAS
AI 1,>5
* JOYSTICK 1 DISPLAY STATE
J1PAS
SWPB R1
MOV *R4,R0
BLWP @VSBW
SWPB R1
A 3,4
* JOYSTICK 2 COMPARE STATE
SWPB R6
MOVB @JSTATE(R6),R9
MOV R10,R1
CB 7,9
JNE J2PAS
AI 1,>5
* JOYSTICK 2 DISPLAY STATE
J2PAS
SWPB R1
MOV *R4,R0
BLWP @VSBW
SWPB R1
S 3,4
* INCREMENT TO NEXT STATE
INC 10
INCT 4
C 10,2
JNE DLOOP
* DO IT AGAIN
JMP MLOOP
END
Posted in Assembly on 2019-04-27 14:31:00.
Hits: 3054