Please, does anybody know how to code overloading in assembly language? I have error:
(70),(72) A4057: Illegal size for operand
CODE WITH ERROR:
mov ax, offset ob1.DRAW
mov _this.DRAW, ax //(70)
mov ax, seg ob1.DRAW
mov _this.DRAW+2, ax //(72)
I try do program very similar to this(Example 14): http://www.drdobbs.com/embedded-systems/object-oriented-programming-in-assembly/184408319
My code:
.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
I don't know Assembly Language. :( I insert my code in c++ to explain what I want to do.
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;
}