ALP to print the addition of N hexadecimal number (64-bit)
kw.asm
section.datatitledb10,"———————————————————————————————————————————"db10,"ALPtoprinttheadditionofNhexadecimalnumber"
db 10, "———————————————————————————————————————————"
db 10, "1.Enterthedata"
db 10, "2.Displaytheresult"
db 10, "3.Exit"
db 10, "———————————————————————————————————————————"
db 10, "Enteryourchoice"title_len equ$-titleinput1db10,"Howmanynumbersyouwanttoenter"input1_len equ$-input1input2db10,"Enterthe2digithexnumber"input2_len equ$-input2outputdb10,"Additionofarrayelementis"output_len equ$-outputwrongdb10,"Wrongchoiceentered...Pleasetryagain"wrong_len equ$-wrongsection.bssnumasciiresb03reslresb01reshresb01cntresb01optionbuffresb02dispbuffresb04%macro display 4
movrax,%1movrdi,%2movrsi,%3movrdx,%4syscall%endm
section.textglobal_start_start:menu:display1,1,title,title_lendisplay0,0,optionbuff,02cmpbyte[optionbuff],"1"jnecase2callprocedurejmp_startcase2:cmpbyte[optionbuff],"2"jnecase3display1,1,output,output_lendisplay1,1,dispbuff,4jmp_startcase3:cmpbyte[optionbuff],"3"jeexitdisplay1,1,wrong,wrong_lenjmp_startprocedure:display1,1,input1,input1_lendisplay0,0,numascii,03callpacknummov[cnt],blxorrcx,rcxmovcl,[cnt]addup:pushrcxdisplay1,1,input2,input2_lendisplay0,0,numascii,03callpacknumadd[resl],bladcbyte[resh],0poprcxloopaddupmovbl,[resl]movbh,[resh]calldisp16_procjmpexitpacknum:movbl,0movrcx,02movrsi,numasciiup1:rolbl,04moval,[rsi]cmpal,39hjbeskip1subal,07hskip1:subal,30haddbl,alincrsiloopup1retdisp16_proc:movrcx,04movrdi,dispbuffdup1:rolbx,04moval,blandal,0fhcmpal,09jbedskipaddal,07hdskip:addal,30hmov[rdi],alincrdiloopdup1jmp_startretexit:movrax,60movrdi,00syscall
Output
kodingwindow@kw:~$ nasm -felf64 kw.asm kodingwindow@kw:~$ ld kw.o && ./a.out
———————————————————————————————————————————
ALP to print the addition of N hexadecimal number
———————————————————————————————————————————
1.Enter the data
2.Display the result
3.Exit
———————————————————————————————————————————
Enter your choice 1
How many numbers you want to enter 02
Enter the 2 digit hex number AF
Enter the 2 digit hex number FF
———————————————————————————————————————————
ALP to print the addition of N hexadecimal number
———————————————————————————————————————————
1.Enter the data
2.Display the result
3.Exit
———————————————————————————————————————————
Enter your choice 2
Addition of array element is 01AE
———————————————————————————————————————————
ALP to print the addition of N hexadecimal number
———————————————————————————————————————————
1.Enter the data
2.Display the result
3.Exit
———————————————————————————————————————————
Enter your choice 3
kodingwindow@kw:~$
Comments and Reactions
Advertisement
Thank You
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.