Intel and AMD 64-bit processors and their instruction sets

Toadill81

Honorable
Nov 9, 2012
2
0
10,510
:hello:
Hello everyone, I am doing a paper for college for my ASM x86 class, that should describe Intel and AMD 64 bit processors and their instruction sets. I am not asking anyone to do my homework for me. I am just asking for a little direction here. I have goggled a few links but I can not use sources like wiki or any other link that does not contain valid citations. Up until now I have never really had a whole lot of experiences with hardware, except for maybe just replacing parts. So what I am asking for here are the good sites that I can get information from. Sites that have a good reputation, or any article that you may have come across that maybe a good source of learning.

I am a Game dev/Application dev/ Web dev, and I am learning ASM for optimization as far as I know so far.
Some of the languages I have studied so far include
HTML, C++, C#, VB6.0, VB.net, Delphi 7, ASP.net including some CSS, MS SQL, SQL express, SQL Server and as I have said I am currently in week 5 of ASM. 😍

Some the Libraries and layers I have used include
Irvine32, Boost, OpenMp, DirectX, and SDL(Currently learning this as well)

The reason I am listing these things is so that maybe I could tie all of these things into my paper and how they all relate. For example game porting(SDL), Boost and OpenMP(Optimization and Multi threaded processing)

• Technical aspects of the new technology
• Role of the new technology in computer organization and structure
• Ways technology improves performance
• Specific applications to game industry
• Separate glossary for the technical terms used in this paper including detailed definition of each term and associated principle

Here are my sources so far....

http://en.wikipedia.org/wiki/X86-64
Although I can not use this link in my bibliography I can still learn from it to break things down a little more for understanding things in other articles that may go over my head.

http://www.extremetech.com/extreme/56018-analyst-intel-reverseengineered-amd64
I realize that AMD and Intel kind of leap frog each other every other year, but I found it interesting in this article that it has been reported that Intel reverse engineered AMD's Instruction set. What I am curious about is if this a common thing? Is it illegal to do this? I also realize that as a programmer just about anything can be reverse engineered.

http://www.dailytech.com/AMD+to+Make+64Bit+ARM+Processors+for+Multiple+Markets+Starting+With+Opterons/article29065.htm
This link describes ARM AMD processor but what I am unsure of is if it relates my subject or if it is a completely different type of processor. It also talks about trashing the old x86 processor. Which from my understand x86 work on both 32bit and 64 bit systems.

I appreciate any guidance I may receive and thank everyone for taking the time to look over my post.

So far the hardest thing I have done in ASM x86 is decrypted a file and plot points on an axis and then color code the points according to the quadrant they are in.
Here is my project and since this is a hardware site I believe someone may understand the code.
I had a few bugs in my project while trying to plot the points, maybe someone can figure this out. By the way this assignment is already handed in so I won't be receiving any extra point for it now.

Here is the link to the encrypted file.
https://dl.dropbox.com/u/64787986/inputfile.txt

Code:
TITLE Week # 4 Assignment

INCLUDE Irvine32.inc

.data
    encrypedFile BYTE "inputfile.txt",0
    decrypedFile BYTE "outputfile.txt",0
    BUFFER_SIZE = 5000
    buffer BYTE BUFFER_SIZE DUP(?)
    bytesRead DWORD ?
    intX DWORD ?
    intY DWORD ?
    intAxisX SDWORD -15
    intAxisY SDWORD -15
.code
main PROC
    call question1Proc
    call question2Proc	
    exit
