#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2

    Constant too large


    INTEL x86 assembly language

    i have been experimenting on how to show multiple digits in assembly. My problem is, when i compile, it is showing me an error that the CONSTANT IS TOO LARGE. How can i resolve this problem?

    Code:
    .MODEL SMALL
    .STACK
    .DATA
    	display1 DB 'CONVERTED ASCII TO DIGITS: ','$'
    .CODE
     
    START:
    	MOV AX, @DATA
    	MOV DS, AX
     
    	MOV AH, 09H
    	LEA DX, display1
    	INT 21H          
     
    	MOV AX, 700000
    	CALL disp
     
    	MOV AH, 4CH
    	INT 21H
     
    	disp proc
    	MOV BX, 10
    	MOV DX, 000000000H
    	MOV CX, 000000000H
    
    
    looper1:	MOV DX, 000000000H
    	div BX
    	PUSH DX  
    	INC CX 
    	CMP AX, 0
    	JNE looper1
                                   
    looper2:	POP DX
    	ADD DX, 30H
    	MOV AH, 02H                            
    	INT 21H
    	LOOP looper2
    	RET
    	ENDP
     
    END START
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    You've got a few statements like this:
    Code:
    	MOV DX, 000000000H
    	MOV CX, 000000000H
    Note that CX and DX are 16 bit registers and 000000000H is a 36-bit constant value. Do you see what the issue is? Perhaps you should try using 0000H instead .
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2
    this has nothing to do with my problem, it works fine when value stored in AX is less than or equal 32,000
    Code:
    	MOV DX, 000000000H
    	MOV CX, 000000000H
    what i am trying to ask is, how am i gonna work with numbers larger than 32,000 if these registers can only hold no more than 32,000? EAX,EBX,ECX,EDX dont work, compiler is throwing me an error NOT RECOGNIZED INSTRUCTIONS!
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,392
    Rep Power
    1871
    Well you're going to have to decide which two 16-bit registers to use for the 32-bit value.

    You'll have to look up the pseudo ops yourself, but it'll be something like
    MOV AX, LO(700000)
    MOV BX, HI(700000)



    Of course, your called function will have to be modified to expect this as well.

    Comments on this post

    • Kuiva agrees
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2
    oh okay! thank you
    Last edited by Kuiva; September 17th, 2013 at 08:21 AM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2
    when 16 is entered, the value in MINUTES becomes 0, when year 17 is entered, value in months is incorrect. weird bug. please help me determine what is wrong with my code -_-

    Code:
    .model small
    .stack
    .data
    .386
    	ask db 10,10,"NUMBER OF YEARS: $",10,10
    	error0 db 10,9,9,9,00,00,00,00,"OUT OF RANGE!$"
    	input db 3, 4 dup (?)
    	
    	container db ?
    	container1 db ?
    	container2 db ?
    	
    	constten db 10
    	constmos db 12
    	constwks db 52
    	constdys dw 365
    	consthrs dd 8760
    	constmins dd 525600
    	
    	mos db 9,0,"MONTHS: $"
    	wks db 9,0,0,0,0,0,"WEEKS: $"
    	dys db 9,0,0,0,0,0,"DAYS: $"
    	hrs db 9,0,0,0,0,"HOURS: $"
    	mins db 9,0,0,0,0,"MINUTES: $"
    	
    .code
    
    start:
    	
    	MOV AX, @DATA
    	MOV DS, AX
    	
    	LEA DX, ask
    	MOV AH, 09h
    	INT 21h
    	
    	LEA DX, input
    	MOV AH, 0Ah
    	INT 21h
    	
    	MOV AH, 02h
    	MOV DL, 0Ah
    	INT 21h
    	INT 21h
    	
    	
    ;-----------------------------------------------------------------------------------------------;
    ;	CHECK INDEX					;
    ;-----------------------------------------------------------------------------------------------;
    	MOV SI, 02h
    
    	MOV AL, input[si+1]
    	CMP AL, 0Dh
    	JE convert1
    	
    	MOV AL, input[si+2]
    	CMP AL, 0Dh
    	JE convert10
    
    	convert1:
    	MOV AL, input[si+0]
    	SUB AL, 30h
    	mov container2, AL
    	JMP months
    	
    	convert10:
    	MOV AL, input[si+0]
    	SUB AL, 30h
    	MUL constten
    	MOV container, AL
    	
    	MOV AL, input[si+1]
    	SUB AL, 30h
    	MOV container1, AL
    	MOV AL, container
    	ADD AL, container1
    	MOV container2, AL
    	CMP container2, 31
    	JAE error1
    ;-----------------------------------------------------------------------------------------------;
    ;	MULTIPLY VALUES					;
    ;-----------------------------------------------------------------------------------------------;
    	months:
    	LEA DX, mos
    	MOV AH, 09h
    	INT 21h
    	MOV AL, container2
    	MUL constmos
    	call disp1
    	mov ah, 02h
    	mov dl, 0ah
    	int 21h
    	
    	weeks:
    	LEA DX, wks
    	MOV AH, 09h
    	INT 21h
    	MOV AL, container2
    	MUL constwks
    	call disp1
    	mov ah, 02h
    	mov dl, 0ah
    	int 21h
    	
    	days:
    	LEA DX, dys
    	MOV AH, 09h
    	INT 21h
    	MOV AL, container2
    	CBW
    	MUL constdys
    	call disp1
    	mov ah, 02h
    	mov dl, 0ah
    	int 21h
    	
    	hours:
    	LEA DX, hrs
    	MOV AH, 09h
    	INT 21h
    	MOV AL, container2
    	CBW
    	MUL consthrs
    	call disp1
    	mov ah, 02h
    	mov dl, 0ah
    	int 21h
    	
    	minutes:
    	LEA DX, mins
    	MOV AH, 09h
    	INT 21h
    	MOV AL, container2
    	CBW
    	MUL constmins
    	call disp1
    	mov ah, 02h
    	mov dl, 0ah
    	int 21h
    	call terminator
    	
    ;-----------------------------------------------------------------------------------------------;
    ;	CONVERT AND DISPLAY				;
    ;-----------------------------------------------------------------------------------------------;
    	disp1:
    	MOV EBX, 10
    	MOV EDX, 000000000000h
    	MOV ECX, 000000000000h
    
    
    superman:	MOV EDX, 000000000000h
    	DIV EBX
    	PUSH EDX  
    	INC ECX
    	CMP AL, 0
    	JNE superman
                                   
    batman:	POP EDX
    	ADD EDX, 30H
    	MOV AH, 02H                            
    	INT 21H
    	LOOP batman
    	RET
    ;-----------------------------------------------------------------------------------------------;
    ;	STRING DISPLAYS					;
    ;-----------------------------------------------------------------------------------------------;
    	error1:
    	LEA DX, error0
    	MOV AH, 09h
    	INT 21h
    	call terminator
    	
    	terminator:
    	MOV AH, 4CH
    	INT 21h
    end start
    Last edited by Kuiva; September 18th, 2013 at 11:17 AM. Reason: i have found answer to my previous question and got new one

IMN logo majestic logo threadwatch logo seochat tools logo