8086装配错误

时间:2014-03-12 02:04:40

标签: assembly fibonacci x86-16

我已经在8086程序集中编写了这个程序,我可以得到一些我不理解的错误。即在第26和27行,我收到错误" Illegal Immediate"在第31,37,38,43,44行,我收到错误"无法转换为指针"。我是这种编程语言的新手,但我认为这些行是有效的。任何人都可以对我可能做错的事情有所了解吗?非常感谢。


title   files in title      ;program name
;-------------------------------------------------------------------------------------
stacksg segment para stack 'Stack'  ;define the stack
    db  32 dup (0)      ;32 bytes, might want to set larger
stacksg endS
;-------------------------------------------------------------------------------------
datasg  segment para 'Data'     ;data segment

first db 0
second db 1
loopit dw 12

datasg  ends
;-------------------------------------------------------------------------------------
codesg segment para 'Code'      ;code segment
main    proc    far         ;main procedure
    assume  ss:stacksg, ds:datasg, cs:codesg  ;define segment registers


    MOV AL, first   ;moves 0 into AL
    MOV AH, second  ;moves 1 into AH


    MOV CX, loopit  ; sets limit to 12 (parity flag)

    MOV [200],AL    ;moves 0 into memory location 200
    MOV [201],AH    ;moves 1 into memory location 201

    MOV BL,202  ;moves 200 into BL
    ADD AH, AL  ;adds 0 and 1, AH is still 1
    MOV [BL],AH ;moves 1 into memory location 202
    INC BL      ;increments BL, BL is now 203

    MOV CL,201  ;moves 201 into CL
    MOV CH, 202 ;moves 202 into CH

    ADD AH,[CL] ;adds 1 and 1, AH is now 2
    MOV [BL], AH    ;moves 2 into memory location 203 (indirectly via BL)
    INC BL      ;increments BL, BL is now 204

loopSection:
    INC CL      ;increments CL
    ADD AH,[CL] ;adds what is in memory location CL to AH
    MOV [BL], AH    ;moves what is in BH into memory location  (indirectly via BL)
    INC BL      ;increments BL

    DEC CX      ; decrements cx by 1

    jnz loopSection



main    endp            ;end of procedure
codesg  ends
    end main

1 个答案:

答案 0 :(得分:0)

   Instruction Prefix                0 oder 1 Byte
   Segment Prefix                    0 oder 1 Byte
   Opcode                            1 oder 2 Byte
-> Mod R/M                           0 oder 1 Byte
   Displacement                      0, 1, 2 Byte
   Immediate                         0, 1, 2 Byte

-> Mod R/M-Byte = MM RRR MMM

MM  - Memeory addressing mode
RRR - Register operand address
MMM - Memoy operand address

RRR Register Names
Filds  8bit  16bit
000    AL     AX
001    CL     CX
010    DL     DX
011    Bl     BX
100    AH     SP
101    CH     BP
110    DH     SI
111    BH     DI

MMM   Default MM Field
Field Sreg     00        01          10             11=MMM is reg
000   DS       [BX+SI]   [BX+SI+o8]  [BX+SI+o16]
001   DS       [BX+DI]   [BX+DI+o8]  [BX+DI+o16]
010   SS       [BP+SI]   [BP+SI+o8]  [BP+SI+o16]
011   SS       [BP+DI]   [BP+DI+o8]  [BP+DI+o16]
100   DS       [SI]      [SI+o8]     [SI+o16]
101   DS       [DI]      [DI+o8]     [SI+o16]
110   SS       [o16]     [BP+o8]     [BP+o16]
111   DS       [BX]      [BX+o8]     [BX+o16]
Note: MMM=110,MM=0 Default Sreg is DS !!!!