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 have started doing my research on these draft picks and I like this guy. But I'm am iffy on taking a TE in the first if isnt a flat out generational guy more importantly on this team where it's questionable we get the necessary impact out of him. I say if a top defensive guy at their position falls to 19th you jump on it and push this defense to an elite unit. The offense will do their part. 
    • fans view “box safety” with the same disdain they have when they hear “game manager” QB. but there’s a reason most 1st round safeties are “box safeties”-it’s a much longer list of requisite skills to be a good box safety than it is to be a guy whose only real responsibility is to not get beat over the top. Fans crave the ed reed type and as someone who has never been able to enjoy this franchise having a guy like that, I get the enthusiasm-but I’m not really prepared to spend a first round pick on a free safety. If it happens it’ll be fun, it’ll address a need with a good player and that’s well and good. But those guys end up walking after their first contract because their pedigree usually outpaces what their teams feel like they’re adding to their overall win total.
    • Its criminal that the upcoming season is mainly in the tiny hands of BY.  I still member the time I did a full turn, if you member his first off-season from that Panthers all-time worst team....... Answering questions at his first presser, he goes along the lines " I didn't do nothing, no weight room or throwing" " I needed to get away". I was fully out with him, the guy didn't even try to improve his football mind, body, strength, in the biggest joke of panther football. I could not believe it, what a leader or dare say "point guard"(lols @ NBA point guards as a ref)
×
×
  • Create New...