请问,有人知道如何用汇编语言编写代码重载吗?我有错误:
(70),(72) A4057: Illegal size for operand
错误代码:
mov ax, offset ob1.DRAW
mov _this.DRAW, ax //(70)
mov ax, seg ob1.DRAW
mov _this.DRAW+2, ax //(72)
我尝试执行与此非常相似的程序(示例14): http://www.drdobbs.com/embedded-systems/object-oriented-programming-in-assembly/184408319
我的代码:
.MODEL SMALL
dseg segment byte public 'data'
_This equ es:[bx] ;Provide a mnemonic name for THIS.
Shape_Draw PROC FAR
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG3 ;print msg3
MOV AH,09H
INT 21H
RET
Shape_Draw ENDP
Rect_Draw PROC FAR
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG1 ;print msg1
MOV AH,09H
INT 21H
RET
Rect_Draw ENDP
Circle_Draw PROC FAR
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG2 ;print msg2
MOV AH,09H
INT 21H
RET
Circle_Draw ENDP
Shape struc
ix dw ? ;Wspolrzedna X
iy dw ? ;Wspolrzedna Y
Draw dd Shape_Draw ;Default (overridden) DRAW routine
Shape ends
;
Rect struc
dw 2 dup (?) ;Reserve space
dd Rect_Draw ;Draw a rectangle
Rect ends
;
Circle struc
dw 2 dup (?) ;Reserve space
dd Circle_Draw ;Draw a circle
Circle ends
dseg ends
.DATA
MSG1 DB "Klasa RECT: ",'$'
MSG2 DB "Klasa CIRCLE: ",'$'
MSG3 DB "Klasa SHAPE: ",'$'
ob1 Shape <'1','1'>
ob11 Shape <'2','2'>
ob2 Rect <,>
ob3 Circle <,>
cseg segment byte public 'CODE'
assume cs:cseg, ds:dseg, es:dseg
main:
mov bx, seg ob1
mov es, bx
mov bx, offset ob1
call ob1.Draw ;Assuming S1 is in the data seg
mov ax, offset ob1.DRAW
mov _this.DRAW, ax
mov ax, seg ob1.DRAW
mov _this.DRAW+2, ax
MOV AH,4CH
INT 21H
END
cseg end
我不懂汇编语言。 :(我将代码插入C ++中,以解释我想要做什么。
class Figura{
public:
int x=2;
int y=3;
virtual void draw();
};
class Rect :public Figura{
public:
void draw(){
cout << "RECT DRAW" << endl;
};
};
int main()
{
Rect object;
object.draw();
return 0;
}