VICE xvic ML loaded at $1001 doesn't work

You need an actual VIC.

Moderator: Moderators

Post Reply
User avatar
toby405
Vic 20 Amateur
Posts: 46
Joined: Fri Dec 21, 2012 8:33 pm
Location: USA

VICE xvic ML loaded at $1001 doesn't work

Post by toby405 »

I'm on a Mac. Tried this on a few recent versions of VICE (2.3, 2.4). In unexpanded vic mode, if I try to load at $1001 it won't run. If I go into the monitor and:

r pc=1001
step

...my program isn't there.

If I load at $1201 everything works fine. I haven't been able to try it on a real machine yet. What am I doing wrong?

Code: Select all

; dasm setup
processor   6502
org         $1001

; zero page variables
scrnmemL    equ $fb
scrnmemH    equ $fc
colrmemL    equ $fd
colrmemH    equ $fe

    jsr $e55f       ; clear screen.

    ; set up screen memory address.
    lda #$0
    sta scrnmemL
    lda $0288
    sta scrnmemH

    ; set up color memory address.
    lda #$0
    sta colrmemL
    ldx #$94
    lda $9002
    bpl .1
    ldx #$96
.1  stx colrmemH

    ; display a character, upper left corner.
    ldy #$0
    lda #$1         ; screen code
    sta (scrnmemL),Y
    lda #$6         ; color code
    sta (colrmemL),Y
    
    rts
User avatar
buzbard
Vic 20 Devotee
Posts: 213
Joined: Sun Jul 03, 2005 9:10 am

Post by buzbard »

Looks like you're trying to load your ML program directly into the BASIC program area, which (i believe) will cause the VIC to think it's a tokenized BASIC program and attempt to adjust the line links which aren't there.

If you want to use the BASIC program area you might need to put a BASIC stub at the beginning like this:

Code: Select all

;DASM VIC20 BASIC stub
          processor 6502

          ;Use only one of these
          ;org $401  ;3k
          ;org $1001 ;Unexpanded
          ;org $1201 ;8k+

BASICstub dc.w nxt_line    ; Pointer to next BASIC line
          dc.w 2013        ; BASIC Line#
          dc $9e           ; BASIC token for SYS
       if nxt_line         ; If label hasn't been defined, skip it for now
          dc [ml_start]d   ; ML start address
       endif
          dc 0             ; End of BASIC line
nxt_line  dc.w 0           ; The next BASIC line would start here

ml_start
This is a stub I created for DASM that will add:

Code: Select all

2013 SYSnnnn
to your code. "nnnn" will be replaced with the start address of your ML code.
You'll need to uncomment one of the org lines according to which memory configuration you're using. And add your code after the ml_start label.

Also in DASM, you need to indent the "processor" and "org" lines.
Ray..
User avatar
toby405
Vic 20 Amateur
Posts: 46
Joined: Fri Dec 21, 2012 8:33 pm
Location: USA

Post by toby405 »

Thanks a bunch! I had a little trouble with a dasm error:

line 12 code/ex2.asm Value Undefined
IF error 1
mismatch nxt_line 1007(r ) pc: 100b
line 16 code/ex2.asm Label Mismatch

But I'm a dasm noob, too. Anyway I hardcoded it up and it works great. By looking at my assembled file and a small BASIC file with a hex editor I learned a ton about how BASIC files work, too. This all makes so much more sense now.

Code: Select all

    processor 6502
    org $1001               ; Unexpanded VIC

    ; BASIC stub (unexpanded vic)   
    dc.w $100b              ; Pointer to next BASIC line
    dc.w 1981               ; BASIC Line#
    dc.b $9e                ; BASIC SYS token
    dc.b $34,$31,$30,$39    ; 4109 (ML start)
    dc.b 0                  ; End of BASIC line
    dc.w 0                  ; End of BASIC program

    jsr $e55f       ; clear screen
    lda #86         ; V
    jsr $ffd2       ; print char
    lda #73         ; I
    jsr $ffd2
    lda #67         ; C
    jsr $ffd2
    rts
User avatar
buzbard
Vic 20 Devotee
Posts: 213
Joined: Sun Jul 03, 2005 9:10 am

Post by buzbard »

Oh, right, your on a MAC, I'm on a PC, so maybe the version of DASM is a little different.

Glad you got it sorted.
Ray..
Post Reply