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

  • SEARCH
  • Home
  • 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 760105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:40:37+00:00 2026-05-14T15:40:37+00:00

class MyString{ char buf[100]; int len; boolean append(MyString str){ int k; if(this.len + str.len>100){

  • 0
class MyString{
char buf[100];
int len;

boolean append(MyString str){

int k;
if(this.len + str.len>100){

for(k=0; k<str.len; k++){
  this.buf[this.len] = str.buf[k];
  this.len ++;
}
 return false;
}

return true;

}
}

Does the above translate to:

start:
  push ebp  ; save calling  ebp
  mov ebp, esp  ; setup new ebp
  push esi  ;  
  push ebx  ;  
  mov esi, [ebp + 8]  ;  esi = 'this'
  mov ebx, [ebp + 14]  ;  ebx = str
  mov ecx, 0  ; k=0
  mov edx, [esi + 200] ;  edx = this.len

append:
  cmp edx + [ebx + 200], 100  
  jle ret_true  ; if (this.len + str.len)<= 100 then ret_true
  cmp ecx, edx
  jge ret_false  ; if k >= str.len then ret_false
  mov [esi + edx], [ebx + 2*ecx]  ; this.buf[this.len] = str.buf[k]
  inc edx  ;  this.len++

aux:
  inc ecx  ; k++
  jmp append

ret_true:
  pop ebx  ; restore ebx
  pop esi  ; restore esi
  pop ebp  ; restore ebp
  ret true

ret_false:
  pop ebx  ; restore ebx
  pop esi  ; restore esi
  pop ebp  ; restore ebp
  ret false

My greatest difficulty here is figuring out what to push onto the stack and the math for pointers.

NOTE:
I’m not allowed to use global variables and i must assume 32-bit ints, 16-bit chars and 8-bit booleans.

  • 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-14T15:40:38+00:00Added an answer on May 14, 2026 at 3:40 pm

    Sounds like you have an assignement, to create Intel x86 assembly code that performs a string append operation.

    If that’s true, It might be instructive for you to examine the disassembled output of a C compiler – like the Intel C compiler, or the Microsoft VC++ Express compiler. Compile some really simple C code, then disassemble and look at the results.

    Compilers usually do things a little differently than a human coder would, but in my experience it’s not difficult to figure out what’s happening in the generated code. You can see how the ASM code manages the stack, how pointer arithmetic in done, how and when registers are initialized, which registers are used and how, and so on.

    A simple C routine might be, your own version of strlen.

    Then, add complexity or change things, compile and disassemble again, and see what happens. Like, instead of strlen, make a C routine that returns the last char in a string.

    or, if you just want the answer, you could try Codecodex.
    🙂

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

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can show the active's parents using .parents() or :has()… May 14, 2026 at 10:30 pm
  • Editorial Team
    Editorial Team added an answer So, after a lot of hair pulling, I found both… May 14, 2026 at 10:30 pm
  • Editorial Team
    Editorial Team added an answer In case the error that amphetamachine pointed out is only… May 14, 2026 at 10:30 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.