main ENDP
;-------------------------------------------------------------------------------------
question1Proc PROC

    
;Question 1###################################################

    ;a.-------------------------------------------------------
    mov edx, OFFSET encrypedFile		;Open the file
    call OpenInputFile
    push eax						;Push the register on the stack
    mov edx, OFFSET buffer			;points to the buffer
    mov ecx, BUFFER_SIZE				;max bytes to read
    call ReadFromFile				;read the file
    mov bytesRead, eax				;count of bytes read
    pop eax						;Pop the register off the stack
    call CloseFile					;Close the file

    ;b.-------------------------------------------------------
    mov esi, offset buffer			;Point to the buffer
    mov ecx, bytesRead				;Loop counter
    Decrypt:
	   mov al, byte ptr [esi]		;get byte at current pointer
	   xor al,0ffh					;Translate a byte
	   mov byte ptr [esi], al		;move that decrypted byte back to our buffer at current pointer
	   inc esi					;point to the next byte
    loop Decrypt					;loop

    ;c.-------------------------------------------------------
    call WriteString				;Print the message to the screen
    mov edx, OFFSET buffer			;Display the buffer
    call WriteString				

    ;d.-------------------------------------------------------
    ;Create the output file 
    mov edx,OFFSET decrypedFile
    call CreateOutputFile
    ;Write to file
    push eax					;get the decrypted file
    mov edx, OFFSET buffer		;points to the buffer
    mov ecx, BUFFER_SIZE			;max bytes to read
    call WriteToFile			;Write to file
    pop eax					;Pop the register off the stack
    call CloseFile				;Close the file
    call Crlf					;Go to the next line
    call waitMsg				;Wait
    call Clrscr				;Clear the screen

    ;e.-------------------------------------------------------
    COMMENT &
	   Bonus Question:
	   Hi Joe, 
	   Here's at question I have pondered. What is the hibernation period of the antartic polar bear?
	   Thanks
	   Andrew

	   Anwser = Polar do not hibernate or live in the antartic
	   polar bears instead enter a state of walking hibernation 
	   where their metabolism slows. 
	   Only pregnant polar bears enter a den, give birth, and emerge three months later.
	   [url=http://www.polarbearsinternational.org/about-polar-bears/faqs#q15]http://www.polarbearsinternational.org/about-polar-bears/faqs#q15[/url] 
	   &
	   ret
		  
question1Proc ENDP
;-------------------------------------------------------------------------------------
;a.-------------------------------------------------------
;Question 2 procedure
question2Proc PROC
   
mov ecx, 32						;Moving 32 into ecx to use to control the point loop
point:							;Start the loop
    call randomY					;Call the randomY Procedure
    call randomX					;Call the randomX procedure
    call checkPoint					;Check what quadrate the point belongs
    mov dh,BYTE PTR intX				;Moving intX into dh to use with GotoXY, had to use PTR because of size difference.
    mov dl,BYTE PTR intY				;Moving intY into dl to use with GotoXY, had to use PTR because of size difference.
    add dl,15						;Adding 15 back into dl because negitives do not work.
    add dh,15						;Adding 15 back into dh because negitives do not work.
    call Gotoxy					;Calling Procedure Gotoxy
    mov eax,intX					;Moving intX into eax to display with WriteInt
    call WriteInt					;Write the integer
    mov eax,intY					;Moving inty into eax to display with WriteInt
    call WriteInt					;Moving inty into eax to display with WriteInt
loop point						;End of loop point
call Crlf							;Move the cursor to the next line
call drawAxis
call waitMsg
ret								;Return control back to main
question2Proc ENDP

;-------------------------------------------------------------------------------------

;randomize Y procedure===================================
randomY PROC
    call random
    mov intY,eax
    ret
randomY ENDP
;-------------------------------------------------------------------------------------

;randomize X procedure===================================
randomX PROC
    call random
    mov intX,eax
    ret
randomX ENDP
;-------------------------------------------------------------------------------------

;random procedure===================================
random PROC
    mov eax,29						;values 0- 29
    call RandomRange				;Generate a random int
    sub eax,15						;value from -15 - +14
    ret							;return
random ENDP						;end random procedure
;-------------------------------------------------------------------------------------

;check point procedure
checkPoint PROC					;Begin check point procdure
    mov edx,intX					;Moving intX into edx for compare
    cmp edx,0						;Comparing edx to zero
    JG Xgreater					;If edx greater then zero jump to Xgreater
    JL Xlesser						;If edx less then zero jump to Xlesser
Xgreater:							;Xgreater knows that X is greater then zero, now compares y
    mov edx,intY					;Moving intY into edx for compare
    cmp edx,0						;Comparing edx to zero
    JG YandXGreat					;If edx greater than zero jump to YandXGreat
    JL XgreatYless					;If edx less than zero jump to XgreatYless
YandXGreat:						;YandXgreat is the Quadrant 1, sets text color to yellow
    mov eax,yellow + (black * 16)		;Assign the color yellow
    Call SetTextColor				;Call the color function
    JMP Complete					;Jump to complete
XgreatYless:						;XgreatYless is Quadrant 4, sets text color to green
    mov eax,green + (black * 16)		;Assign color green
    Call SetTextColor				;Call the color function
    JMP Complete					;Jump to complete
Xlesser:							;Xlesser knows that X is less then zero, now compares y
    mov edx,intY					;Moving intY into edx for compare
    cmp edx,0						;Comparing edx to zero
    JG XlessYgreat					;If edx greater then zero goto XlessYgreat
    JL XlessYless					;If edx less then zero goto XlessYless
XlessYgreat:						;XlessYgreat is Quadrant 2, sets text color to cyan
    mov eax,cyan + (black * 16)		;Assign color cyan
    Call SetTextColor				;Call the color function
    JMP Complete					;Jump to complete
XlessYless:						;XlessYesll is Quadrant 3, sets text colot to red
    mov eax,red + (black * 16)		;Assign color red
    Call SetTextColor				;Call the color function
    JMP Complete					;Jump to complete
    Complete:						;Complete jump
    ret
checkPoint ENDP
;-------------------------------------------------------------------------------------

drawAxis PROC
    call drawXAxis
    call drawYAxis
    ret
drawAxis ENDP

drawXAxis PROC
    mov ecx,36
    loopXAxis: 
	   mov dl,BYTE PTR intAxisX
	   mov dh,BYTE PTR intAxisY
	   add dh, 16
	   sub dl, 36
	   call Gotoxy
	   mov eax,0
	   call WriteInt
	   INC intAxisX
	   DEC ecx
    loop loopXAxis
    ret
drawXAxis ENDP

drawYAxis PROC
    mov ecx, 36
    loopYAxis: 
	   mov dl,BYTE PTR intAxisX
	   mov dh,BYTE PTR intAxisY
	   add dl, 10
	   sub dh, 236
	   call Gotoxy
	   mov eax,0
	   call WriteInt
	   INC intAxisY
	   DEC ecx
    loop loopYAxis
    ret
drawYAxis ENDP

END main

Thanks for any help! :wahoo:
 
Oh wow, been a while since I've looked at X86 assembly code...

Anyways, a few technical points:

X86 generally refers to the 32-bit instruction set in both AMD and Intel processors.
X64 typically refers to the AMD-64 instruction set, which is the 64-bit instruction set that runs when the processor is set to long mode.
Intel-64 or X86-64 typically refers to Intels failed 64-bit implementation.

Anyway, give me a bit to look at the code; I'm a bit rusty with X86 code, but I'll post again if I find anything obviously wrong.
 
Don't see anything obviously wrong, except:

;b.-------------------------------------------------------
mov esi, offset buffer ;Point to the buffer

I forget if X86 assembly is case sensitive or not; in either case, capitalizing OFFSET would be good practice. Don't see anything else obviously wrong at first glance; may play a bit at home over the weekend...

ASM actually isn't that hard to code, provided you understand basic program flow and think through the steps that need to be taken. I've used four or five different forms of ASM over my career, and I don't find it particularly challenging (slow and tedious, but not hard).
 


It is not case sensitive, the only errors I have had were in the PROC question 2, and it seems to display the correct color for the quadrants but the numbers are off by one quadrant in a clockwise direction. Not sure what is causing it. :pt1cable:

Thanks gamerk316 :)
 

The x86 in x86-64 stands for x86-64 being an extension to the x86 instruction set and that would be AMD's 64bits stuff.

IA64 is Intel's Itanium Architecture instruction set. There is no "x86" in Intel's Itanium instruction set names since they are completely unrelated to the legacy x86 instruction set..