Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Puffin Rock Characters Plush Toy Set
anil1961
Updated:
Saturday at 3:51 PM
Toyota Vitz scp10 For Sale
Lakmal Bandara
Updated:
Wednesday at 10:50 AM
Kandy
Welcome all my all new pet shop Bark.lk
dilumrane
Updated:
Nov 2, 2026
Windows RDP Only Rs.500 a month
Blogerwiki
Updated:
Nov 1, 2026
Ad icon
V2ray VPN for Tunneling
hu KANNA
Updated:
Oct 22, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
Helppppppppp
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="lek" data-source="post: 4233141" data-attributes="member: 133071"><p>Need to write a Assembly language program in nasm to solve the below problem...I wrote 1 but i cannot get the correct output.<img src="/styles/default/xenforo/smilies/default/no.gif" class="smilie" loading="lazy" alt=":no:" title="No :no:" data-shortname=":no:" />.If some one knows Assembly language pls help meeee.....<img src="/styles/default/xenforo/smilies/default/sad.gif" class="smilie" loading="lazy" alt=":(" title="Sad :(" data-shortname=":(" /></p><p></p><p><strong>Problem:</strong></p><p><strong>Write an assembly language program that allows entry of a decimal number via the keyboard. Note that the number should be accumulated as a bit word in register </strong><strong>eax. The program terminates when a space is entered.</strong></p><p></p><p><strong>solution:</strong></p><p></p><p>section .data</p><p>accum dd 0 ;This is a double word (32 bits)</p><p>msg db 'Please enter a Decimal number: '</p><p>len equ $ - msg ;length of string</p><p>buf dd 0x0d0a30 ;the input buffer</p><p></p><p>section .text ;program section</p><p> global _start ;must be declared for linker (ld)</p><p></p><p>_start: ;tell linker entry point</p><p> rawmode</p><p>my_loop: ;notice that loop is a reserve name</p><p> ; Write banner</p><p> mov edx,len ;message length</p><p> mov ecx,msg ;message to write</p><p> mov ebx,1 ;file descriptor (stdout)</p><p> mov eax,4 ;system call number (sys_write)</p><p> int 0x80 ;call kernel</p><p> </p><p> ; Read a digit</p><p> mov edx,len ;message length</p><p> mov ecx,buf ;message to read</p><p> mov ebx,0 ;file descriptor (stdin)</p><p> mov eax,3 ;system call number (sys_read)</p><p> int 0x80 ;call kernel</p><p></p><p> mov eax,[buf]</p><p> and ax,7fh ;Strip off the most significant bit</p><p> cmp ax,0x20 ;Compare with space</p><p> je exit ;Jump to exit if space</p><p> sub ax, '0' ; Subtract away the ASCII value for '0'</p><p> </p><p></p><p></p><p> mov edx,15 ;message length</p><p> mov [buf],ax ;message to write</p><p> mov ebx,1 ;file descriptor (stdout)</p><p> mov eax,4 ;system call number (sys_write)</p><p> int 0x80 ;call kernel</p><p> xor eax,eax</p><p> jmp my_loop ;jump to my_start if sum less twenty</p><p></p><p>exit:</p><p> normalmode</p><p> mov eax,1 ;system call number (sys_exit)</p><p> int 0x80 ;call kernel</p></blockquote><p></p>
[QUOTE="lek, post: 4233141, member: 133071"] Need to write a Assembly language program in nasm to solve the below problem...I wrote 1 but i cannot get the correct output.:no:.If some one knows Assembly language pls help meeee.....:( [B]Problem: Write an assembly language program that allows entry of a decimal number via the keyboard. Note that the number should be accumulated as a bit word in register [/B][B]eax. The program terminates when a space is entered.[/B] [B]solution:[/B] section .data accum dd 0 ;This is a double word (32 bits) msg db 'Please enter a Decimal number: ' len equ $ - msg ;length of string buf dd 0x0d0a30 ;the input buffer section .text ;program section global _start ;must be declared for linker (ld) _start: ;tell linker entry point rawmode my_loop: ;notice that loop is a reserve name ; Write banner mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel ; Read a digit mov edx,len ;message length mov ecx,buf ;message to read mov ebx,0 ;file descriptor (stdin) mov eax,3 ;system call number (sys_read) int 0x80 ;call kernel mov eax,[buf] and ax,7fh ;Strip off the most significant bit cmp ax,0x20 ;Compare with space je exit ;Jump to exit if space sub ax, '0' ; Subtract away the ASCII value for '0' mov edx,15 ;message length mov [buf],ax ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel xor eax,eax jmp my_loop ;jump to my_start if sum less twenty exit: normalmode mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom