asm: add segment addressing and fix [10] (#12068)
parent
514443a019
commit
7cf9c198fe
|
@ -1260,6 +1260,7 @@ pub:
|
||||||
mode AddressingMode
|
mode AddressingMode
|
||||||
pos token.Position
|
pos token.Position
|
||||||
pub mut:
|
pub mut:
|
||||||
|
segment string // fs:
|
||||||
displacement AsmArg // 8, 16 or 32 bit literal value
|
displacement AsmArg // 8, 16 or 32 bit literal value
|
||||||
base AsmArg // gpr
|
base AsmArg // gpr
|
||||||
index AsmArg // gpr
|
index AsmArg // gpr
|
||||||
|
|
|
@ -2488,6 +2488,9 @@ fn (mut g Gen) asm_arg(arg ast.AsmArg, stmt ast.AsmStmt) {
|
||||||
g.write('%$arg.name')
|
g.write('%$arg.name')
|
||||||
}
|
}
|
||||||
ast.AsmAddressing {
|
ast.AsmAddressing {
|
||||||
|
if arg.segment != '' {
|
||||||
|
g.write('%%$arg.segment:')
|
||||||
|
}
|
||||||
base := arg.base
|
base := arg.base
|
||||||
index := arg.index
|
index := arg.index
|
||||||
displacement := arg.displacement
|
displacement := arg.displacement
|
||||||
|
@ -2500,7 +2503,6 @@ fn (mut g Gen) asm_arg(arg ast.AsmArg, stmt ast.AsmStmt) {
|
||||||
}
|
}
|
||||||
.displacement {
|
.displacement {
|
||||||
g.asm_arg(displacement, stmt)
|
g.asm_arg(displacement, stmt)
|
||||||
g.write('()')
|
|
||||||
}
|
}
|
||||||
.base_plus_displacement {
|
.base_plus_displacement {
|
||||||
g.asm_arg(displacement, stmt)
|
g.asm_arg(displacement, stmt)
|
||||||
|
|
|
@ -942,6 +942,12 @@ fn (mut p Parser) asm_stmt(is_top_level bool) ast.AsmStmt {
|
||||||
if p.prev_tok.position().line_nr < p.tok.position().line_nr {
|
if p.prev_tok.position().line_nr < p.tok.position().line_nr {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
mut segment := ''
|
||||||
|
if p.tok.kind == .name && p.peek_tok.kind == .colon {
|
||||||
|
segment = p.tok.lit
|
||||||
|
p.next()
|
||||||
|
p.next()
|
||||||
|
}
|
||||||
match p.tok.kind {
|
match p.tok.kind {
|
||||||
.name {
|
.name {
|
||||||
args << p.reg_or_alias()
|
args << p.reg_or_alias()
|
||||||
|
@ -985,7 +991,9 @@ fn (mut p Parser) asm_stmt(is_top_level bool) ast.AsmStmt {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
.lsbr {
|
.lsbr {
|
||||||
args << p.asm_addressing()
|
mut addressing := p.asm_addressing()
|
||||||
|
addressing.segment = segment
|
||||||
|
args << addressing
|
||||||
}
|
}
|
||||||
.rcbr {
|
.rcbr {
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue