0

I don't know why emu8086 does not recognize the movezx instruction, sorry I am new to assembly. thanks for the help..

.MODEL SMALL
.STACK 64

;--------------------------
.DATA
TOPROW  EQU 08
BOTROW  EQU 15 
LEFTCOL EQU 26
ATTRIB  DB ?
ROW     DB 00
SHADOW  DB 19 DUP(0DBH)
MENU    DB 0C9H, 17 DUP(OCDH), 0BBH
    DB 0BAH, 'Add records '
    DB 0BAH, ' Delete records '
    DB 0BAH, ' Enter Orders '
    DB 0BAH, ' Print Report '
    DB 0BAH, ' Update accounts '
    DB 0BAH, ' View records '
    DB 0C8H, 17 DUP(OCDH),0BCH
PROMPT  DB ' To select an item, use <Up/Down Arrow>'  
    DB ' and press <Enter> '
    DB 13, 10 ' Press <Esc> to exit. '
;---------------------------
.CODE
A10MAIN PROC FAR
    MOV AX,@data
    MOV DS,AX
    MOV ES,AX
    CALL Q10CLEAR
    MOV ROW,BOTROW+4

A20:
    CALL B10MENU
    MOV ROW,TOPROW+1
    MOV ATTRIB 16H
    CALL D10DISPLAY
    CALL C10INPUT
    CMP AL,1BH
    JNE A20
    MOV AX,0600H
    CALL Q10CLEAR
    MOV AX,4C00H
    INT 21H
A10MAIN ENDP

;Display shadow box, next menu on top, then prompt
;--------------------------------------------------

B10MENU PROC NEAR
    PUSHA
    MOV AX,1301H
    MOV BX,0060H
    LEA BP,SHADOW
    MOV CX,19
    MOV DH,TOPROW+1
    MOV DL,LEFTCOL+1

B20:    INT 10H
    INC DH
    CMP DH,BOTROW+2
    JNE B20
    MOV ATTRIB,71H
    MOV AX,1300H
    MOVZX BX,ATTRIB
    LEA BP,PROMPT  

This is the unfinished code from Peter Abel's book (IBM PC ASSEMBLY LANGUAGE AND PROGRAMMING 5TH EDITION)

2 Answers2

2

The MOVZX instruction doesn't exist on the 8086. It was added in the 80386.

  • that means I need to use an 80386 emulator so that I can use the MOVZX instruction? – Nevin Rae Orbigozo Mar 13 '16 at 04:53
  • Correct; or use another instruction sequence that is supported by the 8086. –  Mar 13 '16 at 05:33
  • can you please help me with that? I don't seem to know what instruction sequence to use.. my knowledge about assembly is still not sufficient enough. thanks in advance! – Nevin Rae Orbigozo Mar 13 '16 at 05:35
  • In this context, MOVZX moves a byte value into a word register by zero-extending it (i.e, setting the high half of the word to zero). It's equivalent to a move to BL, then zeroing BH. –  Mar 13 '16 at 05:39
1

In this context, MOVZX moves a byte value into a word register by zero-extending it (i.e, setting the high half of the word to zero). It's equivalent to a move to BL, then zeroing BH. – duskwuff Mar 13 at 5:39

instead of

MOVZX BX, ATTRIB

type

mov bh, 00
mov bl, ATTRIB

or

mov bl, ATTRIB
mov bh, 00
flyingpluto7
  • 1,079
  • 18
  • 20
  • [`xor bx,bx` / `mov bl, ATTRIB` is better](http://stackoverflow.com/questions/33666617/which-is-best-way-to-set-a-register-to-zero-in-x86-assembly-xor-mov-or-and/33668295#33668295): it avoids a partial-register stall on Intel CPUs, and a false-dependency on the old value of BX on other CPUs. – Peter Cordes Jun 09 '16 at 04:41
  • 1
    @PeterCordes Does it though? I didn't think `xor bx, bx` could break dependencies since it's only a 16-bit operation and doesn't affect the whole 32-bit register. – Ross Ridge Jun 09 '16 at 05:57
  • @RossRidge: Oh good point, it wouldn't avoid false dependencies on CPUs that don't rename partial-regs. It would avoid partial-reg merging slowdowns when you read BX after writing BL on CPUs that do. (P6-family and SnB/IvB. Haswell and later rename partial regs but have no merging penalty at all.) – Peter Cordes Jun 09 '16 at 06:00