From: Michael Buesch Date: Sun, 27 Jan 2008 18:41:45 +0000 (+0100) Subject: b43-asm: Make use of complex immediates as memory offsets possible. X-Git-Tag: b43-fwcutter-013~67 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=3f723ef8180329e5ca5f750e12a278191053af66;p=b43-tools.git b43-asm: Make use of complex immediates as memory offsets possible. Signed-off-by: Michael Buesch --- diff --git a/assembler/parser.y b/assembler/parser.y index f00b2da..c589195 100644 --- a/assembler/parser.y +++ b/assembler/parser.y @@ -75,6 +75,7 @@ line : line_terminator { /* Allow terminating lines with the "|" char */ line_terminator : /* Nothing */ | BITW_OR line_terminator + ; section_switch : SECTION_TEXT { section = SECTION_TEXT; @@ -1083,27 +1084,26 @@ reg : GPR regnr { } ; -mem : BRACK_OPEN hexnum_decnum BRACK_CLOSE { +mem : BRACK_OPEN imm BRACK_CLOSE { struct memory *mem = xmalloc(sizeof(struct memory)); + struct immediate *offset_imm = $2; mem->type = MEM_DIRECT; - mem->offset = (unsigned long)$2; + mem->offset = offset_imm->imm; + free(offset_imm); $$ = mem; } - | BRACK_OPEN hexnum_decnum COMMA OFFR regnr BRACK_CLOSE { + | BRACK_OPEN imm COMMA OFFR regnr BRACK_CLOSE { struct memory *mem = xmalloc(sizeof(struct memory)); + struct immediate *offset_imm = $2; mem->type = MEM_INDIRECT; - mem->offset = (unsigned long)$2; + mem->offset = offset_imm->imm; + free(offset_imm); mem->offr_nr = (unsigned long)$5; $$ = mem; } ; -imm : hexnum { - struct immediate *imm = xmalloc(sizeof(struct immediate)); - imm->imm = (unsigned long)$1; - $$ = imm; - } - | decnum { +imm : hexnum_decnum { struct immediate *imm = xmalloc(sizeof(struct immediate)); imm->imm = (unsigned long)$1; $$ = imm; diff --git a/assembler/test.asm b/assembler/test.asm index 8f78893..873b761 100644 --- a/assembler/test.asm +++ b/assembler/test.asm @@ -164,6 +164,7 @@ function_b: or [0],0,[0] ; Can have one mem input and one mem output mov testlabel, r0 ; Can use label as immediate value mov r0,r1|mov r2, r3 ; | does also seperate instructions + mov [(1+1)],[(2+2),off0] ; Can use complex immediates as memory offsets ; The .initvals section generates an "Initial Values" file