6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 09, 2024 1:29 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Aug 11, 2023 7:31 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
Hi! I've been a bit disappointed with acme's macro functionality, namely the fact that macro expansion is not detailed in the assembler report, which makes interpreting addresses and setting breakpoints impossible.

Here is an extract from the report, showing how normal assembly looks, and then macros only taking one line, with an incomplete string of compiled bytes to the left.

Code:
    22  804e 20c982                               jsr acia_lcd_putc
    23  8051 fa                                   plx
    24  8052 e8                                   inx
    25  8053 4c4880                               jmp -
    26  8056 48656c6c6f2c2057...+                 !text "Hello, World!", 0
    27                          ++
    28  8064 a90d                                 lda # "\r"                      ; add new line in console only
    29  8066 209d84                               jsr acia_sync_putc
    30  8069 a90a                                 lda # "\n"
    31  806b 209d84                               jsr acia_sync_putc
    32                         
    33  806e a9de8d847fa9088d...                  +play_tone_hz_ms 880, 100
    34                         
    35  809b 485adaa90da0f1a2...                  +delay_ms 1000


I'd like to find a text pre-processor that can be invoked prior to acme to expand macros to proper assembly. Ideally the syntax would not break syntax highlighting (which means it would still be valid assembly, maybe hidden behind comments?). So far I've looked at GPP https://logological.org/gpp, which doesn't do multiline macros in a nice way. I also looked at how ca65 does macros, and it has the same issue of not showing expansion in the listing.

Before I end up rolling my own, does anyone know of a good option?

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 11, 2023 7:36 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
See if you find something useful in enso's topic, "A sensible macro engine," at viewtopic.php?f=2&t=2570 .  I have a few links also at http://wilsonminesco.com/StructureMacros/#forum .

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 11, 2023 7:40 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
Great links, thanks Garth!

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 11, 2023 8:15 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
I should also probably say that I was able to monkey patch the behavior I want into acme, by moving the code to a separate file and sourcing it in the macro. However, it makes the readability really poor (separating the macro definition and arguments from the body of the macro):

Code:
!macro play_tone_hz_ms .frequency_hz, .duration_ms {
                  !source "lib/macros/play_tone_hz_ms.asm"
}


results in the following report, with the included code being expanded properly:

Code:
    28  8064 a90d                                 lda # "\r"                      ; add new line in console only
    29  8066 209d84                               jsr acia_sync_putc
    30  8069 a90a                                 lda # "\n"
    31  806b 209d84                               jsr acia_sync_putc
    32                         

; ******** Source: lib/macros/play_tone_hz_ms.asm
     1                                            ; cycles for half period = CPU_SPEED_MHZ * 1000000 / .frequency_hz / 2
     2                                            ; storing 0 in the counter results in PB7 toggling every two cycles, storing 1 results in toggling every three cycles.
     3                                            ; So we need to substract 2 from the value to get the accurate frequency.
     4                                            ; example: CPU_SPEED_MHZ=3.33MHz, .frequency_hz = 555kHz => cycles should be 1
     5                                            @cycles = int( CPU_SPEED_MHZ * 1000000.0 / .frequency_hz / 2 ) - 2
     6                                            @low_order_byte = @cycles & 255
     7                                            @high_order_byte = (@cycles >> 8) & 255
     8                         
     9  806e a9de                                 lda # @low_order_byte
    10  8070 8d847f                               sta IO_0_VIA_T1CL
    11  8073 a908                                 lda # @high_order_byte
    12  8075 8d857f                               sta IO_0_VIA_T1CH
    13                         
    14                                            ; Setup T1 for continuous operation, PB7 toggling
    15                                            ; T1 interrupts are disabled in the IER
    16  8078 a940                                 lda # (VIA_ACR_T1_CONTINUOUS << VIA_ACR_T1_CONTROL_INT) | (VIA_ACR_T1_PB7_ON << VIA_ACR_T1_CONTROL_PB7)
    17  807a 8d8b7f                               sta IO_0_VIA_ACR
    18                         

; ******** Source: lib/macros/delay_us.asm
     1                                            !if .delay_us > 83298577 * CPU_SPEED_MHZ {

_________________
BB816 Computer YouTube series


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

All times are UTC


Who is online

Users browsing this forum: BigEd and 10 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: