4.2.1 Programming for Stack Program 4.1 WAP to calculate squares of BCD numbers 0 to 9 and store them from 2000h offset onwards in the current data segment. The numbers and their squares are in the BCD format. Write a subroutine for the calculation of the square of a number. ASSUME CS:CODE,DS:DATA,SS:STACK DATA SEGMENT ORG 2000H SQUARES DB 0FH DUP (?) DATA ENDS STACK SEGMENT STACKDATA DB 100H DUP (?) ;Reserve 256 bytes for stack STACK ENDS CODE SEGMENT START: MOV AX,DATA ;Initialize data segment MOV DS,AX MOV AX,STACK ;Initialize stack segment MOV SS,AX MOV SP,OFFSET STACKDATA ; Initialize stack pointer MOV CL,0AH ; Initialize counter for numbers MOV SI,OFFSET SQUARES; Pointer for array of squares MOV AL,00H ; Start from zero NEXTNUM: CALL SQUARE...
Comments
Post a Comment