Microsoft (R) Macro Assembler Version 6

advertisement
EE314. Review 1
Microsoft (R) Macro Assembler Version 6.11
Test program
0000
00C8 01 02 03 04
Title Test program
.model small
.data
org 200
datab db 1,2,3,4
09/23/99 20:33:50
Page 1 - 1
;data name (label) in DATA segment. BYTE size attribute.
;will be treated by default as DIRECT addressing mode.
00CC 41 42 43 44
datas db 'ABCD'
;ASCII character string. Same attributes like previous.
00D0 0005 0006 0007
dataw
;same as previous, but WORD size attribute.
= 0009
cstds equ 9
= 000A
cstds1
dw 5,6,7
;constant declaration. No segment connected.
;will be treated by default as IMMEDIATE addressing mode.
;Constants declared using "EQU" cannot be later modified
;in the .ASM file.
= 0ah
;same as previous.
;Constants declared using "=" can be later modified
;in the .ASM file. When constant's name is used it is
;replaced with the last updated value.
0000
= 000B
= 000C
.code
cstcs equ 0bh
cstcs1 = 0ch
;same as before. No segment connected
;same as before. No segment connected
0000 0D 0E
datacs
;data name in CODE segment. Byte size attribute.
0002
0002
0004
0006
0008
db 0dh,0eh
begtpr:
;LABEL in CODE segment.
;The address of first following instruction.
;Same attributes like data in code segment.
B0 64
B0 64
B0 64
B0 64
mov al,100
;constant value in the body of the instruction
mov al,[100]
;IMMEDIATE addressing mode used.
mov al,offset 100
mov al,byte ptr 100
;no segment connected => no byte pointed by value 100
mov al,seg 100
;no segment connected
c:\masm611\myfiles\review1.asm(36): error A2094: operand must be relocatable
000A B0 09
000C B0 09
000E B0 09
0010 B0 09
mov al,cstds
;constant declared with "EQU":
mov al,[cstds]
;same meaning like a constant in the body of the instruction
mov al,offset cstds
mov al,byte ptr cstds
mov al,seg cstds
c:\masm611\myfiles\review1.asm(42): error A2094: operand must be relocatable
0012 A0 00C8 R
0015 A0 00C8 R
mov al,datab
mov al,[datab]
;data name in DATA segment: DIRECT addressing mode
;R shows relocatable character of the address.
mov al,offset datab
;try to use IMMEDIATE addressing mode.
c:\masm611\myfiles\review1.asm(47): error A2070: invalid instruction operands
;OFFSET datab is WORD size, so doesn't fit in AL
0018 B8 00C8 R
mov ax,offset datab
;IMMEDIATE addressing mode. Effective Address (OFFSET)
;of datab in DATA segment is loaded into AX.
;similar effect with: "LEA ax,datab"
001B 8E D8
mov ds,ax
;ds REGISTER is NOT automatically loaded with the address
;of .DATA segment declared to assembler. This loading
;has to be performed by the program itself.
;All DIRECT MOVs performed until this point use a
;WRONG value in DS register.
;CS, IP and SS registers are loaded automatically when program is loaded in memory
;for execution. No initial load in program is needed.
mov ax,datab
;try to load a BYTE in a WORD register
c:\masm611\myfiles\review1.asm(64): error A2070: invalid instruction operands
001D A1 00C8 R
mov ax,word ptr datab
;overrides size attribute of datab to WORD
0020 A0 00C8 R
mov al,byte ptr datab ;BYTE PTR directive is redundant
mov al,seg datab
;try to load a SEGMENT value (WORD size) in AL
c:\masm611\myfiles\review1.asm(70): error A2070: invalid instruction operands
0023 B8 ---- R
mov ax,seg datab
;the relocatable address of DATA segment is loaded into AX
;data declared in CODE segment
0026 2E: A0 0000 R
mov al,datacs
;data name in CODE segment: DIRECT addressing mode
002A A0 0000 R
002D 2E: A0 0000 R
0031 26: A0 0000 R
0035 36: A0 0000 R
mov
mov
mov
mov
;overriding the default SEGMENT REGISTER
al,ds:datacs
al,cs:datacs ;
al,es:datacs ;
al,ss:datacs ;
;The offset created by an indirect operand is assumed to be from DS
;except when BP or EBP is part of the indirect operand. The later indicate
;offsets from stack segment (SS register).
;Other exception: destination in string instructions is by default ES:DI.
0039 2E: A0 0000 R
mov al,[datacs]
;R shows relocatable character of the address.
mov al,offset datacs ;try to use IMMEDIATE addressing mode.
c:\masm611\myfiles\review1.asm(91): error A2070: invalid instruction operands
;OFFSET datacs is WORD size, so doesn't fit in AL
003D B8 0000 R
mov ax,offset datacs
;IMMEDIATE addressing mode. Effective Address (OFFSET)
;of datacs in CODE segment is loaded into AX.
;similar effect with: "LEA ax,datacs"
mov ax,datacs
;try to load a BYTE in a WORD register
c:\masm611\myfiles\review1.asm(98): error A2070: invalid instruction operands
0040 2E: A1 0000 R
mov ax,word ptr datacs
;overrides size attribute of datacs to WORD
0044 2E: A0 0000 R
mov al,byte ptr datacs
;BYTE PTR directive is redundant
mov al,seg datacs
;try to load a SEGMENT value (WORD size) in AL
c:\masm611\myfiles\review1.asm(104): error A2070: invalid instruction operands
0048 B8 ---- R
mov ax,seg datacs
;the relocatable address of CODE segment is loaded into AX
;All instructions applied to datacs are similar executed on LABEL "begptr"
.stack 100
end
begtpr
_Microsoft (R) Macro Assembler Version 6.11
Test program
09/23/99 20:33:50
Symbols 2 - 1
Segments and Groups:
Name
Size
Length Align Combine Class
DGROUP . . . . . . . . . . . . .
GROUP
_DATA . . . . . . . . . . . . . 16 Bit 00D6 Word
Public 'DATA'
STACK . . . . . . . . . . . . . 16 Bit 0064 Para Stack
'STACK'
_TEXT . . . . . . . . . . . . . 16 Bit 0077 Word
Public 'CODE'
Symbols:
Name
Type
Value Attr
@CodeSize . . . . . . . . . . .Number
0000h
@DataSize . . . . . . . . . . .Number
0000h
@Interface . . . . . . . . . . .Number
0000h
@Model . . . . . . . . . . . . . Number
0002h
@code . . . . . . . . . . . . . Text
_TEXT
@data . . . . . . . . . . . . . Text
DGROUP
@fardata? . . . . . . . . . . .Text
FAR_BSS
@fardata . . . . . . . . . . . . Text
FAR_DATA
@stack . . . . . . . . . . . . . Text
DGROUP
begtpr . . . . . . . . . . . . . L Near
0002 _TEXT
cstcs1 . . . . . . . . . . . . . Number
000Ch
cstcs . . . . . . . . . . . . .
Number
000Bh
cstds1 . . . . . . . . . . . . . Number
000Ah
cstds . . . . . . . . . . . . . Number
0009h
datab . . . . . . . . . . . . . Byte 00C8 _DATA
datacs . . . . . . . . . . . . . Byte 0000 _TEXT
datas . . . . . . . . . . . . . Byte 00CC _DATA
dataw . . . . . . . . . . . . . Word 00D0 _DATA
0 Warnings
8 Errors
Download