flat assembler
Message board for the users of flat assembler.

Index > Main > Can someone please explain RCR reg,reg to me please ?

Author
Thread Post new topic Reply to topic
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
I'm having a very hard time trying to figure out RCR reg,reg . Please help ?
Post 08 Aug 2007, 16:45
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
What it does or how to use?

If you what to use a register as src it only can be CL.
Post 08 Aug 2007, 17:19
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Wink
Post 08 Aug 2007, 19:13
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
I don't understand that picture lol...... I want to know what the opcode does. Please explain in words lol
Post 09 Aug 2007, 01:42
View user's profile Send private message Reply with quote
ChrisLeslie



Joined: 04 Jun 2006
Posts: 50
Location: Australia
ChrisLeslie
Rotate Right through Carry.
For example, when the instruction RCR al,1 is executed the low order bit (bit0) of al is copied to the carry flag. The carry flag is copied to the high order bit (bit7) of al. Bit 7 copies to bit 6 etc. So all the 8 register bits plus the carry bit play musical chairs and shift one bit (or chair) in a circle.

If the instruction is RCR al,cl, for example, the number of times the shift takes place for the one instruction is the value that is in the cl register. For example, if you preceed the rcr al,cl instruction with mov cl,2, then two shifts will take place.

Chris
Post 09 Aug 2007, 03:42
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
Do you mean the high order bit ( bit 7 ) by eax ?
eax can hold 8 bits .... in the way you explain it from 0-7

I still dont understand what happens here :

mov al, 36h
rcr al,2h

al is equal to "Dh" after the execution . How is the low order bit --- 6h in this case copied into the carry flag ? The carry flag can't become 6 ....
Post 09 Aug 2007, 13:54
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
However, al can only hold a byte
So for example

mov al,36h

which al in bits is 110110

There are only 6 binary numbers there.... and the carry flag would count as the 7th. Why do you say 8 then ? Is there something I'm missing ?
Post 09 Aug 2007, 19:26
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> Is there something I'm missing ?

YES. After 2 years and 233 posts Confused

> So for example
> mov al,36h
> which al in bits is 110110

00110110

> There are only 6 binary numbers there

NO. always 8 Shocked

> the carry flag would count as the 7th.

NO.

> Why do you say 8 then ?

Always 8.

Code:
; Before  : 00110110 C ; $36
; After 1 : C0011011 0 ; $1B
; After 2 : 0C001101 1 ; $0D
    


BTW, C must have been zero before your RCR Shocked

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 09 Aug 2007, 19:54
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
Lol I know I don't have all the basics down..
Post 09 Aug 2007, 20:12
View user's profile Send private message Reply with quote
ChrisLeslie



Joined: 04 Jun 2006
Posts: 50
Location: Australia
ChrisLeslie
> Do you mean the high order bit ( bit 7 ) by eax ?
> eax can hold 8 bits .... in the way you explain it from 0-7

The example was using an 8 bit register. If using 16 bit register then high order bit will be 15, and 31 if using a 32 bit register.

> al is equal to "Dh" after the execution . How is the low order bit --- 6h in > this case copied into the carry flag ? The carry flag can't become 6 ....

The low order bit is 1h. You are confusing a hex nibble with a bit. Only one bit is copied to the carry flag, not the four bits of a hex symbol.

Quote:
mov al,36h

which al in bits is 110110

There are only 6 binary numbers there.... and the carry flag would count as the 7th. Why do you say 8 then ? Is there something I'm missing ?

mov al,36h gives 00110110 in binary. You left off the top two bits. So there are 8 bits and the carry flag could count as the ninth bit during the rotate.
Post 09 Aug 2007, 22:51
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
Well thank you everyone. I understand now
Post 11 Aug 2007, 00:06
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.