ASM
No notes
Syntax:
No syntax
FINISH MACRO mov ax, 4c00h ;call interrupt to return to DOS int 21h ENDM LOAD_DS MACRO SEG_ADDR MOV AX, SEG_ADDR MOV DS, AX ENDM SUB_DDM MACRO X, Y, Z, Z1 LEA AX, X LEA BX, Y LEA CX, Z CALL sub_dd ENDM ADD_DDM macro X, Y, Z, Z1 SUB_DDM ZERO, Y, Z1 SUB_DDM X, Z1, Z ENDM stacksg segment para stack 'stack' dw 32 dup(0) stacksg ends ; ; datasg segment para 'data' ZERO DD 0 Z1 DD ? A DD 1230 B DD 100 RES DD ? datasg ends ; codesg segment para 'code' test proc far assume ss:stacksg, ds:datasg, cs:codesg LOAD_DS datasg ADD_DDM A, B, RES, Z1 SUB_DDM B, A, RES SUB_DDM A, B, RES SUB_DDM ZERO, A, RES FINISH test endp ;------------------------------------------------------------------------ ;------------------------------------------------------------------------- ; sub_dd makes the following assumptions: ; Interface Rules: ; ================ ; 1. The address of operand1 in AX; operand1 is double word ; 2. The address of operand2 in BX, operand2 is double word ; 3. The address of the result (operand1 - operand2) in CX; the difference is stored in a double word ; 4. The flags are set as required by ordinary addition in the procedure. ; 5. No registers including AX, BX and CX are changed. ; 6. 5 extra temporary words in the stack are used. ; sub_dd proc PUSH AX PUSH BX PUSH CX PUSH SI PUSH DI CLC MOV SI, AX ; SI points to OP1 MOV DI, BX ; DI points to OP2 MOV BX, CX ; BX points to OP1-OP2 MOV AX, [SI] SBB AX, [DI] ; MOV [BX], AX ; INC SI INC SI ; address of the most significant word of OP1 INC DI INC DI ; address of the most significant word of OP2 INC BX INC BX ; address of the most significant word of OP1-OP2 MOV AX, [SI] SBB AX, [DI] MOV [BX], AX ; POP DI POP SI POP CX POP BX POP AX RET add_ddm A, B, RES, Z1 sub_dd endp codesg ends end test