-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc_disp.c
More file actions
42 lines (36 loc) · 961 Bytes
/
calc_disp.c
File metadata and controls
42 lines (36 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
** calc_disp.c for calc_disp.c in /home/marcha_j//test/c/ftrace
**
** Made by hugo marchadier
** Login <marcha_j@epitech.net>
**
** Started on Thu May 31 16:12:06 2012 hugo marchadier
** Last update Fri Jun 22 14:43:28 2012 hugo marchadier
*/
#include <stdio.h>
#include <unistd.h>
#include "ftrace.h"
#include "decode_mode_rm.h"
#include "calc_disp.h"
static unsigned long calc_disp(int nb_octet, ePosDisp pos,
unsigned long instr)
{
unsigned long disp;
if (nb_octet == 1)
disp = ((instr >> (pos * 4)) & 0xf);
else
disp = ((instr >> (pos * 4)) & 0xffff);
return (disp);
}
unsigned long check_disp(eSTATUS *status, eDISP disp, eTACHE tache,
unsigned long instr)
{
if (disp == NO_DISP)
return (0);
else if (disp == DISP8 || disp == DISP32)
return ((tache == SIB) ? calc_disp(disp, WITH_SIB, instr)
: calc_disp(disp, NO_SIB, instr));
*status = ERROR;
printf("Error: unknow disp.\n");
return (0);
}