config/msvc.h: inttypes.h and stdbool.h introduced in MSVS 2013
[nasm.git] / output / legacy.c
blob7c1dcec1f43831ffe04ea20c33db1dfd13068259
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2016 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
9 * conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
35 * output/legacy.c
37 * Mangle a struct out_data to match the rather bizarre legacy
38 * backend interface.
41 #include "nasm.h"
43 void nasm_do_legacy_output(const struct out_data *data)
45 const void *dptr = data->data;
46 enum out_type type = data->type;
47 int32_t tsegment = data->tsegment;
48 int32_t twrt = data->twrt;
49 uint64_t size = data->size;
51 switch (data->type) {
52 case OUT_RELADDR:
53 switch (data->size) {
54 case 1:
55 type = OUT_REL1ADR;
56 break;
57 case 2:
58 type = OUT_REL2ADR;
59 break;
60 case 4:
61 type = OUT_REL4ADR;
62 break;
63 case 8:
64 type = OUT_REL8ADR;
65 break;
66 default:
67 panic();
68 break;
71 dptr = &data->toffset;
72 size = data->inslen - data->insoffs;
73 break;
75 case OUT_SEGMENT:
76 type = OUT_ADDRESS;
77 /* fall through */
79 case OUT_ADDRESS:
80 dptr = &data->toffset;
81 size = (data->sign == OUT_SIGNED) ? -data->size : data->size;
82 break;
84 case OUT_RAWDATA:
85 case OUT_RESERVE:
86 tsegment = twrt = NO_SEG;
87 break;
89 default:
90 panic();
91 break;
94 ofmt->legacy_output(data->segment, dptr, type, size, tsegment, twrt);