![]() |
![]() |
#1 |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 278
|
![]()
I understannd much of C code, but not all.
While I tried to use the gadtools.library, I stumbled over this: Code:
struct Gadget *glist = NULL; gad = CreateContext(&glist); How does the similar code look in assmbler? Like this? Code:
lea glist(pc),a0 clr.l (a0) CALLGADTOOLS CreateContext glist DS.B gg_SIZEOF Code:
sub.l a0,a0 CALLGADTOOLS CreateContext Last edited by dissident; 15 August 2024 at 21:23. |
![]() |
![]() |
#2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,050
|
The first snippet is correct.
glist should be ds.l 1 for proper alignment. Or dc.l 0, then you don't need the clr.l (a0). |
![]() |
![]() |
#3 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,224
|
Globals are set to 0 or null at startup due to being initialized with MEMF_CLEAR but the NULL assignment is just making sure there is no phantom data in memory. The assignment should reduce out to nothing.
|
![]() |
![]() |
#4 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,097
|
It's a pointer to pointer, so it's the former (NULL is overwritten with a valid pointer on return, if successful). Passing a0=0 would be equivalent to CreateContext(NULL) and result in address 0 being trashed ("NULL ptr problem").
|
![]() |
![]() |
#5 |
Registered User
Join Date: Sep 2015
Location: Germany
Posts: 278
|
Thx for your quick replies. Now I understand it much better.
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Misc Amiga Assembler Source Code | copse | Coders. General | 14 | 20 October 2019 02:05 |
I am trying to make my first GFX assembler code | litwr | Coders. Tutorials | 111 | 14 December 2018 21:10 |
The 6502 assembler code in "The Terminator" (1984) | Shoonay | Nostalgia & memories | 2 | 15 May 2009 13:52 |
Assembler System Friendly code | redblade | Coders. General | 3 | 29 July 2008 12:15 |
Amiga Cross Assembler to code intros! - Help! | W4r3DeV1L | Amiga scene | 6 | 30 May 2008 16:53 |
|
|