I got stuck in a simple 68k program.
Program needs to read from a txt file. In txt file are numbers, separated by space, and file ends with a dot (.)
I need to enter a file name and read from it, count how many numbers are there and sum up all neighbour numbers.
Example: 222 10 300 7 450 201 9 117 38 456. Result: Sum of neighbours: 232 310 307 457 651 210 126 155 494, Number of numbers: 10.
Here's what I've got so far. Using D3 for number of numbers.
START ORG $1000
MOVE #0,D3
MOVE #14,D0
LEA text,A1
TRAP #15
MOVE #2,D0
LEA name,A1
TRAP #15
MOVE #51,D0
LEA name,A1
TRAP #15
MOVE #53,D0
MOVE.L #100,D2
LEA cont,A1
TRAP #15
MOVE #13,D0
TRAP #15
loop CMP.B #$2E,(A1)
BEQ dot
CMP.B #$20,(A1)
BEQ space
ADD.L #1,A1
JMP loop
space ADD.L #1,D3
RTS
dot MOVE #14,D0
LEA sum,A1
TRAP #15
LEA end,A1
TRAP #15
MOVEA d3,a1
TRAP #15
MOVE.B #9,D0
TRAP #15
name DS.B 10
cont DS.B 100
text DC.B 'Enter file name:',0
sum DC.B 'Sum of neighbours: ',0
end DC.B 'Number of numbers: ',0
END START
First of all, what is the easiest way to print my d3 register on screen? 2nd: Since im moving only one character at the time, how do i make a number from those 1-3 characters?