English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 09 March 2020, 23:49   #1
sparhawk
Registered User

sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 51
Posts: 304
vasm repeat macro with reversing parameter order

I wanted to create an STDCALL macro which pushes the arguments in revers order on the stack for calling a C function.

Code:
STDCALL    MACRO

; Move CARGS up to the last argument...
    REPT \#-1
VAL SET \+
    ENDR

; ... And push in reverse order now
    REPT \#-1
    pea        \-
    ENDR

    jsr        _\1

    ENDM

; Usage
    STDCALL crc32,1,2,3
Maybe I'm doing something wrong and there is a better way. The above macro advances CARG to the end, and then goes back, pushing each argument. Can I address the arguments directly by their number through a variable or such? I tried that, but it didn't work so I tried this approach.

The problem I still have though is, that I get an warning
Code:
warning 62: imported symbol <crc32> was not referenced
Reason is, because of this line:
Code:
VAL SET \+
Which is actually just my way of advancing the CARG counter, in lack of a better approach. So what is the best way to achieve this?

The expected code would be in this example:
Code:
pea 3
pea 2
pea 1
jsr _crc32
I know that if I pass a register, this wouldn't work with this right now, but this is the next thing I w would look into.
sparhawk is offline  
Old 10 March 2020, 09:17   #2
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 47
Posts: 3,689
I don't know for vasm but phxass allows setting CARG directly, like this :
CARG set NARG
meynaf is offline  
Old 10 March 2020, 18:07   #3
sparhawk
Registered User

sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 51
Posts: 304
That worked. Strange. I tried something similar before, but it didn't work. I guess I did something wrong there.
sparhawk is offline  
Old 10 March 2020, 23:00   #4
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,598
Quote:
Originally Posted by sparhawk View Post
The problem I still have though is, that I get an warning
Code:
warning 62: imported symbol <crc32> was not referenced
Reason is, because of this line:
Code:
VAL SET \+
No, the reason is because of this line:
    jsr        _\1

Maybe you did an "xref crc32" somewhere, but you were actually calling _crc32.
phx is offline  
Old 10 March 2020, 23:45   #5
sparhawk
Registered User

sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 51
Posts: 304
Nope. Reason was that the symbol passed in was used because the repeat was not working as intended. I have it working now.
sparhawk is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
VLINK / VBCC / VASM linking order issue adrianpbrown Coders. C/C++ 6 14 January 2020 08:10
vasm: Empty Macro issue VladR Coders. Asm / Hardware 2 06 January 2020 17:17
VASM named macro arguments guy lateur Coders. Asm / Hardware 20 01 October 2018 14:50
Trouble with macro parameters in VASM kazblox Coders. Asm / Hardware 2 03 January 2015 04:28
[for RCK] Homonym artists: links displayed in reverse numerical order lilalurl HOL data problems 3 07 September 2009 01:41

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:32.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.06229 seconds with 14 queries