6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 21, 2024 3:00 am

All times are UTC




Post new topic Reply to topic  [ 132 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 9  Next
Author Message
 Post subject:
PostPosted: Wed Jun 29, 2011 10:40 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Highly experimental draft assembler and linker.

http://www.obelisk.demon.co.uk/files/65016.zip

Unzip and open a command prompt in the directory then use NMAKE to assemler boot.asm and link into output files. Linux lovers will need to tweak the Makefile a little. Needs a java 1.6 JRE/JDK installed on the command path. (Type java -version to check for one).

The binary and hex file outputs from the linker look OK but need more testing. The S19 output is bugged.

I'm off for some sleep

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jun 30, 2011 11:55 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 395
Location: Minnesota
Quote:
do you have a code drop I could use?


My plan at this point is to go back and make sure none of the changes has messed up anything else. A test suite is so helpful with that :D, but I think I'm going to add something new that verifies identical behavior with the existing version where tests haven't changed between versions. Just checking for matching error/non-error behavior has let little things slip through before.

If that doesn't turn up anything horrible then I want to document HXA as it now exists and post it as v0.180. With any luck, should be available this weekend. It's miserably hot in the workroom today (no A/C and a heat index over 100), so there might not be much progress before then.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jul 05, 2011 5:19 am 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 395
Location: Minnesota
Quote:
but I think I'm going to add something new that verifies identical behavior with the existing version where tests haven't changed between versions


Well...that turned out to be 36K lines of differences, mainly because I modified file listings. Hardly "identical". I only looked at the first 6K, found a couple of things I didn't like, and changed them.

Anyway, version 0.180 is up at

http://home.earthlink.net/~hxa

The only lapse is that the on-line copies of the test programs are not properly updated due to alphabetic case issues and the sheer number of changes I have yet to make (god I hate case-sensitivity). All the rest of the on-line documentation should be okay, and the various *.ZIP downloads should be fine.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jul 05, 2011 10:19 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
TT, Bitwise - thanks for the updated assemblers. I managed very little technical stuff over the weekend, but I do plan to port the hex loader to both syntaxes (unless a single syntax suits both)

I did get a listing from BitWise's assembler, from which I might have tried to extract a hex dump, but of course some of the hex is still zero at that point, so probably not worthwhile. I did that by using cpp to process the #defines, but really I'd want to rewrite them as labels.

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jul 06, 2011 4:41 am 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 395
Location: Minnesota
It's probably already occurred to you, but it's just occurred to me (slow learner, right?) that the 16/16 address format of an Intel 32-bit address works out really nicely as a 6502-style 2-byte pointer: record type '4's data field is just the high "byte" of the address, and record type '0's offset field is just the low "byte". They're even in the proper order as far as internal octets go, if I understand that correctly. Read 'em and store. Nothing to it! Set the Y-register to zero and you're all set to read and store data octets.

Or, hmm, set the low "byte" of the pointer to zero and set the Y-register to the offset. The only hazards would be the possibility of the offset + data bytes running over a 64K boundary, or the offset "wrapping" at that point. Those should never happen, but you never know when you'll run into a badly formed record.

We need not go into how I know about badly-formed records...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jul 06, 2011 8:18 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
BigEd wrote:
I did get a listing from BitWise's assembler, from which I might have tried to extract a hex dump, but of course some of the hex is still zero at that point, so probably not worthwhile. I did that by using cpp to process the #defines, but really I'd want to rewrite them as labels.


If you use .ORG (or *=) to set an origin within the .CODE section then the assembler will generate absolute address (as in the example boot ROM). You still need to link to convert the .OBJ output into a binary or hex file.

You only get zeros in the listing when expressions are not resolvable without linking.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jul 07, 2011 5:50 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
BitWise wrote:
You only get zeros in the listing when expressions are not resolvable without linking.

Ah, top tip. I shall perform the comparison!

TT: I immediately notice that the
Code:
  .string
directive is packing characters in a big-endian fashion, unlike .byte:

Code:
 0000:F81F  53 00 65 00         .string "Send 6502 code in"
 0000:F853  00 0D               .byte 13,10

Because I'll be talking to an 8-bit peripheral connected to the LSByte, I will be needing my strings to be little-end justified, which is what BitWise does. Is this something I can fix in source, or is this a bug report?!

(BitWise's tool will allow a string argument to a .byte directive:
Code:
0000F81F  00530065006E0064> :         .byte "Send 6502 code in"
but I think HXA does not.
)

Thanks to both of you, of course - I could use either tool as-is, if I had to, and both are a step up from the previous one.

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jul 07, 2011 7:37 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Here's a curious one for you Bitwise: the loading of some binary constants isn't coming out as expected:
Code:
0000F97F  00A92B67          : INITSER lda #00011111b ;
0000F981  0085F000          :         sta $F000 ;
0000F983  00A903F3          :         lda #00001011b ;

(It's very handy having two tools to compare!)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jul 07, 2011 11:23 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 395
Location: Minnesota
Quote:
TT: I immediately notice that the
Code:
.string

directive is packing characters in a big-endian fashion, unlike .byte:

Code:
0000:F81F 53 00 65 00 .string "Send 6502 code in"
0000:F853 00 0D .byte 13,10


Because I'll be talking to an 8-bit peripheral connected to the LSByte, I will be needing my strings to be little-end justified, which is what BitWise does. Is this something I can fix in source, or is this a bug report?!


".string' is actually doing what I told it to (and as documented), so if there's a bug it's a failure of my imagination. The sequence to me looks little-endian; it's the ".byte" sequence that looks big-endian.

I assume you initialized with a sequence like this:

Code:
.cpu T_32_L16
.assume BIT16=10, BIT32=1032


Try this instead:

Code:
.cpu T_32_M16
.assume BIT32=1032, BIT32R=3210


That should swap the order of octets in string characters. BIT16 (aka ".byte") will "naturally" have octet order 10 in an MSB-first machine, so it doesn't have to be changed. BIT32 (aka ".word") will "naturally" have octet order 3210, so it does have to be changed. If you never plan to use reversed order words you don't need the BIT32R assumption, but it's there for completeness (and won't hurt anything if present).

But it never occurred to me that ".string" should be affected by byte sequence changes. If strings are considered sequences of bytes, perhaps it should have.

Quote:
(BitWise's tool will allow a string argument to a .byte directive:
Code:
0000F81F 00530065006E0064> : .byte "Send 6502 code in"
but I think HXA does not.
)


True. OTOH, ".string" arguments can be either string or numeric expressions (which will get cut down to the least significant octet).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Jul 08, 2011 10:59 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Hi TT
I tried changing the assume statements, but it changed the output code very significantly. As things stood, your tool and BitWise's are identical apart from the .string behaviour (and the binary constant.)

(This is parenthetical, because I think it's a diversion...) The first divergence is that
Code:
sta $F000
changes from
Code:
^0000:F8A2  00 85               .byte ]opc
^0000:F8A3  F0 00               .ubyte val(]adr$)
to
Code:
^0000:F8A6  00 8D               .byte ]opc+8                                                                       
^0000:F8A7  F0 00 00 00         .uword val(]adr$)                                                                   

