I'm very new with assembly, I'm trying to build a character, word and spaces counter with Easy68k. I'm getting the user input, then looping through the characters, adding to the counter and trying to output the result, but all I could do was to output the same input a user enters, so I'm stuck. What am I doing wrong?
CR EQU $0D
LF EQU $0A
START: ORG $1000
* Cargar dialogo en direccion de memoria
LEA DIALOG,A1
* Mostrar prompt
MOVE #14,D0
TRAP #15
* Leer input de usuario
MOVE #2,D0 ;lee el input
MOVE D0,A0
TRAP #15
* Enseña input de usuario
MOVE #14,D0
MOVE A1,A0
TRAP #15
LOOP:
TST.B (A0)+ ; Carga el sig. caractetr
BEQ FINISHED ; If si termina en 0, se termina el programa
CMP.B #32, D1 ; Checa si caracter es espacio
BEQ IS_SPACE ; Si es, vamos a subrutina COUNTSPACE
ADDQ #1,D1
BRA INCREMENT
IS_SPACE:
ADDQ #1,(SPACES)
BRA INCREMENT
INCREMENT:
ADDQ #1,(CHARS)
BRA LOOP
FINISHED:
MOVE.B (SPACES),D1
MOVE #14,D0
TRAP #15
SIMHALT
DIALOG: DC.B 'ESCRIBE ALGO: ',CR,LF,0
CHARS: DC.B 0
Tried reading documentation and the simulator's examples, and repositories. Tried getting the input from user using task #2 I/O. But all I could do was to output the same input a user enters i.e. 'hello world', output: 'hello world'
expected: 'Characters: 11' 'Words:2' 'Spaces:1'