flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > x86 RCL 8 Bit command in ARM (Thumb)

Author
Thread Post new topic Reply to topic
Kuemmel



Joined: 30 Jan 2006
Posts: 200
Location: Stuttgart, Germany
Kuemmel 01 Sep 2020, 07:24
Hi there, I'm a bit puzzled when I tried to port some x86 assembler to ARM code (Thumb mode). I got the 8bit rotate with carry "rcl al,cl".

I can't figure out how to do that in a nice/short/correct way in ARM/Thumb. With "rors r0,r0,r1" and some "and r1,r1,#255" + "rsb r1,r1,#32" before, I can do the rotate left, but how to integrate the carry and make it work on 8Bit ? Seems I need plenty instructions to do the same 8Bit stuff in ARM.
Post 01 Sep 2020, 07:24
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 01 Sep 2020, 08:04
You are correct. There are no native 8-bit ARM rotates with carry (RCL equivalent, which makes it a 9-bit shift actually).

If you need an exact equivalent then you have to manually construct it.

You can rotate left by rotating right the inverse amount with ROR.

The most troubling part will be to reduce the shift modulo 9 (not 8) unless you know your shift value is already <9.
Post 01 Sep 2020, 08:04
View user's profile Send private message Visit poster's website Reply with quote
Kuemmel



Joined: 30 Jan 2006
Posts: 200
Location: Stuttgart, Germany
Kuemmel 01 Sep 2020, 08:14
Ok! Meanwhile I got the idea to check the source of DOSBox...that acutally looks troublesome in the sense of sizecoding Smile I wonder what the compiler output is when assembling to ARM or Thumb.
Code:
#define RCLB(op1,op2,load,save)                                                         
        if (op2%9) {                                                                                    
                LoadZF;LoadSF;LoadAF;                                                           
                Bit8u cf=get_CF();                                                                      
                flags.var1.b=load(op1);                                                         
                flags.var2.b=op2%9;                                                                     
                flags.type=t_RCLb;                                                                      
                flags.result.b=(flags.var1.b << flags.var2.b) |         
                                (cf << (flags.var2.b-1)) |                                      
                                (flags.var1.b >> (9-flags.var2.b));                     
                SETFLAGBIT(CF,((flags.var1.b >> (8-flags.var2.b)) & 1));                        
                SETFLAGBIT(OF,(flags.var1.b ^ flags.result.b) & 0x80);                          
                save(op1,flags.result.b);                                                       
        }    
Post 01 Sep 2020, 08:14
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.