To revisit the string behaviour: a string constant in the source is a series of octets, and we want it assembled into a series of (padded) 16-bit bytes. BitWise places the input octet into the LSB, and HXA presently places the input octet into the MSB.

That is, HXA produces:
Code:
0000:F81F 53 00 65 00 .string "Send 6502 code in"
where I expect to see
Code:
0000:F81F 00 53 00 65 .string "Send 6502 code in"
because when I load from 0000F81F, I expect to load 0053, an 'S'

That is, I don't think there's any word-order problem here, so no need to change the assume statement.

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Jul 08, 2011 11:00 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 395
Location: Minnesota
Okay, two separate issues.

Quote:
I tried changing the assume statements


Good but not enough. The ".cpu" statement changes as well, from
Code:
.cpu T_32_L16

to
Code:
.cpu T_32_M16


Changing from LSB to MSB is what swaps the octet order in string characters, as HXA will put the character octet in the least-significant postition and zero-fill the rest. For an 16-bit "byte" LSB descriptor that becomes "XX 00", and for an MSB that becomes "00 XX".

Tested that again; works as described.

Now for an LSB descriptor HXA by default extracts octets in the order 0->01->012->0123, for 8-, 16-, 24- and 32-bit quantities respectively. For 16-bit values you want the order "10" and for 32-bit quantities the order "1032", which is why the ".assume" is used to specify those. Reversed 32-bit quantities should come out "3210", but they already do by default, so there's no need to change that.

