English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old Yesterday, 21:16   #1
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 276
Post C-code translated to assembler

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);
A pointer to a gadget structure should be set to NULL!?

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
Or only

Code:
  sub.l a0,a0
  CALLGADTOOLS CreateContext
I don't get it.

Last edited by dissident; Yesterday at 21:23.
dissident is offline  
Old Yesterday, 21:35   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,047
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).
thomas is offline  
Old Yesterday, 21:36   #3
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
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.
Samurai_Crow is offline  
Old Yesterday, 21:39   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,093
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").
a/b is online now  
Old Yesterday, 22:08   #5
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 276
Thx for your quick replies. Now I understand it much better.
dissident 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
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

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 09:29.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11497 seconds with 15 queries