what's the c equivalent to this asm code

This is a discussion on what's the c equivalent to this asm code within the C++ Programming forums, part of the General Programming Boards category; asm { mov ax,a xchg ah,al }...

  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 08: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 08: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, 10:31 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. Replies: 4
    Last Post: 01-15-2002, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21