Any idea what this assembly code is doing?

StackMasher

Well-Known Member
OP
Member
Joined
Nov 29, 2016
Messages
136
Trophies
0
Age
21
XP
380
Country
I'm tired of failing all my programming projects and want to try something new. So I decided to try some reverse engineering. Currently I'm working on the linux version of saints row 4, and I'm stuck on this part (parts cut out, ask if more info needed):
Code:
1000a3b0:   e8 0b cf ff ff           call   100072c0 <SteamAPI_RestartAppIfNecessary@plt> #Checks if steam is open, launches it if not and returns 1 indicating that the app should be closed as steam will reopen it. Returns 0 if the app can continue
1000a3b5:   84 c0                   test   %al,%al # ???
1000a3b7:   0f 85 81 01 00 00       jne    1000a53e <__isinff@plt+0x197e>
From looking around, it seems like this code tests if %al is 0, and jumps if not. But why %al? I'm not super familiar with 32bit x86 calling conventions but according to wikipedia, return codes are passed in %eax
 

tetrabrik

Well-Known Member
Newcomer
Joined
Aug 13, 2017
Messages
67
Trophies
0
Age
39
XP
86
Country
United States
yes it does seem it's testing the al part of the eax register. this would be the lower 8 bits of the eax. eax is composed of: ax (16 bits) ah (8 bits) and al (8 bits). they can be used as one register of 32 bits (eax) or just parts of it (as in this case, al only 8 bits).
my guess is that you're correct, the value represents a boolean inside a conditional statement.
without more context not sure where that value's coming from.
 

Mikemk

Well-Known Member
Member
Joined
Mar 26, 2015
Messages
2,092
Trophies
1
Age
28
XP
3,154
Country
United States
Extending what tetrabrik said:

All general registers and several other follow the same pattern.

In the early days of 8-bit computers, you had registers a, b, c, and d. When 16 bit came around, it kept 8 bit access to each half to make porting old code easier.
32-bit and 64-bit CPUs are backwards compatible, so they still have access. r*x (where * is a/b/c/d) is the full 64-bit register, eax is the lower 32 bits, ax the lower 16 bits. al and ah are the lower and higher half of ax.
 

Mikemk

Well-Known Member
Member
Joined
Mar 26, 2015
Messages
2,092
Trophies
1
Age
28
XP
3,154
Country
United States
Also, you're probably seeing a compiler optimization, it's doubtful that the init code was written in assembly.

--------------------- MERGED ---------------------------

Oh, sorry, didn't notice the date
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • K3Nv2 @ K3Nv2:
    why
  • Xdqwerty @ Xdqwerty:
    @K3Nv2, it's not funny
  • K3Nv2 @ K3Nv2:
    ok
  • BigOnYa @ BigOnYa:
    Wut?
  • K3Nv2 @ K3Nv2:
    That's not funny
    +2
  • Psionic Roshambo @ Psionic Roshambo:
    So two cannibals where eating a clown and one says to the other. Hey does this taste funny to you?
    +2
  • K3Nv2 @ K3Nv2:
    What do you call a slow car? Retired
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Did you hear about the police car that someone stole the wheels off of? The police are working tirelessly to find the thieves.
    +2
  • K3Nv2 @ K3Nv2:
    A firefighter got arrested for assault his main claim was what I was told he was on fire
    +2
  • BigOnYa @ BigOnYa:
    What do you call a hooker with a runny nose? Full
    +2
  • Psionic Roshambo @ Psionic Roshambo:
    What do you tell a woman with two black eyes? Nothing you already told her twice!
  • K3Nv2 @ K3Nv2:
    Diddy also works
  • K3Nv2 @ K3Nv2:
    A scientist heard the word batman so he put a naked lady in a cage with a bat
  • Psionic Roshambo @ Psionic Roshambo:
    Chuck Norris won a staring contest, with the sun.
  • K3Nv2 @ K3Nv2:
    A vampires favorite thing to do is moon you
  • BigOnYa @ BigOnYa:
    What's the difference between an airplane, and Ken's mom? Not everyone has been in an airplane.
  • K3Nv2 @ K3Nv2:
    What's the difference between @BigOnYa and his wife? Nothing both want to bone me
    +3
  • RedColoredStars @ RedColoredStars:
    How much wood could a wood chuck chuck if a wood chuck could chuck norris
    +1
  • BakerMan @ BakerMan:
    how do i know? you're a guy, and he wants to bone every guy on this site (maybe, idk)
    +1
  • K3Nv2 @ K3Nv2:
    He wants to bone anything with a dick
    +1
  • Xdqwerty @ Xdqwerty:
    Good night
    +1
  • BigOnYa @ BigOnYa:
    Nighty night, big day tomorrow. Congrats.
    K3Nv2 @ K3Nv2: https://www.instagram.com/reel/C7iLZ35NrQt/?igsh=MWd2Z3U0dmNlMmNxcw==