Advertisement

05.08.2008 at 12:33PM PDT, ID: 23387367 | Points: 20
[x]
Attachment Details

What is the error in this assembler sourse code?

Hi expert,
I try to write sorting ascending order for six numbers that the user inter them,
I start with 2 numbers but the program doesnt work.Can you tell me whats the error in this assemblly code.
My program in attachement
Attachments:
 
sort assembly code
 
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: albusaidi
Question Asked On: 05.08.2008
Participating Experts: 2
Points: 20
Views: 0
Translate:
Loading Advertisement...
05.08.2008 at 12:51PM PDT, ID: 21527884

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.09.2008 at 10:41PM PDT, ID: 21537971

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 01:24AM PDT, ID: 21538224

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.11.2008 at 02:38PM PDT, ID: 21543583

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.12.2008 at 12:35AM PDT, ID: 21545146

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.01.2008 at 01:17PM PDT, ID: 21911213

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.01.2008 at 02:08PM PDT, ID: 21911651

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.08.2008 at 12:51PM PDT, ID: 21527884

Rank: Master

I had a (very) quick look over the code, and I noticed that you never place the second value you read into the array.

You place the first value into nums[0]. Shouldn't you place the second value into nums[1] ?


Btw, what is the input you give and the output you get ? Which algorithm are you trying to implement ?
 
05.09.2008 at 10:41PM PDT, ID: 21537971
This is exactly my question sir.
The input from the user should stop when 999 is entered. An example of I/O should look as follows:

Enter positive decimal values or 999 to stop.
Value 1: 38
Value 2: 12
Value 3: 90
Value 4: 8
Value 5: 26
Value 6: 999

Sorted values are:
8
12
26
38
90

 
05.10.2008 at 01:24AM PDT, ID: 21538224

Rank: Master

>> An example of I/O should look as follows:

Yes, but what is the ACTUAL I/O you get ?


Which sort algorithm are you trying to implement ?


Did you fix the problem I pointed out ?
 
05.11.2008 at 02:38PM PDT, ID: 21543583
Yes sir,
I try and I changed my code again but also I have errors.
My code in attachement
 
sorted code
 
 
05.12.2008 at 12:35AM PDT, ID: 21545146

Rank: Master

Can you answer the questions I asked ? I'm not good at reading minds, and guessing intentions ... ;)
 
07.01.2008 at 01:17PM PDT, ID: 21911213
It could be the that cx is changed in the int and calls.

changed code:

data segment
num1  Dw  ?
num2  Dw  ?

msg0  DB  'Enter positive decimal values or 999 to stop.$'
msg1  DB  'Value $'
msg2  DB  'Value 2:$'
msg3  DB  'Value 3:$'
msg4  DB  'Value 4:$'
msg5  DB  'Value 5:$'
msg6  DB  'Value 6:$'
msg7  DB  'Sorted values are:$'
msg8  DB  'End of program$'
data ends

working_storage  segment    stack
                 dw         100h    dup(?)
             working_storage  ends
             


code           segment
               assume cs:code,ds:data,ss:working_storage
               extrn putdec:proc,putcrlf:proc,getdec:proc,getchar:proc,putchar:proc


 
start: mov ax,data
       mov ds,ax
     
      mov si,0
      mov cx,6

            push cx                              ;save the cx value that could be destroyed by the(1)
                                                      ;int or call routines, In 16 bit dos only si,di,bx are
      mov bx,1                              ;"usually" preserved in calls and interrupt routines.
      mov Dx,offset msg0              
      mov ah,9h
      int 21h
      call putcrlf


repeat:mov Dx,offset msg1              
      mov ah,9h
      int 21h
      mov ax,bx
      call putdec
     
      call getdec  
      cmp  ax,999                    
      jae  finish                        ;watch out, cx is still on the stack
      add  nums[si],ax
      mov ax,nums[si]

            pop cx                              ;get the cx value back for the compare(2)

      inc si
      inc bx
      dec cx
      jnz repeat

      mov Dx,offset msg7              
      mov ah,9h
      int 21h
      call putcrlf
      mov cx,6

            push cx                              ;same as above(1)

check:mov bx,nums[si]
      mov dx,nums[si+1]
      cmp dx,bx
      ja next
      mov nums[si],dx
      mov nums[si+1],bx
      ;mov  num1,bx
      mov  ax,nums[si]
      call putdec
      call putcrlf
      mov  ax,nums[si+1]
      call putdec
      call putcrlf


next:
       mov ax,bx
       call putdec
       mov ax,dx
       call putdec

             pop cx                              ;see above(2)

       inc si
       dec cx
     jmp check

     
finish:mov Dx,offset msg8  

            pop cx                              ;to realign the stack. This is not really necessary
                                           ;because the ax,4c00h int 21h cleans up the stack

;            add sp,2                              ;this can also be used            

      mov ah,9h
      int 21h
      call putcrlf
       
      mov ax,4c00h
      int 21h      
code ends
end start
 
07.01.2008 at 02:08PM PDT, ID: 21911651

Rank: Master

What is the problem you are experiencing ?

Which sort algorithm are you trying to implement ?
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628