For an MSB descriptor the default extractions are 0->10->210->3210. The 16-bit value is in the the proper order, but the 32-bit values, normal and reversed, are not, so they need to be changed via ".assume".

That should take care of the first issue.

Quote:
(This is parenthetical, because I think it's a diversion...)


Actually it's not. It's a bug of sorts. In the file "i6502.a" there is this:

Code:
        .if cpu$() ~ /L16/    ; 16-bit "byte" (and 65K "zero page") ?
abs_mask    .equ    $FFFF0000
        .else               ; assume 8-bit byte (and 256-byte "zero page")
abs_mask    .equ    $FFFFFF00
        .endif


Look at the listing. "abs_mask" has the value $FFFFFF00, because changing the descriptor from "_L16" to "_M16" causes the match to be false and so "abs_mask" gets the second value, not the first.

Thus the address $0000FF00 becomes non-zero when masked, and is taken as absolute, rather than zero page.

Changing the code to this:

Code:
        .if cpu$() ~ /[LM]16/    ; 16-bit "byte" (and 65K "zero page") ?
abs_mask    .equ    $FFFF0000
        .else               ; assume 8-bit byte (and 256-byte "zero page")
abs_mask    .equ    $FFFFFF00
        .endif


should be one way to make the match succeed and the proper value given to "abs_mask".


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Jul 08, 2011 11:07 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 395
Location: Minnesota
...and making those changes gives me this:
Code:

                        ; a "big-endian" cpu/byte order definition:

                                .cpu    T_32_M16    ; required psop
                                .assume BIT32=1032, BIT32R=3210

                                .org    $f800   ; on zero page, hmm

                                .include "i6502.a"

                        ; -------------------------------

 0000:F800  00 53 00 65    .string   "Send 6502 code in"
 0000:F802  00 6E 00 64
 0000:F804  00 20 00 36
 0000:F806  00 35 00 30
 0000:F808  00 32 00 20
 0000:F80A  00 63 00 6F
 0000:F80C  00 64 00 65
 0000:F80E  00 20 00 69
 0000:F810  00 6E
 0000:F811  00 0D          .byte   13, 10
 0000:F812  00 0A

                           sta $F000
^0000:F813  00 85               .byte ]opc
^0000:F814  F0 00               .ubyte val(]adr$)


...which I think is what you are looking for. If not, well, more changes can be made!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Jul 08, 2011 11:16 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 395
Location: Minnesota
Quote:
Actually it's not. It's a bug of sorts. In the file "i6502.a" there is this


Of course, to even cause that bug to occur means the ".cpu" statement had to have been changed. Oops! But I'm a little surprised the string octets (which would not have been affected by the bug in "i6502.a") didn't come out in the order you wanted after that, since they certainly do for me.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Jul 10, 2011 5:12 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Great - the patch to i6502.a works a treat!

I didn't look too closely before, because once the operand length to one opcode was different I wasn't able to compare the output so easily - everything looked different.

Sorry for my rambling denial about byte order - I'd forgotten that internally to HXA you're treating the octets within a 16-bit byte as being in the other order, so when the listing says '00 A9' it looks right but internally the A9 is the MSB. So long as the loader does the right thing with packing octets into bytes, we'll be fine. The string constants now land with the same octet ordering as the opcodes, which is what we need, and HXA now produces the same output as BitWise's tool.

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jul 11, 2011 8:12 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
BigEd wrote:
Here's a curious one for you Bitwise: the loading of some binary constants isn't coming out as expected:
Code:
0000F97F  00A92B67          : INITSER lda #00011111b ;
0000F981  0085F000          :         sta $F000 ;
0000F983  00A903F3          :         lda #00001011b ;

(It's very handy having two tools to compare!)

My assembler uses prefixes for number bases (e.g. $ for hex, @ for octal and % for binary).

Make it lda #%00011111 and it should work fine.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 132 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 9  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 27 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: