Jump to content
  • Welcome!

    Register and log in easily with Twitter or Google accounts!

    Or simply create a new Huddle account. 

    Members receive fewer ads , access our dark theme, and the ability to join the discussion!

     

Anyone here know anything about assembly language?


stankowalski

Recommended Posts

I'll give you what I got so far, if you can help that'd be great, if not I'll figure it out eventually probably but it's been a pain in the ass so far.

BTW, this "program" is taking a predefined key and a predefined message and encrypting it. I just started working on it so it's not much so far.

Here it is:

.data

key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6

plainText BYTE "This is a secret message, which will be encrypted",0

encText BYTE ?

mesEnc BYTE "Message encrypted: ",0

mesDec BYTE "Message decrypted: ",0

textBuffer DWORD LENGTHOF plainText

keyBuffer DWORD LENGTHOF key

.code

main PROC

mov edi, 0 ;key pointer

mov esi, 0 ;plainText pointer

mov ecx, textBuffer ;loop counter

mov edx, OFFSET plainText

call WriteString

call crlf

mov edx, OFFSET mesEnc

call WriteString

call Encrypt

mov edx, OFFSET encText

call WriteString

call crlf

call waitmsg

exit

main ENDP

Encrypt PROC

L1: push ecx ;save loop counter

mov al, plainText [esi] ;move letter into al based on pointer

mov cl, key[edi] ;move number from key into cl based on pointer

cmp cl, 0 ;is the key positive or negative?

js L2 ;jump to L2 if negative

ror al, cl ;encrypt the character stored in al based on the key

mov encText[esi], al ;move the encrypted character into encText based on pointer

inc esi ;move to next letter in plainText

inc edi ;move to next number in key

pop ecx ;restore loop counter

loop L1

L2: rol al, cl ;encrypt the character stored in al based on the key

mov encText[esi], al ;move the encypted character into encText based on pointer

inc esi ;move to next letter in plainText

inc edi ;move to next number in key

pop ecx ;restore loop counter

loop L1

ret

Encrypt ENDP

END main

The part in bold is what is causing me problems right now.

Link to comment
Share on other sites

Alright, figured it out. I was one off on the loop counter, didn't take into account the null terminating byte. Working program:

.data

key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6

plainText BYTE "This is a secret message, which will be encrypted",0

mesEnc BYTE "Message encrypted: ",0

mesDec BYTE "Message decrypted: ",0

textBuffer DWORD LENGTHOF plainText

keyBuffer DWORD LENGTHOF key

encText BYTE 128 DUP(0)

.code

main PROC

mov edi, 0 ;key pointer

mov esi, 0 ;plainText pointer

mov ecx, textBuffer ;loop counter

mov edx, OFFSET plainText

call WriteString

call crlf

mov edx, OFFSET mesEnc

call WriteString

call crlf

call Encrypt

mov edx, OFFSET encText

call WriteString

call crlf

mov edx, OFFSET mesDec

call WriteString

call crlf

mov edx, OFFSET plainText

call WriteString

call crlf

call crlf

call waitmsg

exit

main ENDP

Encrypt PROC

L1: push ecx ;save loop counter

mov al, plainText[esi] ;move letter into al based on pointer

mov cl, key[edi] ;move number from key into cl based on pointer

cmp cl, 0 ;is the key positive or negative?

js L2 ;jump to L2 if negative

ror al, cl ;encrypt the character stored in al based on the key

mov encText[esi], al ;move the encrypted character into encText based on pointer

inc esi ;move to next letter in plainText

inc edi ;move to next number in key

.IF edi == keyBuffer

mov edi, 0

.ENDIF

pop ecx ;restore loop counter

.IF ecx == 1

ret

.ENDIF

loop L1

L2: rol al, cl ;encrypt the character stored in al based on the key

mov encText[esi], al ;move the encypted character into encText based on pointer

inc esi ;move to next letter in plainText

inc edi ;move to next number in key

.IF edi == keyBuffer

mov edi, 0

.ENDIF

pop ecx ;restore loop counter

.IF ecx == 1

ret

.ENDIF

loop L1

ret

Encrypt ENDP

END main

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


  • PMH4OWPW7JD2TDGWZKTOYL2T3E.jpg

  • Topics

  • Posts

    • I just rewatched all the highlights from after Bryce being benched. The Bryce hate needs to calm down a little bit. He showed a ton of potential the back half of the year. Same with Legette. They both made great plays when it mattered and a few mistakes when it counted. If we didn’t have a historically awful defense last year we could have ended even a bit better. Going into a brand new season we should be optimistic at least before game one. 2015 no one expected to go anywhere and the team steam rolled the league. I’m not saying that will happen, but hopefully we made strides to improve on the end of last year. Bryce put both Super Bowl teams in a battle last year and if we had a better D we could have taken them both. So at least look forward to the season and not past the season until it at least begins. 
    • I’m not mad at Moehrig.  He’s great at what he does.  And to be honest, a lot of my favorite safeties in our history were box-first type guys - Maxie, Minter, Mike Mitchell, Chris Harris…  they’re first and foremost objective was to put people on their backs and coverage was secondary.  There is a place for that.  There is a definite need for that.  Physical guys that set the tone.  So cool, we have that in Moerhig. But what we have lacked for the vast majority of our existence is a true free safety that cleans everything up on the back end.  Sometimes they come in the form of a JOAT, like Peppers.  I think he would be a fantastic compliment to Moehrig’s strengths and weaknesses.  If we don’t go after him, I certainly hope Ransom is given the chance to grow and develop in real-time with real game reps, because what he did in preseason was very encouraging to see.  I hope he can grow into that roaming center fielder with a little bit of an edge to him as an enforcer as well.  He has the tools.  In the meantime, adding Peppers would only help.
    • Option 1 is most likely. Even if he kills it this year, it wouldn't be prudent to rush an extension for one good season. If you have to pay him more because you waited another year, then he earned it. And that's OK. Adjust accordingly. 
×
×
  • Create New...