English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 21 July 2011, 22:28   #1
Jherek Carnelia
Dazed and Confused
 
Jherek Carnelia's Avatar
 
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
C to assembler

A basic question, but it's confusing me!

here's a bit of C code:

screen->RastPort.Flags=DBUFFER

is this equivalent?

movea.l my_screen,a0
movea.l sc_RastPort(a0),a0
lea rp_Flags(a0),a0
move.w #2,a0

Thanks...
Jherek Carnelia is offline  
Old 21 July 2011, 22:35   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,987
move.l screen,a0
move.w #2,sc_RastPort+rp_Flags(a0)


To correct your code, it should be

move.l screen,a0
lea sc_RastPort(a0),a0
lea rp_Flags(a0),a0
move.w #2,(a0)

It does the same with more instructions.
thomas is offline  
Old 22 July 2011, 00:26   #3
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,753
Quote:
Originally Posted by thomas View Post
Code:
	move.l	screen,a0
	move.w	#2,sc_RastPort+rp_Flags(a0)
Nice

You can also do it in three instructions
Code:
	move.l	my_Screen,a0
	lea	sc_RastPort(a0),a0
	move.w	#2,rp_Flags(a0)
Thorham is offline  
Old 22 July 2011, 20:45   #4
Jherek Carnelia
Dazed and Confused
 
Jherek Carnelia's Avatar
 
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
Quote:
Originally Posted by thomas View Post
move.l screen,a0
move.w #2,sc_RastPort+rp_Flags(a0)
Thomas, I know I'm thick, but I don't really understand...

This is how my somewhat limited understanding sees this.

sc_RastPort is the offset to the pointer in the screen structure of the RastPort's address.

rp_Flags is the offset in the RastPort to the Flags.

If I add the two offsets together, I would have thought that I would get an offset somewhere past the RastPort into the screen structure; I don't understand how I get the address of the Flags in the RastPort...

Can you explain to my dim brain, how this works?
Jherek Carnelia is offline  
Old 22 July 2011, 23:21   #5
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,753
It's actually quite simple: The RastPort structure is part of the Screen structure, which means that sc_RastPort is an offset that points to the RastPort structure instance inside the Screen structure and not to a pointer.

There are some other structures that are part of the Screen structure as well, so just make sure that you know exactly when an offset points to a pointer or a structure instance.
Thorham is offline  
Old 23 July 2011, 20:22   #6
Jherek Carnelia
Dazed and Confused
 
Jherek Carnelia's Avatar
 
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
Doh! What an idiot! It's so easy when you stop and think!
Jherek Carnelia 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
Which assembler to use BanisterDK Coders. General 4 10 January 2012 15:13
Help with Assembler redblade Coders. General 8 23 April 2010 16:00
Learning assembler bLAZER Coders. General 1 12 May 2007 05:00
assembler harlequin request.Apps 26 07 February 2002 20:53
Assembler for WinUAE Jherek Carnelia request.Apps 4 27 December 2001 08:32

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 18:05.

Top

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