6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon Jul 01, 2024 5:34 am

All times are UTC




Post new topic Reply to topic  [ 132 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Author Message
 Post subject:
PostPosted: Fri Jul 08, 2011 11:07 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 390
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: 390
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: 10837
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  
 Post subject:
PostPosted: Mon Jul 11, 2011 3:51 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10837
Location: England
BitWise wrote:
Make it lda #%00011111 and it should work fine.
Ah, indeed so.

The two assemblers now agree on everything!

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 17, 2011 3:16 am 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
sorry posted to wrong thread!

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 22, 2011 5:23 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10837
Location: England
Hi Teamtempest
Just stumbled across an oddity in your assembler: lazily relying on errors to help me port Bruce's pi program from 65816 to 65Org16, the assembler correctly rejected the PHY and PLY opcodes, but silently ignores the PHX and PLX opcodes.

It's not immediately obvious to me where the problem lies, but hopefully it's a small one.

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Aug 23, 2011 4:25 am 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 390
Location: Minnesota
Quote:
Just stumbled across an oddity in your assembler: lazily relying on errors to help me port Bruce's pi program from 65816 to 65Org16, the assembler correctly rejected the PHY and PLY opcodes, but silently ignores the PHX and PLX opcodes.


Odd. If you're using the "i6502.a" macro versions of the instruction set with the HXA_T version of the assembler, I don't believe PHX and PLX are even defined.

Hmm. If they aren't interpreted as pseudo ops (nope, none with those names), operators (HXA_T doesn't recognize any) or defined macros (shouldn't be), the only possibility left is that they are interpreted as labels.

This possibility is increased because PHX and PLX don't take arguments, so they can look like labels sitting by themselves on a line (and thus get assigned the current value of the program counter).

Still, HXA should complain the second time either of these appear because presumably the program counter will have a different value, and HXA doesn't permit that for non-variable labels (which these would be).

So without seeing the code you're trying to convert (I don't see it in the source respository here), my best guess is that PHX and PLX both appear on a line by themselves and only once in the program (but PHY and PLY do appear more than once, and it's the second and any successive appearance that triggers any error).

Or if more than once, then in only one section that's actually assembled (as opposed to sections skipped over due to some source condition turning off assembly for a while).

Or they appear more than once but assembly stops before reaching them the second time because the error count limit is reached first.

If none of these is the case, then clearly I need to see exactly what code is failing to generate a proper error message. I've actually learned quite a bit when HXA fails to generate the error I expect. This may be an opportunity to learn even more.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Aug 23, 2011 7:33 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10837
Location: England
Hi TT
Ah, I think that explains it! Thanks!

I just started with Bruce's program posted here and dealt with each error spotted by your assembler.

PHY appears on a line with a label, so does give rise to an error. Also, I'd spotted that one myself, so was expecting to deal with it, and of course was already on the lookout for the matching PLY.

As you say, PHX and PLX are just taken as labels - they appear only once. (I suppose if the syntax demanded left-justified labels, or a period or colon marker, then there would be no issue. But I'm not complaining!)

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 25, 2011 2:57 am 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 390
Location: Minnesota
Hi Ed,

Well I'm glad that worked out. I've had a couple of other thoughts you might consider trying in an effort to get HXA to help you translate things.

Those opcodes defined for the 65c02 and other variant instruction sets, for instance. One idea is to define macros that implement them:

Code:
    .macro PHX
    TXA
    PHA
    .endm


Of course this doesn't exactly duplicate PHX because the A register is trashed, which could be A Bad Thing (OTOH, what else can easily be done?).

Another idea, still using macros, is to make such instructions explicitly illegal as a tip that Something Needs To Change Here:

Code:
    .macro PHX
    .fatal "Unimplemented on the 65Org16"
    .endm


The error message that pops up should show the offending source line, which therefore shows the PHX (or whatever), so all bad instructions could reference the same macro:

Code:
    .macro XNOTIMP
    .fatal "Unimplemented on the 65Org16"
    .endm

    .macro PHX
    XNOTIMP
    .endm


Which would at least save writing out the same error message every time. If you didn't want to stop assembly at each bad instruction, you could change "fatal" to "error".

New instructions which accept or require arguments are no problem because there's no requirement they actually be used in the body of the macro:

Code:
    .macro STZ, ?addr, ?reg="@"
    XNOTIMP
    .endm


This handles both "STZ addr" and "STZ addr,x" forms by using a default argument in case "X" is not specified (it could just as well be a null string as "@", and in some ways it would be simpler to do so if it was actually going to be used, but it's an idiom I developed before HXA could handle null strings).

New address modes on old instructions would be trickier, and most likely would require re-writing the existing instruction macros to recognize and reject the new mode, but it could be done.

As things now stand, I believe the ADC macro accepts "ADC (addr)" as "ADC addr" because the value of an expression enclosed in parentheses is the same as the value of the same expression without parentheses. That is, expression evaluation ignores them, so for them to be "meaningful" they have to be noticed and acted on before evaluation takes place. The 6502 instruction macros do pay attention if they also see a ",Y", but otherwise I don't think they care.

This method also has the advantage that macro names can be preceeded by labels, so the error happens whether or not there is a label on the same source line.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Aug 27, 2011 5:40 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10837
Location: England
Thanks - I think a few .fatal macros might be a help, if one were likely to see code from broader instruction sets. It might not be a real problem now that I'm once bitten.

Interesting difficulty in ruling out the unindexed indirect mode though - probably best to leave that as another thing to debug. After all, the machine is never going to be source compatible, due to 8-bit assumptions not holding.

Do you think it's worth adding a label syntax, such as leading dot or trailing colon? As an option?

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 28, 2011 2:10 am 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 390
Location: Minnesota
Quote:
Do you think it's worth adding a label syntax, such as leading dot or trailing colon? As an option?


Trailing colons on labels are already allowed, mainly to make it easier to port source that requires them. They're not really meaningful at this point, though. If HXA sees one it just gets stripped off before anything is done with the label. (BTW, a leading period on pseudo ops is also optional and is treated the same way. But it does help set them off from processor instructions, doesn't it?)

Offhand, I think the code changes necessary to make colons required on labels as an option would be relatively minor, but that's without looking at all the source. It'd also need a flag somewhere to tell HXA to use those changes instead of the default. Maybe the next version will have that.

The way things are set up now, that'd be much easier than, say, requiring labels to start in column one. I didn't actually want that because I didn't care for "anonymous" labels in that position in listings. It's kind of a moot point now that listing margins can be altered, but it took me a while to get around to making that possible.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 28, 2011 2:36 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8460
Location: Southern California
Quote:
If HXA sees one it just gets stripped off before anything is done with the label. (BTW, a leading period on pseudo ops is also optional and is treated the same way. But it does help set them off from processor instructions, doesn't it?)

I very much prefer a colon after a label. Otherwise when you do a search in your source code, you get lots of references to it before you find the label itself. There needs to be a way to say, "This is the label," as opposed to, "This refers to the label."


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 28, 2011 12:11 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10837
Location: England
teamtempest wrote:
Offhand, I think the code changes necessary to make colons required on labels as an option would be relatively minor, but that's without looking at all the source. It'd also need a flag somewhere to tell HXA to use those changes instead of the default. Maybe the next version will have that.
Hi TT
That's what I meant to say: making the optional required, optionally(!) - but certainly not a priority. As Garth says, it helps for searching too.

(I can't say how pleased I was to discover that on linux I did
Code:
./HXA_TW.EXE pi.asm
and by happening to have WINE installed it "just worked" - your assembler is cross-platform after all.)

Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 29, 2011 5:13 am 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 390
Location: Minnesota
Quote:
Quote:
If HXA sees one it just gets stripped off before anything is done with the label. (BTW, a leading period on pseudo ops is also optional and is treated the same way. But it does help set them off from processor instructions, doesn't it?)

I very much prefer a colon after a label. Otherwise when you do a search in your source code, you get lots of references to it before you find the label itself. There needs to be a way to say, "This is the label," as opposed to, "This refers to the label."


I see your point. Sorry if I wasn't clear. You as programmer can already use a trailing colon on any label you like. So if you want to mark all labels that lead source lines with trailing colons, go right ahead.

Internally for its own purposes HXA "normalizes" labels to a common format before using them for anything, so there's no confusion between labels leading source lines and the same labels in expressions. However the only place you as programmer will ever notice this is in a listing, where label names (if listed at all) are shown in their normalized form.


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, 8, 9  Next

All times are UTC


Who is online

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