generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Small Programming Challenge

Previous Thread :: Next Thread 
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
15 Mar 2016 02:29 AM
While I was chatting with my slack lads, I came up with a challenge that was pretty fun for me to solve. It's a small challenge and might be a good way to exercise that brain of yours.

The challenge is in assembly, but it's basic enough where with a little bit of information, you should still be able to solve it without having to really learn assembly.

The challenge is this:
"allocate a 4-byte integer on the stack and set it to some number `n` using only subtraction"

The traditional method would be to do:
SUB esp, 4 ; allocates 4 bytes on the stack
MOV [esp], 69 ; moves a 69 into memory at esp

However you're restricted to using only subtraction, no using the MOV (move) instruction.

My solution was 7 SUB instructions. You can use any of the general purpose x86 registers (eax, ebx, ecx, edx, etc.) HOWEVER you must allocate 4 bytes on the stack (this can be done easily [see traditional method]) and write the number into that memory.

Here's 1 hint:
SUB eax, eax -> will result in the eax register being set to 0
Report Abuse
bosswalrus is not online. bosswalrus
Joined: 04 Jan 2013
Total Posts: 5430
15 Mar 2016 02:30 AM
ok
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
15 Mar 2016 02:42 AM
If you've think you've got it, private message me so I can confirm it and I'll say you've got it. Please don't be a moron and post it here, give people a chance to solve it.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
15 Mar 2016 04:38 PM
abc
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
15 Mar 2016 05:02 PM
Forgot to note, in case you're not at all familiar with x86, something like this is invalid:

"sub [esp], [esp]
sub [esp], -69"

because the instruction format does not support to memory operands. In simple terms: you can only have at most 1 memory index per instruction ([ ] denotes that) for the most part.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
15 Mar 2016 05:12 PM
lordrambo has got it
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
15 Mar 2016 05:13 PM
hah 1st winner with ten instructions losers
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
15 Mar 2016 05:42 PM
you're obviously cnt in disguise no one cares.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
15 Mar 2016 05:43 PM
get out loser
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
15 Mar 2016 05:47 PM
Pretty sure Flux is cnt?
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
15 Mar 2016 05:48 PM
yes just look at his profile if you care that much, it's not a secret
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
15 Mar 2016 05:54 PM
No, I didn't care enough to look at his profile because I was very sure. I just didn't want to be wrong and look like a idiot, gg.
Report Abuse
os_time is not online. os_time
Joined: 15 Feb 2014
Total Posts: 2247
15 Mar 2016 06:04 PM
Would flux be mad if I called him senpai cnt


#code "Lua ~ PHP ~ CSS ~ HTML for me at least."
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
15 Mar 2016 07:01 PM
hello only 1 person solved the challenge.. i want someone to solve it in less instructions than me so i can be awed and think "why didnt i think of that"
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
15 Mar 2016 07:06 PM
Okay another person solved the challenge (bosswalrus) in 7 instructions as well
Report Abuse
bosswalrus is not online. bosswalrus
Joined: 04 Jan 2013
Total Posts: 5430
15 Mar 2016 07:06 PM
ok i do'ed iit 7 instructas
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
17 Mar 2016 12:07 AM
bmp
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
18 Mar 2016 01:25 AM
2
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
19 Mar 2016 01:44 AM
3
Report Abuse
MiniNob is not online. MiniNob
Joined: 14 May 2013
Total Posts: 822
19 Mar 2016 03:40 AM
sub eax, eax
sub eax, [-1*esp]
sub [esp], eax
sub edx, edx
sub edx, -69
sub esp, 4
mov [esp], edx

this is what i got, i don't know if it's valid though
Report Abuse
MiniNob is not online. MiniNob
Joined: 14 May 2013
Total Posts: 822
19 Mar 2016 03:46 AM
sub eax, eax
sub eax, [-1*esp]
sub [esp], eax
sub edx, edx
sub edx, -69
sub esp, 4
sub [esp], edx
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
19 Mar 2016 04:09 AM
Nope, invalid.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
30 Mar 2016 03:24 PM
we're almost at 4 ;[
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
30 Mar 2016 08:09 PM
So we can't use any mov instructions at all? or are you saying we cannot use mov when moving a number into [esp]?
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
30 Mar 2016 08:16 PM
You can't use MOV at all
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image