Sorry for taking so long to get back... anyway, I was having trouble following the code, and didn't have a copy of TASM on hand in any case, so I re-wrote the code to work in NASM instead, replacing most of the magic numbers with EQUates, along the way (and fixing some of the comments - the interrupt calls were to DOS, not the BIOS):
[org 0x0100]
dos equ 0x021 ; interrupt for DOS function selector
getchar equ 0x02 ; DOS routine code "read character"
putchar equ 0x02 ; DOS routine code "print character"
puts equ 0x09 ; DOS routine code "print string"
quit equ 0x4c ; DOS routine code "return to DOS"
CR equ 0x0A ; ASCII carriage return
LF equ 0x0D ; ASCII line feed
off_zed equ 0x30 ; ASCII zero
[section code]
;print name and ID
mov dx, nameoutput ;sets the offset to the nameoutput string
mov ah, puts ;code to print a dollar terminated string
int dos ;prints the string at DS::DX
;print opening prompt
mov dx, welcome ;set the offset to the 'welcome' string
mov ah, puts ;DOS code for print a dollar terminated string
int dos ;invoke DOS -- prints the string at DS::DX, always
;begin algorithm by reading in integers
;print the prompt first, using DOS code '9d'
mov dx, prompt2
mov ah, puts
int dos
mov al, 0
mul cx
mul bx
enter_loop1:
;now get the keystroke
mov ah, getchar ;DOS code for read a keystroke
int dos ;invoke DOS, ASCII code will be in register 'al' after this command
cmp al, LF
jz next_integer
;save the keystroke in register 'cl'
;after we get the integer value from the ASCII code
;by subtracting hex 30 from the ASCII code value
sub al, off_zed
add cl, al
jmp enter_loop1
next_integer:
;now read the second integer as above
;first print the prompt using DOS code '1d'
mov dx, prompt3 ;set the offset for DS::DX
mov ah, puts ;set dos code
int dos ;invoke dos
enter_loop2:
mov ah, getchar ;dos code for read a keystroke
int dos ;invoke dos, ASCII code will be in register 'al' after this command
cmp al, LF
jz repeat
sub ah, off_zed
add bl, al
jmp enter_loop2
; we now have two integers, actual values not ASCII codes, one in 'cl' and the other in 'al'
repeat:
cmp cl, bl ;compare the two integers
jz print_and_exit ;print the result and return control to operating system
;if here, the two numbers were **NOT** the same
;note that the flags are still set from the compare statement, but it's probably wise to do another
;one in case we change or edit the file.
cmp cl, bl
jg greater ;test to see if cl > bl, and if it is, jump to label 'greater'
;OK, so if we get to here, cl **must** be less than (<) bl
sub bl, cl ;diminish 'bl' by 'cl'
jmp repeat ;go round the loop until the variables become equal
greater:
;if we get here, it was shown that cl > bl, so diminish 'cl'
sub cl, bl
jmp repeat ;go round the loop until the variables become equal
print_and_exit:
;there's only one way to get here and that's when the integers are equal
;so print and then we're done.
;first the prompt
mov dx, prompt4
mov ah, puts ;dos code for print a string
int dos
;last, the actual result
mov ah, putchar ;dos code for print to screen
;character's ASCII code must be in 'dl' for this to work
mov dl, cl ;starting to print 'cl's value
add dl, off_zed ;convert value to ASCII code
int dos
mov dx, goodbye
mov ah, puts
int dos
mov ah, quit ;dos code for exit/quit
int dos
[section data]
welcome db "Running Euclids algorithm to find the HCF", CR, LF
db "of two small positive integers.", CR, LF, "$"
nameoutput db "Rose, Matthew 0471844", CR, LF, "$"
prompt2 db CR, LF, "Please type the first integer $"
prompt3 db CR, LF, "Please type the second integer $"
prompt4 db CR, LF, "The HCF is $"
goodbye db CR, LF, "quitting now$"
One thing I noticed is that the code for both reading and printing the numbers is wrong - if you are reading more than one digit, you aren't adjusting the digits for place value, with the practical upshot that you are adding the digits together rather than reading them as a single number. For example, if you entered '1234', the number that would actually get stored in CL is 1 + 2 + 3 + 4 = 10. Similarly, you are printing the number as a single ASCII character value, not as a number.
Niether of these problems is necessarily the cause of the freezing, though. I will see if I can take a closer look at the code RSN. In the meanwhile, you might want to look at the Interrrupt List (http://www.ctyme.com/rbrown.htm) to better understand the behavior of the DOS functions in question (especially INT 0x21, ah=0x01 (http://www.ctyme.com/intr/rb-2552.htm), INT 0x21, ah=0x02 (http://www.ctyme.com/intr/rb-2554.htm), and INT 0x21, ah=0x09 (http://www.ctyme.com/intr/rb-2562.htm)) ; some of the have side effects that can change the values in the BX and AX registers. You might want to look into INT 0x21, ah=0x0A (http://www.ctyme.com/intr/rb-2563.htm) as well, for a way of getting buffered input rather than reading each character directly.