Hallo,
Ich möchte gerne 16-bit positive integer Zahlen rechtsbündig auf den Bildschirm ausgeben und benutze dafür die Routine linprt ($bdcd). Da aber die zahlen 1 bis 5 Zeichen breit sind, kann ich sie nicht schön rechtsbündig ausgeben.
Im BASIC würde dies so aussehen:
Ich habe hier ein Assembler Beispiel wie die zahlen jetzt ausgegeben werden:
Code
!to "assemble.prg",cbm
!cpu 6502
*=$2000
linprt = $bdcd
chrout = $ffd2
setcur = $e50a
val1 = 1
val2 = 22
val3 = 333
val4 = 4444
val5 = 55555
;----------------
ldx #<val1
lda #>val1
jsr linprt ;output integer
sec ;get cursor position
jsr setcur
ldy #6 ;set cursor (6,y)
clc
jsr setcur
ldx #$00 ;reset index
- lda textval1,x ;fetch char
beq + ;end of text?
jsr chrout ;print to screen
inx ;increase index
bne - ;loop
+
ldx #<val2
lda #>val2
jsr linprt ;output integer
sec ;get cursor position
jsr setcur
ldy #6 ;set cursor (6,y)
clc
jsr setcur
ldx #$00 ;reset index
- lda textval2,x ;fetch char
beq + ;end of text?
jsr chrout ;print to screen
inx ;increase index
bne - ;loop
+
;----------------
ldx #<val3
lda #>val3
jsr linprt ;output integer
sec ;get cursor position
jsr setcur
ldy #6 ;set cursor (6,y)
clc
jsr setcur
ldx #$00 ;reset index
- lda textval3,x ;fetch char
beq + ;end of text?
jsr chrout ;print to screen
inx ;increase index
bne - ;loop
+
;----------------
ldx #<val4
lda #>val4
jsr linprt ;output integer
sec ;get cursor position
jsr setcur
ldy #6 ;set cursor (6,y)
clc
jsr setcur
ldx #$00 ;reset index
- lda textval4,x ;fetch char
beq + ;end of text?
jsr chrout ;print to screen
inx ;increase index
bne - ;loop
+
;----------------
ldx #<val5
lda #>val5
jsr linprt ;output integer
sec ;get cursor position
jsr setcur
ldy #6 ;set cursor (6,y)
clc
jsr setcur
ldx #$00 ;reset index
- lda textval5,x ;fetch char
beq + ;end of text?
jsr chrout ;print to screen
inx ;increase index
bne - ;loop
+
;----------------
rts
;----------------
textval1 !pet "the first value",13,0
textval2 !pet "the second value",13,0
textval3 !pet "the next value",13,0
textval4 !pet "and another one",13,0
textval5 !pet "the last value",13,0
Alles anzeigen
Ausgegeben wird:
Code
searching for assemble.prg
loading from $2000 to $20eb
ready.
sys8192
1 the first value
22 the second value
333 the next value
4444 and another one
55555 the last value
Gewünschte Ausgabe:
Code
1 the first value
22 the second value
333 the next value
4444 and another one
55555 the last value
Hat jemand eine Idee wie das einfach gelöst werden könnte?