w6a: MOVB REX for SI/DI/BP/SP; LEAQ/CALL shapes err; honest diag lengths
Three w6a defects, one component. MOVB with an SP/BP/SI/DI register operand encoded AH/CH/DH/BH -- emit_rex suppressed the bare 0x40 that selects SPL/BPL/SIL/DIL (the comment claimed "we always emit REX"; encode probe: `MOVB SI,(AX)` -> `88 30` = %dh). emit_rex8 forces the byte for low-byte codes 4-7; no current w6c output emits those shapes, so all existing objects are unchanged. LEAQ and CALL unsupported operand shapes fell through with zero bytes and no errs++ (every MOV arm reports); both now err. Every hardcoded os.write diagnostic length in the wwstage was one byte short (truncating the newline/quote); all converted to the .len idiom so the length cannot drift again.
This commit is contained in:
@@ -73,16 +73,19 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
if (cstreq(a, "-o")) {
|
||||
i += 1;
|
||||
if (i >= argc) {
|
||||
os.write(2, "w6a: -o requires arg\n".ptr, 20u64);
|
||||
let wm1: str = "w6a: -o requires arg\n";
|
||||
os.write(2, wm1.ptr, wm1.len: u64);
|
||||
return 2;
|
||||
};
|
||||
out = argv[i];
|
||||
} else { if (a[0u64] == 45u8) {
|
||||
os.write(2, "w6a: unknown flag\n".ptr, 17u64);
|
||||
let wm2: str = "w6a: unknown flag\n";
|
||||
os.write(2, wm2.ptr, wm2.len: u64);
|
||||
return 2;
|
||||
} else {
|
||||
if (src != nil) {
|
||||
os.write(2, "w6a: only one input\n".ptr, 19u64);
|
||||
let wm3: str = "w6a: only one input\n";
|
||||
os.write(2, wm3.ptr, wm3.len: u64);
|
||||
return 2;
|
||||
};
|
||||
src = a;
|
||||
@@ -91,11 +94,13 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
};
|
||||
|
||||
if (src == nil) {
|
||||
os.write(2, "usage: w6a_ww -o file.o file.s\n".ptr, 30u64);
|
||||
let wm4: str = "usage: w6a_ww -o file.o file.s\n";
|
||||
os.write(2, wm4.ptr, wm4.len: u64);
|
||||
return 2;
|
||||
};
|
||||
if (out == nil) {
|
||||
os.write(2, "w6a: missing -o\n".ptr, 15u64);
|
||||
let wm5: str = "w6a: missing -o\n";
|
||||
os.write(2, wm5.ptr, wm5.len: u64);
|
||||
return 2;
|
||||
};
|
||||
|
||||
@@ -103,7 +108,8 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
let blen: u64;
|
||||
buf, blen = slurp(src);
|
||||
if (buf == nil) {
|
||||
os.write(2, "w6a: cannot read input\n".ptr, 22u64);
|
||||
let wm6: str = "w6a: cannot read input\n";
|
||||
os.write(2, wm6.ptr, wm6.len: u64);
|
||||
return 1;
|
||||
};
|
||||
|
||||
@@ -120,7 +126,8 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
|
||||
let fd: i32 = os.open(pathstr(out), os.flag.WRONLY | os.flag.CREATE | os.flag.TRUNC, 420i32); // 0o644
|
||||
if (fd < 0) {
|
||||
os.write(2, "w6a: cannot open output\n".ptr, 23u64);
|
||||
let wm7: str = "w6a: cannot open output\n";
|
||||
os.write(2, wm7.ptr, wm7.len: u64);
|
||||
return 1;
|
||||
};
|
||||
let rc: i32 = emitelf(&s, fd);
|
||||
|
||||
Reference in New Issue
Block a user