Post on 18-Jan-2019
6
Instruções de Máquina
Um processador executa instruções de máquina
Um conjunto típico de instruções inclui operações Aritméticas
Lógicas
e de desvio
Muito simples mas executadas em altíssima
velocidade
bilhões de instruções de ponto flutuante por Segundo
Representadas por sequências de dígitos binários
7
Exemplo em X64 Assembly
A common instruction is the LOOP instruction, which
decrements ECX, and then jumps if the result is not 0.
XOR EAX, EAX ; zerar o valor de EAX
;
MOV ECX, 10 ; loop 10 vezes
Aqui: ; este é um marcador para repetição
ADD EAX, 2 ; incrementa EAX de 2
LOOP Aqui ; decrementa ECX, loop se não for 0
8
X64 Assembly – operações usuais
Opcode Meaning Opcode Meaning MOV Move to/from/between
memory and registers AND/OR/XOR/NOT Bitwise operations
CMOV* Various conditional moves SHR/SAR Shift right logical/arithmetic
XCHG Exchange SHL/SAL Shift left logical/arithmetic
BSWAP Byte swap ROR/ROL Rotate right/left
PUSH/POP Stack usage RCR/RCL Rotate right/left through carry bit
ADD/ADC Add/with carry BT/BTS/BTR Bit test/and set/and reset
SUB/SBC Subtract/with carry JMP Unconditional jump
MUL/IMUL Multiply/unsigned JE/JNE/JC/JNC/J* Jump if equal/not
equal/carry/not carry/ many others
DIV/IDIV Divide/unsigned LOOP/LOOPE/LOO
PNE
Loop with ECX
INC/DEC Increment/Decrement CALL/RET Call subroutine/return
NEG Negate NOP No operation
CMP Compare CPUID CPU information
9
Linguagens de Alto-Nível
Programar em assembler excesso de detalhes devidos a natureza da máquina
propensa a erros
baixa produtividade
Meados dos anos 50 surgimento de várias linguagens de alto nível
Nível de abstração cada vez mais elevado mais próximas das linguagens utilizadas pelos seres
humanos
10
FORTRAN (1957)
COBOL (1960)
ALGOL (1968)
PASCAL (1970)
C (1972)
C++ (1983)
PYTHON (1991)
LUA (1993)
JAVA (1995)
Linguagens de Alto-Nível
11
Guido van Rossum
12
... um best seller