From the course: Learning Assembly Language

Adding a menu and jump table to the Enigmatic encryptor - Python Tutorial

From the course: Learning Assembly Language

Start my 1-month free trial

Adding a menu and jump table to the Enigmatic encryptor

- [Instructor] Let's update our enigmatic encryptor code by adding a menu to it. Firstly, we'll replace the welcome message at line 11 with a menu, and we'll use the dollar construct to determine the length of this menu. Let's also add a jump table loaded with calls for configuration and ciphering. I'll add the exit as well as the zeroith item. Put the menu jump table comment in, we'll call it jumper and specify quadwords with address exit quadword with address config and a quadword with address cipher. In the main code before line 62 let's define the exit point and we'll be tidy and close our handles as well. Exit invoke close handle hin invoke close handle hout invoke close handle hinst. Okay. Let's add a menu label before line 170 and update the welcome message in our main line with the length wlen. Menu and wlen. So now we have the menu displayed and we need to read a character. We'll do that with an invoke ReadFile from hin to charin we want it to be three characters for our menu item plus character turn line fee and address bin for the bytes in and zero. We can now get the character and adjust it into binary form. So will xoreax eax move into the lower byte by character in and we'll subtract from eax hexadecimal 30 and turn it into an offset for our jump table. Just change that to sub so we'll shift left eax three so that we are eight byte offsets. And then we'll jump via the jump table by using the gym table start address plus the offset. Call jumper plus eax. And when we return, we'll loop back to the menu with a strike jump back to menu. Okay, we now have a menu and we just need to declare the menu labels. We've already declared exit. Let's declare the configuration before line 180. Configuration I will declare that as label config. And let's add the ciphering stub also. Ciphering cipher is the label and we'll return. Okay, that settled our menu and jump table. Let's go check it out We'll build it and run it in the command shell. Let's configure it. We'll enter slot three, character F, slot one character A rotor in slot three is five character two. And for the plug one, C7 and unplug two, five F And we're back to our menu again. Let's exit now.

Contents