Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 14th, 2007, 02:51 AM
lilnaniam lilnaniam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Location: North Dakota
Posts: 2 lilnaniam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 16 sec
Reputation Power: 0
Assembly Program Question?

Hello All.
I am very new to Assembly Language. I am being taught from 'Assembly Language, Programming for the IBM PC Family, 3rd Edition.' This book had many horrible reviews on Amazon. If anyone knows of a better book to use with this one to get me through my class please let me know..

Now my other question..
This is only our second assignment. I managed to get it working thus far. We are to create a program that calculates the number of hours and minutes when given only the minutes.

I got it to the point of using 200 minutes. And making the result display ...

200 Minutes
Equals.

But am unsure on how to proceed.
I usedd hex, converted that to a decimal value of 200. I tried using somewhat the same sequence usedd to get decimal but changedd the divisor to 60 instead of 10 to try to get the hours, and to save the remainder but it did not work. Can anyone lead me into the right direction
Here's my code:

Code:
.MODEL SMALL
        .586                  ;Allows Pentium instructions, must come after .MODEL
        
        .STACK 100h
        
        .DATA
zero    DW    0
time    DW    0C8h            ;Hexadecimal value equal to 200 in Decimal
word1   DB    ' Minutes.', 13, 10, '$'
word2   DB    ' hours ', 13, 10, '$'
word3   DB    ' minutes.', 13, 10, '$'
word4   DB    'Equals.', 13, 10, '$'      
        .CODE
main PROC
        mov   ax, @data       ;Initialize
        mov   ds, ax          ; segment registers
        
        mov   ax, zero        ;Clear the Register
       
        mov   ax, time        ;Assign the hex C8 into register
        call  decimal         ;Convert hex C8 into decimal 200. Display decimal.
        
        mov   dx, OFFSET word1  ;Display the word 'Minutes' after the decimal value       
        mov   ah, 9             ; using function 09h
        int   21h             ; of interrupt 21h
        
        mov   dx, OFFSET word4  ;Display the word 'Equals'      
        mov   ah, 9             ; using function 09h
        int   21h             ; of interrupt 21h
        mov   ax, time
        call  decimal
                
        mov   ax, 4C00h       ;end
        int   21h             ;  processing
   
decimal proc
        mov    bx, 10d        ;Division Factor
        mov    cx, 00d        ;Number of decimal digits encountered, so far

NonZero:
        mov    dx, 00d        ;The dx register will hold the division's remainder
        div    bx             ;Divide contents of ax by 10d (ax<-quotient, dx<-remainder)
        push   dx             ;Push the remainder onto the stack
        inc    cx             ;Encountered another decimal digit
        cmp    ax, 00d        ;Is the quotient zero?
        jne    NonZero        ;  No - Keep dividing ax by 10 until quotient is zero

DigitLoop:
        pop    dx             ;  Yes - Retrieve last digit from the stack
        add    dl, 30h        ;ASCII character to display
        mov    ah, 02h        ;Display ASCII character
        int    21h            ;  on screen
        loop   DigitLoop      ;Repeat until stack of pushed remainders is empty
        ret
decimal endp

main    ENDP

        END    main           ;Identifies where execution is to start

Reply With Quote
  #2  
Old September 14th, 2007, 05:36 PM
Schol-R-LEA's Avatar
Schol-R-LEA Schol-R-LEA is offline
Commie Mutant Traitor
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Location: The People's Republic of Berkeley
Posts: 1,082 Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Schol-R-LEA User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 10 h 16 m 50 sec
Reputation Power: 446
The Assembly Language entry in the Languages Resources List gives links to the home pages for a number of books; I personally recommend Assembly Language Step By Step, though [i]The Art Of Assembly Language is highly popular. I will warn you, however, that they both use a different assembler from MASM (in the former, Netwide Assembler, and in the latter HLA), which have somewhat different syntaces even though they are for the same processor.
__________________
Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
#define KINSEY (rand() % 7) λ Scheme is the Red Pill
Scheme in ShortUnderstanding the C/C++ Preprocessor
Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

Reply With Quote
  #3  
Old September 14th, 2007, 07:37 PM
Lux Perpetua Lux Perpetua is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,418 Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 47 m 27 sec
Reputation Power: 334
I think you just need to work through the process more carefully. Converting minutes to hours:minutes is not identical to finding the decimal digits of a number. Actually, it's much easier. When you divide the minutes by 60, the quotient is the hours and the remainder is the minutes. That's it.
Comments on this post
lilnaniam agrees: Thanks

Reply With Quote
  #4  
Old September 15th, 2007, 12:44 AM
lilnaniam lilnaniam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Location: North Dakota
Posts: 2 lilnaniam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 16 sec
Reputation Power: 0
I got it to work. It just took rethinking as you said. Think I was overtired and the thought process was just not there. Walking away and coming back to it later helped alot.
Thank you. Once I did it it seemed simple.

Reply With Quote
  #5  
Old September 16th, 2007, 09:13 AM
Lux Perpetua Lux Perpetua is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,418 Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 47 m 27 sec
Reputation Power: 334
Quote:
Originally Posted by lilnaniam
I got it to work. It just took rethinking as you said. Think I was overtired and the thought process was just not there. Walking away and coming back to it later helped alot.
Thank you. Once I did it it seemed simple.
I think this strategy, "walking away and coming back later," is underrated. (Unfortunately, one doesn't always have the luxury...) I'm glad you got it working.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Assembly Program Question?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway