Thread: what's the c equivalent to this asm code

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    552

    what's the c equivalent to this asm code

    asm {
    mov ax,a
    xchg ah,al
    }

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    int a=12345; // dummy value.
    int b= a & 0xffff;
    b<<=16;
    int c= a & 0xffff0000;
    c>>=16;
    a=b|c;

    not exact but close enough.
    Last edited by Stoned_Coder; 01-17-2002 at 09:14 PM.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    erm... isn't that a little long-winded?? ax is 16 bits right??

    Code:
    short ax = a;
    ax = (ax >> 8) | (ax << 8);
    U.
    Last edited by Uraldor; 01-17-2002 at 09:39 PM.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    yes you are right ax is 16 bits wide. Dont know why i thought it was 32 lol
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    thx guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ASM to C language
    By TAZIN in forum C Programming
    Replies: 22
    Last Post: 06-03-2009, 06:29 AM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM