Lxperiment No-G
Tille.
wWaike an Xs&lsh ALp to accepl five G4 bit
Hexadecimal numbens fhom. USeg and stone them
41Tay nd diaplay 4he accepBed numbezs
To be fomiliestith the fonmat of asae mbly lonquaqe
anogram shuctuse and insBqucdian.
alo study the fonmad s assembly lanqua4e pacunum
alaag ith ditenent assembleg inecdivea and
Alleseat funclions af the NAGM
3Io leaan the paaceduae how do stoae a hexadecima
numben in memany
Prablem delinaion. -
lNite an X8G I64 ALP to accept îive
G4 bid X Hexacdecimal numbess fom Gtoe
Ahem
1
n. gnnay and display the acce pBed numbexc
lonking Enujxonment -
Sofkuseae Requiaements -
Cpu:Intel 6 p10cessox
2)os Windows XP (l6 bit execution) fedona 13 (32 4 64 bit
Lxe cution)
2Lditoggedi! GNU Lditox
4AsGembleg: NASm LNetoide Assemblen).
Page No.
Date
and H/w Requiae ments
SoflwaTe gequine ments.
CPU Intel 5 proces SoY
2)0S Windows Xp 1s bit
B4 bil execution) Executian)Fedona 1g (321
3diias qedit GanL Lditon
4Assemblea: NASM { Neluoide Assembleg)
Input five Hexa
Dulpul
*|1heoy
Assemaly languaqe gaoyaam is memonic aepnesenta lian
of machine code Thaee asse mbleg cuailable io
dsse mbling the piogiam fog 181
1 Micao Asse.mbleg MASM
Bosland Iugbo Asaembleg TAGn)
3Neluside Assemblen CAASH)
LAasemaly Baaic aynluz thtee.
An dscembly paoqam cun be deuided into
Sections
The cdata sectian
The bas sedion.
3.The text setion
he data section
The daBa secian is used kor decloning initialized.
deda og conslaunts This data does not change at
gundime you con declane vanicus constant lalues
file name o bulfeg size, eBc in this artica
The synBa foy decaning dada sedicn is
Geclion.deda
The bas Geclion
used toa decluaia uninilili2ed datu
The hss seckion is declanin bas seisn is
Naaiables The ayniux fos
secion. has
The tex Gecian the ucual
fog
used fog
The Jex seclian is must wntiny
witing lazudiar
beqin with the der
Lcode Ihic
This section whelhez the
Lalobe sBaat, hich tells keanel
paagtam executian beqins
declazing lext secticn is
The oynlax for
Gethan text
alablad Gtazt
Assembly lanquaye sludements. types
pnoqnum consist cf hree
AsGembly lanquage
of stalements G1 inchucdicns
beculable instauction
2-Asse mbleg diccve, pseuda ops
Page No.
Date
he exeuion inshuçliong
noces Gon what o do simply inslauclion hell the
penaion code eachinshuion
(opcode.
qene1ades one machine Lach executable
consist of
he asse mble dinecives lnquuqeinshudian. incucion
abaut the Nanious aspecs oofpseudo -sps tell the assemblk
Thesedie on-excuable and dothe gsaembly pno ce ss
not qenerdie mach
language inaBaucdisn.
inu System (alls (ga bi)
Put he syslem call numbeg in the EAx geqisle
Slone he daquments lo 4he sysle m call in the eqiste
LX, ECX etc
"Call 4he gelevent inteupl (soh).
" lhe geGult is uGually gelunned the tAX neqister
nsiaucdians needed
EQU - Assiyn single absoulute values to symbola
Moy tapie s bye wond faom specified sau ta
specified deslinahion.
CALL- 1he call instauction causes the procedure nmed in the
bperdnd to be executed
INZ - jump if not equal to zeno
INC - Jumpc if no cany is qenenated
Alonihne
1. staat
dete setion.
1Declane 4 initilize he voniables inbas
uainitilized Vag iubles in Gectian
Declae opeiatian
4Nedae mac0s fon paint and exit
SInitilize poinBen wiih Sounce
accepBednumbeIG
the display and them stoge qnd uGeT
numbens Hexadecimal bit n accepBed
Gy have we Hene
ConcluGlan
1GlopsBop
pacedune. Ahe Declane .
he
proces 1Texminate
] oudput la. base 9Dexiding
by
to- points 1si achanucBer
nd a display
of ax
[n] compleBesummed
n tovalue aba
elements. of
numbe he out
(oun Inililize
Date
No. Puge
Syscall
len2
Rsi,msg2 Rdx, IIOV
Inov
Rdi,1 Inoy
Rax,1 In0V
display
loopi JNZ
(counter] byte dec
COunter move ;tO 17
rbx, add
Syscall
rdz,
17 Inov
rbx rsi, add
array
oi
start pointer
to Ove i array rsi, AOV
keyboard for ;0 mOV
di, 0
read for ;0 rax,0 nov
loopl:
[cournter],05 rbx,
00
byte rOT OT
iaccept
syscall
lenl Rdz, mOV
Rsi,msgl mOv
Rdi, 1 mOV
Rax,1 mov
idisplay
Start:
start global
.text section
resb
1 cOunter
200 resd arrav
.bss section
nunbers" bit "Entered $-msg2 equ len2
64 5 10,
$-mSgl 13, domSa2
numbers" bit 13,"Enter
64 5 equ leni
10, b msgl
numheS acceptei .data sectiOn
display
te and array
HexaieciI2 an 1ntnem store
64
five accept Om
rters
ir
ASSIsiGMENT- 6 to AL? X36/64 and userWIite
an
are:-9 numbers bit 64fiveEntered
854 036 372 223
036 372 223 Input:
-9
854
numbers bit 64five Enter
Output:
nunbers bit 64Enter5
Output:
Syscall
rdi, 0 mov
,60 rax mov
cal1 System ;exit
loop2 JNZ
[counter] byte dec
rbx,
17 add
Syscall
enter for +1 bit ;16 rdx,
17 mov
rbX rsi, add
array rsi, mov
monitor for ;1 rdi,
1 mov
write for ;1 rax, I mov
loop2:
00
bx, mov
[counter],
05 byte mov
display ;