1 / 11

Interface C / Assembly Modo Real

Interface C / Assembly Modo Real. Lauro Moura lauromoura@gmail.com. Roteiro. Assembly Inline Chamando rotinas Assembly a partir de C Exercícios. Inline Assembly. Escrito dentro do código C Bloco asm{} asm{ MOV AX, 09h ADD AX, BX }. TCC – Turbo C Compiler. tcc [options] file[s]

daw
Télécharger la présentation

Interface C / Assembly Modo Real

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interface C / AssemblyModo Real Lauro Moura lauromoura@gmail.com

  2. Roteiro • Assembly Inline • Chamando rotinas Assembly a partir de C • Exercícios

  3. Inline Assembly • Escrito dentro do código C • Bloco asm{} asm{ MOV AX, 09h ADD AX, BX }

  4. TCC – Turbo C Compiler • tcc [options] file[s] • Local das bibliotecas: p:\tc\lib • tcc –Lp:\tc\lib arquivo[s] • #pragma inline força o uso do TASM como assembler (Padrão: BASM)

  5. Exemplo 1 #pragma inline int main(){ char *msg = "Hello, World!\n$"; asm{ MOV AH, 9; MOV DX, msg; INT 21H; } return 0; }

  6. Compilando... • Utilizaremos o “make” • make ex1.exe • Mesmo processo para os outros exemplos.

  7. Assembly Inline em funções • Retorno em AX • Exemplo 2 (ex2.exe)

  8. Rotinas Assembly a partir de C • Nomes começam com ‘_’ • Ex: ‘_AX’, ‘_PrintHello’ • Arquivos compilados com o TASM e a opção mx (Case sensitive) • tasm –mx arquivo.asm • Exemplo 3

  9. Argumentos • Parâmetros passados na pilha, em ordem inversa (printf...) • Exemplo 4

  10. Exercícios • Crie um programa que compare dois números (0-9) e imprima o maior deles. Use assembly inline e arquivos separados.

  11. Referências • A to Z of C: http://guideme.itgo.com/atozofc/

More Related