|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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
|
|
#2
|
||||
|
||||
|
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 Short • Understanding the C/C++ Preprocessor Taming Python • A 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 |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
Quote:
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Assembly Program Question? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|