Hi all, UNI's finished and got 4 assignments to keep me going over x-mas.

Decided to get an early start and not the best at programming.

Got a Low level program to write using the 6502 instruction set.

Basically we got to write a program that asks the user to enter a string, and then prints back on screen how long the string is, so far i've got:


; This program accepts input from the screen and echoes it to the screen.
; It will then state how long the entered string is.
; The stored string is terminated with a 00.

io_area = $e000
io_cls = io_area + 0
io_putc = io_area + 1
io_putr = io_area + 2
io_puth = io_area + 3
io_getc = io_area + 4

.org $0200


LDX #0
PRINT: LDA prompt1,x
BEQ continue
STA io_putc
inx
JMP PRINT


continue: LDX #0


get: LDA io_getc
BEQ get
CMP #$0d
beq show
STA io_putc
STA string,x
inx
jmp get

LDX #0


show: LDA prompt2,x
BEQ move
STA io_putc
INX
JMP show

*
*
*
*
*
*
*

finish: lda #0
INX
sta string,x
LDA #$0a
STA io_putc
LDA #$0d
sta io_putc
BRK

prompt1: .DB "Please enter a string :",$00
prompt2: .DB "The Length of the string is :",$00
length: .DS 1
string: .DS 255


thats what i got so far, where the **'s are is what i need help with.

got the rest sorted but not sure how to get the program to print back on screen the length of the string so any help would be excellent.

Thanks to all who help.
Posted on 2004-12-20 10:13:31 by DrWarezz
Hello DrWarezz,

I moved your thread to the heap as this is where non-Win32asm stuff should be...

I am sorry that I cannot answer your question because I do not know the instruction set for 6502. Maybe someone who knows 6502 will be willing to answer your questions.
Posted on 2004-12-20 10:30:16 by roticv
This should work... I think

io_area = $e000 

io_cls = io_area + 0
io_putc = io_area + 1
io_putr = io_area + 2
io_puth = io_area + 3
io_getc = io_area + 4

.org $200
ldx #$16
wrl0:
lda prompt1,x
sta io_putc
dex
bpl wrl0
getloop:
lda io_getc
sta io_putc
inx
cmp #$0d
bne getloop
lda #$0a
sta io_putc
txa
ldy #2
divloop2:
ldx #0
stx 0
ldx #4
clc
divloop:
bcs greater
cmp #$a0
bcc less
greater:
sbc #$a0
less:
rol 0
asl
dex
bpl divloop
lsr
ora #$30
sta 1,y
lda 0
dey
bpl divloop2
lda #$0d
sta 4
lda #$0a
sta 5
ldx #$1c
wrl1:
lda prompt2,x
sta io_putc
dex
bpl wrl1
wrl2:
lda 2,y
sta io_putc
iny
cpy #4
bcc wrl2
brk
prompt1: .db " :gnirts a retne esaelP"
prompt2: .db " :si gnirts eht fo htgnel ehT"
Posted on 2004-12-20 12:58:53 by Sephiroth3
Thanks very much for the quick reply.. sorry about my delay. ^_^

I'm afraid that that don't work. doesn't like the wrl instructions.


Thanks alot,
R
Posted on 2004-12-22 15:36:34 by DrWarezz
Those are labels. Maybe your assemblers doesn't like numbers in labels? Try replacing them with letters.
Posted on 2004-12-22 16:20:51 by Sephiroth3