#40 (instruction reg, [byte indexreg*scale+imm8] suspicious) – The Yasm Modular Assembler Project

Ticket #40 (closed defect: fixed)

Opened 4 years ago

Last modified 2 years ago

instruction reg, [byte indexreg*scale+imm8] suspicious

Reported by: vclaudepierre@… Owned by: peter@…
Priority: P2 Milestone: 0.4.0
Component: Architecture: x86 Version: unspecified
Severity: normal Keywords:
Cc:

Description

;thanks for the nightly snapshots for Win9x, it rocks !
;
;nasm 0.98  outputs 06h as a dword in any case, no warnings
;yasm r1162 outputs 06h as a byte if asked,  no warnings too
;I would like a warning if possible. Moreover,
;the trouble is this opcode really needs DISP32 :-(  (if I believe Ollydbg)

;in nasm's 0.98 html doc you may have a typo if I understand well, end of
;section A.2.3
;"If mod is 0, r/m is 4 (meaning the SIB byte is present) AND BASE IS 4,
; the effective address encoded is not [EBP+index] as the above rules
; would suggest, but instead [disp32+index]: the displacement field is present
; and is four bytes long, and there is no base register (but the index register
; is still processed in the normal way)."
;I'll get an update of the doc if it exists
;IMHO you must read "AND BASE IS 5". Here we are in that special case.

;compiled with -fbin option
;a priori, idem with [bits 64]
[bits 32]
add [byte  ebp*8+06h],ecx ;db 01,0c,0ed,06 probably wrong
dd 90909090h
add [dword ebp*8+06h],ecx ;db 01,0c,0ed,06,0,0,0  OK
dd 90909090h
add ecx,[byte  ebp*8+06h] ;db 03,0c,0ed,06 probably wrong
dd 90909090h
add ecx,[dword ebp*8+06h]
dd 90909090h
add ecx,[byte ebx*8+06h]  ;db 03,0c,0dd,06 probably wrong
dd 90909090h
add ecx,[dword ebx*8+06h]
dd 90909090h

Regards

Attachments

Change History

comment:1 Changed 4 years ago by peter@…

  • status changed from new to assigned
This is intentional behavior, but worth fixing.  We currently assume that the
user knows what they are doing when they override with an explicit size (we were
going to add a warning later that this results in an invalid instruction), but
it's probably better to fix it for them to dword size (as NASM does), and warn
that their specified size wasn't valid, so it was fixed for them.

I'll put in a fix very soon for this case (with warning) to do the latter.

comment:2 Changed 4 years ago by peter@…

  • status changed from assigned to resolved
  • resolution set to fixed
  • component changed from object format: bin to architecture: x86
Fixed in r1165 (warning message, correct code generated).

Add/Change #40 (instruction reg, [byte indexreg*scale+imm8] suspicious)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.