6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 21, 2024 11:30 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: DASM is working, kind of
PostPosted: Sat Aug 22, 2015 8:59 pm 
Offline
User avatar

Joined: Sat Aug 22, 2015 8:54 pm
Posts: 31
For some reason, I can't get DASM to compile a BIOS I am creating for custom 6502-based microcomputers. The following is the code:

Code:
processor 6502
   ;; This is a simple BIOS for a 6502 machine.
   ;; The BIOS code assumes the following:
   ;;    Random Number generator lives at $fe
   ;;    ASCII keypress is stored at $ff (pseudo-readonly, value only changes when new keypress occurs.
   ;;                 You can write to the location but it changes with next keypress.)
   ;;    Stack will live at $100-$1ff
   ;;    BIOS starts at $600 and ends at $fff (2560 bytes)
   ;;    Screen pixels mapped at $200-$5ff with following color info:
   ;;       $0: Black
   ;;       $1: White
   ;;       $2: Red
   ;;       $3: Cyan
   ;;       $4: Purple
   ;;       $5: Green
   ;;       $6: Blue
   ;;       $7: Yellow
   ;;       $8: Orange
   ;;       $9: Brown
   ;;       $a: Light red
   ;;       $b: Dark gray
   ;;       $c: Gray
   ;;       $d: Light green
   ;;       $e: Light blue
   ;;       $f: Light gray
   ;;    The BIOS also assumes that color info gets ANDed with $0f (not by the BIOS) to always get a valid color.
   ;;    To read the color of a pixel, the BIOS will read from the pixel address. (e.g., to read $200: lda $200)
   ;;    NMI means serious hardware issue
   ;;    IRQ resets processor
   ;;    Interrupt vectors at $fffa
   ;; Anything not mentioned is RAM space.
   ;; Assemble with DASM.

   ;; Let's begin some code, shall we?
   ORG $600
Reset
   ;; Register Immediate addressing mode check
   lda #$ff
   ldx #$ff
   ldy #$ff
   cmp #$ff
   bne die         ;Stop on error
   cpx #$ff
   bne die
   cpy #$ff
   bne die
   ;; Register transfer test
   and #$00
   tax
   tay
   cpx #$00
   bne die
   cpy #$00
   bne die
   ;; store to RAM test
   lda #$ea
   sta $00
   ldx $00
   cpx #$ea
   bne die
   and #$00
   tax
   sta $00
   ;; 'White Dot' test
   lda #$01
   sta $200
   ldx $200
   cpx #$01
   bne die
   and #$00
   tax
   sta $200
   ;; Your code goes here
   jmp Reset      ;Simple filler instruction. Remove if you wish.
die
   ;; Red screen of death
   lda #$02
   ldx #$00
loop
   sta $200, x
   inx
   cpx #$ff
   bne loop
loop2
   sta $2ff, x
   inx
   cpx #$ff
   bne loop2
loop3
   sta $3ff, x
   inx
   cpx #$ff
   bne loop3
loop4
   sta $4ff,x
   inx
   cpx #$ff
   bne loop4
   jmp loop

   ORG $fffa
InterruptVectors
   .word die      ;NMI
   .word Reset      ;RESET
   .word Reset      ;IRQ
END
   


DASM fails with this message (with -v5):
Quote:
dasm bios.asm -obios.bin -lbios.txt -v5
DASM V2.20.07, Macro Assembler (C)1988-2003

START OF PASS: 1

----------------------------------------------------------------------
SEGMENT NAME INIT PC INIT RPC FINAL PC FINAL RPC
INITIAL CODE SEGMENT 0600 0600
----------------------------------------------------------------------
10 references to unknown symbols.
11 events requiring another assembler pass.
- Expression in mnemonic not resolved.
- Label defined after it has been referenced (forward reference).

--- Unresolved Symbol List
x 0000 ???? (R )
--- 1 Unresolved Symbol


START OF PASS: 2

----------------------------------------------------------------------
SEGMENT NAME INIT PC INIT RPC FINAL PC FINAL RPC
INITIAL CODE SEGMENT 0600 0600
----------------------------------------------------------------------
3 references to unknown symbols.
3 events requiring another assembler pass.
- Expression in mnemonic not resolved.

--- Unresolved Symbol List
x 0000 ???? (R )
--- 1 Unresolved Symbol


START OF PASS: 3

----------------------------------------------------------------------
SEGMENT NAME INIT PC INIT RPC FINAL PC FINAL RPC
INITIAL CODE SEGMENT 0600 0600
----------------------------------------------------------------------
3 references to unknown symbols.
3 events requiring another assembler pass.
- Expression in mnemonic not resolved.

--- Unresolved Symbol List
x 0000 ???? (R )
--- 1 Unresolved Symbol

--- Unresolved Symbol List
x 0000 ???? (R )
--- 1 Unresolved Symbol

Fatal assembly error: Source is not resolvable.


I can't seem to figure out why :( .

My command line is:
Code:
dasm bios.asm -obios.bin -lbios.txt -v5

_________________
It may look hard, but it won't take long if you take it one byte at a time.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 22, 2015 9:03 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Just a wild guess - you have a space between the comma and the x for your indexed accesses. Might be worth fixing that to see if it makes any difference.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 22, 2015 9:05 pm 
Offline
User avatar

Joined: Sat Aug 22, 2015 8:54 pm
Posts: 31
BigEd wrote:
Just a wild guess - you have a space between the comma and the x for your indexed accesses. Might be worth fixing that to see if it makes any difference.


That did the trick. Too used to x86. :oops:

_________________
It may look hard, but it won't take long if you take it one byte at a time.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 22, 2015 9:14 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Lucky guess... I see you're new here - welcome! Hope you'll stick around and tell us about progress on your project.


Top
 Profile  
Reply with quote  
PostPosted: Sat Aug 22, 2015 9:17 pm 
Offline
User avatar

Joined: Sat Aug 22, 2015 8:54 pm
Posts: 31
Does anyone happen to know if you can use the output from DASM directly into 6502SIM (for DOS) and expect it to work?

_________________
It may look hard, but it won't take long if you take it one byte at a time.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2015 8:00 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I'm not familiar with that emulator, (here?) but if you have the right load address and the right hooks to system facilities like input and output, I would think it should work.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2015 9:59 am 
Offline
User avatar

Joined: Sat Aug 22, 2015 8:54 pm
Posts: 31
Yes, that is it. Every time I load raw binary from DASM it gives me an error.

_________________
It may look hard, but it won't take long if you take it one byte at a time.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2015 10:28 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Looks like it always loads a BIN file right up against the top of memory, so you need to create a binary image which looks something like a ROM. Unless you use 'bload' and place your file somewhere specific. Then you need to use 'pc' to set the program counter. If it's not working, perhaps you could say more about what you see.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2015 10:54 am 
Offline
User avatar

Joined: Sat Aug 22, 2015 8:54 pm
Posts: 31
So have the code start at $F000 like in the Atari 2600? And have it stop at $FFFA then place the interrupts? Like maybe this:
Code:
processor 6502
ORG $F000
; Code goes here
ORG $FFFA
; Interrupt vectors here


Would that possibly work?

_________________
It may look hard, but it won't take long if you take it one byte at a time.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 24, 2015 11:39 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
That's how the included a65 example works - if you get a 4k binary, that's a good sign. It seems though that the emulator doesn't use the reset vector, it starts at 0000 unless you set the pc.

Edit: there's a 'reset' command which sets the PC to the value in the reset vector.

Edit: the example is a 32k binary which starts at 8000. Same principle.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: