Thursday, February 10, 2011

Lookup Table


%OUT--------------------------------------------------------------------------
%OUT- Using a look up table, accept a number and print its power of 2
%out- input: Number (<16) to be accepted from the user
%out- output: Print the square of the number
%out – author: Ayon and Ariyam
%OUT-----------------------------------------------------------------------

if1
include macrolib.lby
endif

.model small
.stack
.data
ip db "Enter a number: ","$" ;a request to prompt the user for entering the number
op db " Square of the number = ","$" ;output message
heading db "***** LOOK UP TABLE *****","$" ;a heading
xltbl db 00d,01d,04d,09d,16d,25d,36d,49d,64d,81d,100d,121d,144d,169d,196d,225d

.code

main proc

clrscrn ;clearing the screen
mov dx,0105h
cursor ;setting up the cursor
showmsg heading ;displaying heading

mov dx,0303h ;pointing to next line
cursor ;setting up the cursor
showmsg ip ;print the input message to prompt the user
input ;input is accepted in AL
lea bx,xltbl ;loading address of table
xlat ;output is in AL

mov bh,al ;copying result to BH
showmsg op
output ;displaying the result
exit

main endp
end main

No comments:

Post a Comment

Do you think this information useful or was not up to the mark? Comment if you have any advices or suggestions about the post.