Im have trouble trying to calulate this 3a-4c. The program calculate only 3*a and produces no errors.

call getPos 
M1 dw ?
mov M1, AX  
call crlf
call getPos     
M2 dw ?
mov M2, AX 
call crlf
call getPos 
M3 dw ?
mov M3, AX  
call crlf
mov BX, 2   
mov CX, 3   
mov DX, 4   
mov AX, M1  
mul CX      
mov SI, AX  
mov AX, M3  
mul DX      
mov DI, AX  
sub SI, DI  
mov AX, SI       
call putPos     
mov ah, 04c
int 021
include ioSubs.inc

Recommended Answers

All 2 Replies

Unless getPos does something special with return, lines 1-2, 5-6 and 9-10 will not work unless you did something like this.

    call    getPos
    jmp     $ + 4
    M1      dw  ?
    mov`    ax, M1

Show me the code for ioSubs.inc and I'll show you a much simpler way of doing this.

You seem to be mixing code and data, and you can't do that in assembly language. First you would need to have all the code, and then define the variables at the end

..............
..............
mov ah, 04c
int 021

M1 dw ?
m2 dw ?
M3 dw ?
M4 dw ?

However, it isn't clear what M1 and M2 are for, because they don't seem to be used in the calculation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.