comparison lwasm/pseudo.c @ 158:f0527dc3804d

Added support for .globl <sym>, .area <section>, .word, .byte, .blkb, and a .module directive that does nothing
author lost
date Sat, 31 Jan 2009 05:30:06 +0000
parents 427e268e876b
children b061350c17e4
comparison
equal deleted inserted replaced
157:745721e13970 158:f0527dc3804d
27 #include "instab.h" 27 #include "instab.h"
28 #include "expr.h" 28 #include "expr.h"
29 #include "util.h" 29 #include "util.h"
30 30
31 extern int lwasm_read_file(asmstate_t *as, const char *filename); 31 extern int lwasm_read_file(asmstate_t *as, const char *filename);
32
33 OPFUNC(pseudo_noop)
34 {
35
36 }
32 37
33 OPFUNC(pseudo_org) 38 OPFUNC(pseudo_org)
34 { 39 {
35 int v, r; 40 int v, r;
36 41
906 911
907 OPFUNC(pseudo_export) 912 OPFUNC(pseudo_export)
908 { 913 {
909 lwasm_symbol_ent_t *se; 914 lwasm_symbol_ent_t *se;
910 export_list_t *ex; 915 export_list_t *ex;
911 916 char *sym2, *sym3;
917
912 if (as -> outformat != OUTPUT_OBJ) 918 if (as -> outformat != OUTPUT_OBJ)
913 { 919 {
914 register_error(as, l, 1, "Symbol exports only supported for obj target"); 920 register_error(as, l, 1, "Symbol exports only supported for obj target");
915 return; 921 return;
916 } 922 }
917 923
918 if (as -> passnum == 1) 924 if (as -> passnum == 1)
919 return; 925 return;
926
927 if (!(l -> sym))
928 {
929 // look for symbol after op
930 if (**p)
931 {
932 for (sym2 = *p; **p && !isspace(**p); (*p)++)
933 /* do nothing */
934 sym3 = lwasm_alloc(*p - sym2 + 1);
935 memcpy(sym3, sym2, *p - sym2);
936 sym3[*p - sym2] = '\0';
937
938 l -> sym = sym3;
939 }
940 }
941
942 if (!(l -> sym))
943 {
944 register_error(as, l, 2, "No symbol");
945 return;
946 }
947
920 948
921 // the symbol better be defined at this point (pass 2) 949 // the symbol better be defined at this point (pass 2)
922 // local symbols cannot be exported nor can "global" symbols 950 // local symbols cannot be exported nor can "global" symbols
923 se = lwasm_find_symbol(as, l -> sym, -1); 951 se = lwasm_find_symbol(as, l -> sym, -1);
924 if (!se) 952 if (!se)