Professional Documents
Culture Documents
ORIG x3000
LEA R0, Intro
PUTS
LD R5, Base ;x3500 x3501 ... hold the input character
LD R4, Base1 ;R4 count the number of characters in each
string
;--------------------------------MAIN PROGRAM----------------------------------;
INPUT GETC
OUT
ADD R1, R0, #-9
BRz NEXT ;end input if press 'TAB' "-9"
ADD R1, R0, #-16
ADD R1, R1, #-16
BRz INPUT ;Ignore 'SPACE' "-32"
ADD R1, R1, #-12
BRz INPUT ;Ignore ',' "-44"
ADD R1, R0, #-10
BRz NEXT ;If 'ENTER' "-10" => end string
STR R0, R5, #0 ;store valid character in x3500 ...
ADD R5, R5, #1
ADD R2, R2, #1 ;count the number of character
BR INPUT
A_NEW_MIN ADD R6, R0, #0 ;MIN <- current character of current string
ST R5, SaveR5 ;SaveR5 save the current address of lowest
string
ST R4, SaveR4 ;SaveR4 save the current address of the number
of cha
BR A_NEW_S
;----------------------------------------------------------;
A_DONE1 LD R2, SaveString ;Load the the number of remaining
string
AND R1, R1, #0
LD R5, SaveR5
LD R4, SaveR4
LDR R3, R4, #0
A_OUTPUT LDR R0, R5, #0
OUT
AND R0,R0,#0 ;when we regconize 5 in 'B_LOOP' Label means
that this is already displayed chracter
ADD R0,R0,#5
STR R0,R5,#0
ADD R5, R5, #1 ;next character of string
ADD R3, R3, #-1 ;check whether there is any characters in the
string left
BRp A_OUTPUT
ADD R0, R1, #10 ;after finish each string. ENTER to the new
line
OUT
ADD R2, R2, #-1 ;check whether there is any strings left
BRz A_END
ST R2, SaveString
BR A_BEGIN
B_NEW_MIN ADD R6, R0, #0 ;MIN <- current character of current string
ST R5, SaveR5 ;SaveR5 save the current address of lowest
string
ST R4, SaveR4 ;SaveR4 save the current address of the number
of cha
BR B_NEW_S
;----------------------------------------------------------;
B_DONE1 LD R2, SaveString ;Load the the number of remaining
string
AND R1, R1, #0
LD R5, SaveR5
LD R4, SaveR4
LDR R3, R4, #0
B_OUTPUT LDR R0, R5, #0
OUT
AND R0, R0, #0 ;when we regconize 5 in 'B_LOOP' Label means
that this is already displayed chracter
ADD R0, R0, #5
STR R0, R5, #0
ADD R5, R5, #1 ;next character of string
ADD R3, R3, #-1 ;check whether there is any characters in the
string left
BRp B_OUTPUT
ADD R0, R1, #10 ;after finish each string. ENTER to the new
line
OUT
ADD R2, R2, #-1 ;check whether there is any strings left
BRz B_END
ST R2, SaveString
AND R6, R6, #0
BR B_BEGIN