101
Assembly Program
Assembly language program operation:
The numbers and characters are separated and stored in the number storage
buffer and the character storage buffer, respectively. Then numeric strings and
character strings are restored as the original character variables. This program
has no practical application; it’s just an example.
$2000
PSHA
Saves registers
PSHB
PSHX
LDD
#$2600 Sets first address of buffer 1 in
point 1
STD
$2500
LDD #$2700 Sets first address of buffer 2 in
point 2
STD
$2502
LDAB
0,X
Number of characters to GET
LDX
1,XC
Character variable first ad-
dress GET
STX
$2504
$2016
LDX
$2504
DOUNTIL (number of times
equal to the number of charac-
ters)
LDAA
0,X
Character GET
INX
Character variable address p1
STX $2504
CMPA #$30
IF (minimum $30)
BLT
$2032
THEN
CMPA #$39
IF (numeral less than $39)
BHI
$2032
THEN
LDX
$2500
Stores numeral in buffer 1
STAA
0,X
INX
STX
$2500
BRA $203B
$2032
LDX $2502
ENDIF
STAA
0,X
Stores character in buffer 2
INX
STX $2502
$203B DECB
Updates
counter
BNE $2016
ENDDO
LDD $2500
LDX
#$2600 Transfer from buffer 1 to a
character variable
STX $2504
SUBD
#$2600
PULX
PSHX
PSHB
LDX 1,X
STX
$2506
JSR
$2100
LDX
#$2700 Transfer from buffer 2 to a
character variable
STX
$2504
PULB
PULX
PSHX
LDX
1,X
ABX
STX
$2506
LDD
$2502
SUBD
#$2700
JSR
$2100
PULX
PULB
PULA
RTS
$2100
LDX
$2504
Data transfer subroutine
LDAA 0,X
INX
STX $2504
LDX $2506
STAA
0,X
INX
STX $2506
DECB
BNE $2100
RTS
Example 2: Use of More than One Parameter
This program singles out the larger of two character strings.
Three parameters are used (i.e., the two original character strings for compari-
son and the other for result storage).
BASIC Program
100 ’
*****
*****
Assembly language
110 ’
***** Program to single out the larger of two character
*****
program $2170 to
120 ’
***** strings
*****
$21AF. Work area
Assembly Language Examples
Summary of Contents for C500-ASC04
Page 1: ...C500 ASC04 ASCII Unit Operation Manual Revised February 2001 ...
Page 5: ...iv ...
Page 7: ...vi ...