21 July 2011, 22:28 | #1 |
Dazed and Confused
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... |
21 July 2011, 22:35 | #2 |
Registered User
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. |
22 July 2011, 00:26 | #3 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,753
|
|
22 July 2011, 20:45 | #4 |
Dazed and Confused
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
|
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? |
22 July 2011, 23:21 | #5 |
Computer Nerd
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. |
23 July 2011, 20:22 | #6 |
Dazed and Confused
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
|
Doh! What an idiot! It's so easy when you stop and think!
|
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 |
|
|