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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 27th, 2006, 11:31 PM
bunker17 bunker17 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 123 bunker17 User rank is Sergeant (500 - 2000 Reputation Level)bunker17 User rank is Sergeant (500 - 2000 Reputation Level)bunker17 User rank is Sergeant (500 - 2000 Reputation Level)bunker17 User rank is Sergeant (500 - 2000 Reputation Level)bunker17 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 2 h 47 m 2 sec
Reputation Power: 11
8086 32 bit integer input

yeah im working on a project for school and i need the integer input to work on 32 to bit and its working only up to 16 bits haven't been able to figure whats its the bug so im gonna post my proc in hope someone can find it. Basically i need Dx to have the first 16 bits and ax the last 16.
Code:
;A procedure that sums BX-AX and DX-CX
	;the result is returned in BX-AX
	longadd proc
		add ax,cx
		adc bx,dx
		ret
	longadd endp



;reads a number and place on dx:ax
	readn proc near
	push cx
	push bx  ; saving the other registers
	push bp
	mov bp , 0
	mov cx , 10    ; make cx 10 
	mov bx , 0     ;set to 0
	mov dx , 0     ; set to 0
	readn1:               
		mov ah , 1             ;make ah 1 in order to call interrup of one char with echo
		int 21h		       ;activate the interrupt
		cmp al , 13d
		je readn2
		cmp al , '0'           ;if its < 0 ends the loop
		jb set0
		cmp al , '9'
		ja set0			; if its >9 ends the loop
		sub al , '0' 		; turn the char into decimal
		push ax			;saves ax
		mov ax ,dx		;places the value from dx into ax for mult
		mul cx			; mult by 10
		mov dx ,ax		;restore dx mult by 10		
		mov ax ,bx		;makes ax bx for mult
		mul cx			;mult by 10
		mov bx ,ax		;restore bx mult by 10
		pop ax			; restore ax to value before mult
		mov ah , 0		;makes ah 0
		push ax			;saves variables
		push cx			;set stuff for long adding
		mov cx , ax
		mov ax , bx
		mov bx , dx
		mov dx , 0
		call longadd		; long add happens
		mov dx ,bx
		mov bx , ax
		pop cx
		pop ax
		jmp readn1 ; goes back to start of the loop
	set0:
		mov bp , 1	; uses bp to hold a flag for when ilegal input occurs
		jmp readn1
	set02:
		xor dx ,dx	;makes them 0 due to ilegal input
		xor ax ,ax
		mov bp , 0
	readn2:			;checks if it there was an error and gives output
		mov ax,bx
		cmp bp ,1
		je set02
	tend1:			;returns variables
		pop bp
		pop bx
		pop cx
		ret		;ends proc
 	readn endp

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > 8086 32 bit integer input


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 1 hosted by Hostway