data segment abc dw 1101H def dw 0025H pqr dw 0011H res dw ? res1 dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,abc mov bx,def mov cx,pqr mov dx,0002H jmp ma back: push ax push bx push cx pop cx pop bx pop ax mov ax,abc inc ax mov abc,ax mov bx,def dec bx mov def,bx ma: add ax,bx mov res,ax dec dx jnz back in ax,25H out 30H,ax mov res1,ax int 3 code ends end start
Output
C:\TASM>masm pushpop.asm Microsoft (R) Macro Assembler Version 5.00 Copyright (C) Microsoft Corp 1981-1985, 1987. All rights reserved. Object filename [pushpop.OBJ]: Source listing [NUL.LST]: Cross-reference [NUL.CRF]: 50402 + 450254 Bytes symbol space free 0 Warning Errors 0 Severe Errors C:\TASM>link pushpop.obj Microsoft (R) Overlay Linker Version 3.60 Copyright (C) Microsoft Corp 1983-1987. All rights reserved. Run File [PUSHPOP.EXE]: List File [NUL.MAP]: Libraries [.LIB]: LINK : warning L4021: no stack segment C:\TASM>debug pushpop.exe -g AX=1818 BX=0024 CX=0011 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=0B97 ES=0B87 SS=0B97 CS=0B98 IP=003B NV UP EI PL ZR NA PE NC 0B98:003B CC INT 3 -d 0B97:0000 0B97:0000 02 11 24 00 11 00 26 11-18 18 00 00 00 00 00 00 ..$...&......... 0B97:0010 B8 97 0B 8E D8 A1 00 00-8B 1E 02 00 8B 0E 04 00 ................ 0B97:0020 BA 02 00 EB 17 90 50 53-51 59 5B 58 A1 00 00 40 ......PSQY[X...@ 0B97:0030 A3 00 00 8B 1E 02 00 4B-89 1E 02 00 03 C3 A3 06 .......K........ 0B97:0040 00 4A 75 E2 E5 25 E7 30-A3 08 00 CC E5 5D C3 90 .Ju..%.0.....].. 0B97:0050 55 8B EC 81 EC 84 00 C4-5E 04 26 80 7F 0A 00 74 U.......^.&....t 0B97:0060 3E 8B 46 08 8B 56 0A 89-46 FC 89 56 FE C4 5E FC >.F..V..F..V..^. 0B97:0070 26 8A 47 0C 2A E4 40 50-8B C3 05 0C 00 52 50 E8 &.G.*[email protected]. -q