Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 21st, 2009, 02:59 AM
laguna92651 laguna92651 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 9 laguna92651 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 41 m 15 sec
Reputation Power: 0
Assembly - Machine code relative offsets

I am trying to understand how assembly is translated into machine language. I understand how to get the machine coding formats but I'm not sure how to calculate 'rr' in all cases. For the example example bra is 20 rr or 20 03, I know that the relative offset is 03 to get to the iny instruction. But I'm not sure why the rr = F3 for the dbne instruction, how does that relative offset get me to Again? A quick answer would be appreciated, I have a test tomorrow.

Solution to sample problem:
Code:
        org $600   
                    ldy  #Array        ;CD B6 15
                    ldaa  #N            ;86 07
                    clr      7,y           ;69 47
Again             brclr   0,y %11110000, Not_gtr  ;0F 40 F0 02
                    bra    Update     ;20 03
Not_gtr          inc     Count       ;72 B6 1C
Update           iny                      ;02
                    dbne  a,Again    ;04 30 F3
                    swi                     ;             
Array             fdb   8,7,2                           
N                  equ   7
Count            rmb   1

Reply With Quote
  #2  
Old March 26th, 2010, 08:25 AM
Paul Herber Paul Herber is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2010
Location: Hampshire, UK
Posts: 11 Paul Herber User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 44 m 59 sec
Reputation Power: 0
The data is a 2s complement of the difference between the addresses. When the DBNE is executed the PC will already be at the byte beyond the F3. Now, count back bytes from there to the label 'Again'. That's 13 bytes, but -13 bytes = 00001101. 1s Complement = 11110010. 2s Complement = 1s complement+1 so that gives us 11110011 = F3

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Assembly - Machine code relative offsets

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap