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