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 9310517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:08:02+00:00 2026-06-19T01:08:02+00:00

I am trying to understand how to use pointer in assembly. By reading some

  • 0

I am trying to understand how to use pointer in assembly. By reading some tutorials around internel,I think had undertantood some concepts. But when I’II go to try it,it did work. Below some attempts to translate C to ASM.

C

const char *s = "foo";
unsigned z = *(unsigned*)s;
if(!(z & 0xFF))
do_something();
if(!(z & 0xFFFF))
 do_b_something();

(here’s not full code,but it’s a word-check,thefore,there is more two stmts which checks 0xFF0000,0xF000000 respectivily.

ASM:

mov ebp,str
mov eax,ebp

mov eax,[eax]
and eax,0xFF
cmp eax,0
je etc

mov eax,[eax]
and eax,0xFFFF
cmp eax,0
je etc

It returns a seg fault.

And the try:

mov eax,dword ptr [eax]

that’s generated by gcc compiler and you can see it in some other assemblies code,returns

invalid symbol

on FASM assembler. It isn’t really supported by the FASM or am I missing something?

  • 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-06-19T01:08:04+00:00Added an answer on June 19, 2026 at 1:08 am

    I think this is what you are attempting to do:

        mov  ebp,str
        mov  eax,ebp
    
        mov  ebx,[eax]
        test ebx,0xFF
        jz   low_byte_empty
    
        do_something:
             ; some code here...
    
    low_byte_empty:
        test ebx,0xFFFF
        jz   low_word_empty
    
        do_b_something:
             ; some code here.
    
    low_word_empty:
    

    Explanation:

    First, as JasonD already mentions in his answer, you are loading a pointer to eax, then doing a logical and to it, then you are using the result still in eax to address memory (some memory offset in the range 0x0 … 0xFF).

    So what goes wrong in your code: you can’t keep in the same register both a pointer to a memory address and a value at the same time. So I chose to load the value from [eax] to ebx, you can also use some other 32-bit general register (ecx, edx, esi, edi) according to your needs.

    Then, you don’t need to use cmp to check if a register is empty, because all cmp does is that it does the subtraction and sets the flags. But ZF (zero flag) is already set by and, so cmp is absolutely unnecessary here. Then, as cmp is not needed here and we do not need the result either, we only want to update the flags, it’s better to use test. test does exactly the same logical AND as and does, the only difference being that test does not store the result, it only updates the flags.

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

Sidebar

Related Questions

I'm trying to find some easy to understand and use tutorials for D3 that
I'm trying to understand amazon php sdk for AWS but I really can't use
I am learning Django and I am trying to understand the use of models.py
I'm trying to understand how to use firebug to debug my Javascript. So I
I am trying to understand how to use instance variable in Perl OO -
I am trying to understand how to use reference parameters. There are several examples
I'm trying to understand why one would use Spring Batch over a scripting language
I'm trying to understand whether and under what circs one should use Python classes
I am trying to understand my embedded Linux application's memory use. The /proc/pid/maps utility/file
I have recently started to use Twitter Bootstrap and trying to understand how it

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.