Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6911601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:58:42+00:00 2026-05-27T08:58:42+00:00

From what I understand reading the Intel manuals, it should be possible to write

  • 0

From what I understand reading the Intel manuals, it should be possible to write an instruction like add $0x7f, %ebx and it should be encoded as 83 /0 ib for a total of three bytes.

However, when I do this (whether I use add, addb, or addl) it always “promotes” the immediate value to a 32-bit value and encodes as 81 /0 id and takes up six bytes. The same problem exists with adc, sub, etc. Note that I am using AT&T syntax with GNU as.

I have been looking for a solution for over a day and haven’t found it. Can anyone please advise?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:58:43+00:00Added an answer on May 27, 2026 at 8:58 am

    Surprisingly, I don’t have such a problem.

    I took this assembly code produced by gcc (DJGPP):

            .file   "im.c"
    .globl _x
            .section        .bss
            .p2align 2
    _x:
            .space 4
            .section .text
            .p2align 4,,15
    .globl _main
    _main:
            pushl   %ebp
            movl    %esp, %ebp
            pushl   %eax
            pushl   %eax
            movl    _x, %eax
            andl    $-16, %esp
            addl    $127, %eax
            movl    %eax, _x
            movl    %ebp, %esp
            xorl    %eax, %eax
            popl    %ebp
            ret
            .ident  "GCC: (GNU) 3.3.4"
    

    And compiled it with as and this is what I’m seeing in a.out:

    55                push ebp
    89E5              mov ebp,esp
    50                push eax
    50                push eax
    A100000000        mov eax,[0x0]
    83E4F0            and esp,byte -0x10
    83C07F            add eax,byte +0x7f
    A300000000        mov [0x0],eax
    89EC              mov esp,ebp
    31C0              xor eax,eax
    5D                pop ebp
    C3                ret
    

    And the C program was:

    volatile int x = 0;
    
    int main(void)
    {
      x += 0x7F;
      return 0;
    }
    

    Are you sure your immediate operand can be represented as an 8-bit signed integer? If it’s outside the -128 to +127 range, the assembler will have to use a longer encoding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From what I understand of REST principles, URLs should represent a single resource, like
Hello I understand from reading advice on this site that scripts should go at
As I understand from reading this post about the new invokedynamic bytecode instruction in
From what I understand, in TDD you have to write a failing test first,
I've been doing some reading up on XML serialization, and from what I understand,
I was reading up on Virtual Memory and from what I understand is that
I was reading a piece of code from the XStreamingReader library (which seems like
From whatever little I understand by reading various material, public-private key pair are the
I am using DBus in a project. I understand from DBus specification that for
From what I understand, the parent attribute of a db.Model (typically defined/passed in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.