5 Replies - 678 Views - Last Post: 20 March 2012 - 08:47 PM

#1 Fredex  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 86
  • Joined: 16-January 12

getting previous value.

Posted 14 March 2012 - 02:36 AM

WHAT is the code to get the previous value of an operation? I want to use it to increment and decrement this value?
Is This A Good Question/Topic? 0
  • +

Replies To: getting previous value.

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 876
  • View blog
  • Posts: 2,312
  • Joined: 28-March 11

Re: getting previous value.

Posted 14 March 2012 - 02:39 PM

You would create a global variable in the data section or uninitialized data section and increment/decrement it in your proc.

This post has been edited by GunnerInc: 14 March 2012 - 02:40 PM

Was This Post Helpful? 0
  • +
  • -

#3 Fredex  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 86
  • Joined: 16-January 12

Re: getting previous value.

Posted 14 March 2012 - 08:26 PM

is this value goto ax register?
Was This Post Helpful? 0
  • +
  • -

#4 Fredex  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 86
  • Joined: 16-January 12

Re: getting previous value.

Posted 15 March 2012 - 06:08 AM

Why I can't get the value of input to this code..

this is my code in upper part:
   FIR_INDEX0:
  	MOV AH, 02H
  	MOV BH, 00H
  	MOV DH, 05H
  	MOV DL, 0DH
  	INT 10H

	MOV AH, 7
	INT 21H
	
	CMP AL, 13
	JNE FIR_SKIP
	

  	;JMP SEC_INDEX0

	  FIR_SKIP:
  	CMP AL, 30H
  	JB FIR_INDEX0

  	CMP AL, 39H
  	JA FIR_INDEX0
	
INCR:
  	MOV FIR, AL
	SUB FIR, 30H
	
	mov BL,AL



and in lower part I'll try to get the value of input in this code but not successful.
back:	

	mov ah,9 
	lea dx,PMT
	INT 21H
	
	MOV AH,7
	INT 21H
	
	cmp al,'i'
 	je increment

	cmp al,'d'
	je decrement
	
	cmp al,27
	je exit
	
increment:	
	ADD BL,1
	
	MOV AX, 3
	INT 10H
	
	;BLACK_TEXT
	MOV AX, 0607H 
	MOV BX, 0000H
	MOV CX, 0541H
	MOV DX, 000DH
	INT 10H

    ;MATRIX_DISPLAY
  	MOV AH, 02H
  	MOV BH, 00H
  	MOV DH, 05H
  	MOV DL, 0DH
  	INT 10H

	MOV AH, 9
	LEA DX, DIS
	INT 21H
	
	JMP INCR
	

decrement:
	SUB BL,1
	
	MOV AX, 3
	INT 10H

   ;BLACK_TEXT
	MOV AX, 0607H 
	MOV BX, 0000H
	MOV CX, 0541H
	MOV DX, 000DH
	INT 10H

    ;MATRIX_DISPLAY
  	MOV AH, 02H
  	MOV BH, 00H
  	MOV DH, 05H
  	MOV DL, 0DH
  	INT 10H

	MOV AH, 9
	LEA DX, DIS
	INT 21H	
	
	JMP INCR

	loop back




what's wrong with this?
Was This Post Helpful? 0
  • +
  • -

#5 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 876
  • View blog
  • Posts: 2,312
  • Joined: 28-March 11

Re: getting previous value.

Posted 15 March 2012 - 04:20 PM

Well, bl is the low byte of the 16 bit bx register which is the low word of ebx.

EBX is the 32 bit register
BX is the low word of EBX (16 bit)
BH is the high byte of BX
and BL is the low byte of BX

So if you put a value in BL then move something into BH and BX as you do for your int 10, then you just overwrote that value.

You could push BL before an int 10 call then pop it afterwards, but do as I said, create a variable and save it to there.

Yes, you do have an EBX register and can use 32 bit registers in DOS 16 bit code!!!

.data?
SomeVar     db ?
...
...
...
    mov     SomeVar, al
...
...
...
increment:  
    inc     SomeVar
...
...
...
decrement:
    dec     SomeVar

This post has been edited by GunnerInc: 15 March 2012 - 04:20 PM

Was This Post Helpful? 2
  • +
  • -

#6 Fredex  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 86
  • Joined: 16-January 12

Re: getting previous value.

Posted 20 March 2012 - 08:47 PM

Thank you Mr. Gunner, I've learn more on your explanations..I already got my project but only 1 digit. :bigsmile:
This is my code:
TITLE final project
.MODEL large
.STACK 50H

.DATA?
	promp db "Enter a number only$"
	FIR DB (?),'$'

	TTL DB " 		IT-225 COMPUTER ORGANIZATION WITH ASSEMBLY LANGUAGE", 10, 13
  	    DB "                		FINAL PROJECT   $"   	
 
	DIS DB 30 DUP (2), 10, 13
	    DB 13 DUP(32), 30 DUP (2), 10, 13
	    DB 13 DUP(32), 30 DUP (2), 10, 13
	    DB 13 DUP(32), 30 DUP (2), 10, 13
	    DB 13 DUP(32), 30 DUP (2), 10, 13
	    DB 13 DUP(32), 30 DUP (2), 10, 13
	    DB 13 DUP(32), 30 DUP (2), 10, 13
		DB 80 DUP(32), '$'
	PMT DB "please select i/d/ESC:$"
	EXCLUDED DB "You have been reach the limit..$"
	
	MSG DB "				BY BSIT 2/BLK.1", 10, 13
	    DB "			TO ENGR.RICHARD D. GARCIA,M.I.T    $"
	
.CODE
	MOV AX, @DATA
 	MOV DS, AX

  START:

    ;CLEAR_SCREEN
	MOV AX, 3
	INT 10H

    ;TITLE_MESSAGE
	MOV AH, 9
	LEA DX, TTL
	INT 21H

    ;CREDIT_MESSAGE
  	MOV AH, 02H
  	MOV BH, 00H
  	MOV DH, 16H
  	MOV DL, 00H
  	INT 10H

	MOV AH, 9
	LEA DX, MSG
	INT 21H

    ;BLACK_TEXT
	MOV AX, 0607H 
	MOV BX, 0000H
	MOV CX, 0541H
	MOV DX, 000DH
	INT 10H

    ;MATRIX_DISPLAY
  	MOV AH, 02H
  	MOV BH, 00H
  	MOV DH, 05H
  	MOV DL, 0DH
  	INT 10H

	MOV AH, 9
	LEA DX, DIS
	INT 21H
	
	mov ah,9
	lea dx,promp
	int 21h


    FIR_INDEX0:
  	MOV AH, 02H
  	MOV BH, 00H
  	MOV DH, 05H
  	MOV DL, 0DH
  	INT 10H

	MOV AH, 7
	INT 21H
	

	  FIR_SKIP:
  	CMP AL, 30H
  	JB FIR_INDEX0

  	CMP AL, 39H
  	JA FIR_INDEX0
	
  	MOV FIR, AL
	SUB FIR, 30H
	
	mov BL,AL
	
INCR: 

    SEG_1_1:
 	CMP FIR, 1  
 	JE SEG_1_2

 	CMP FIR, 4
 	JE SEG_1_2
 
	MOV AX, 0601H ;top
	MOV BX, 0C00H
	MOV CX, 0511H
	MOV DX, 000DH
	INT 10H


    SEG_1_2:
 	CMP FIR, 1
 	JE SEG_1_3

 	CMP FIR, 7
 	JE SEG_1_3
 
	MOV AX, 0601H 
	MOV BX, 0C00H
	MOV CX, 0811H;mid
	MOV DX, 000DH
	INT 10H


    SEG_1_3:
 	CMP FIR, 1
 	JE SEG_1_4

 	CMP FIR, 4
 	JE SEG_1_4

 	CMP FIR, 7
 	JE SEG_1_4

	MOV AX, 0601H 
	MOV BX, 0C00H;bottom
	MOV CX, 0B11H
	MOV DX, 000DH
	INT 10H
 

    SEG_1_4:
 	CMP FIR, 1
 	JE SEG_1_5

 	CMP FIR, 2
 	JE SEG_1_5

 	CMP FIR, 3
 	JE SEG_1_5

 	CMP FIR, 7
 	JE SEG_1_5

	MOV AX, 0604H 
	MOV BX, 0C00H
	MOV CX, 050aH;ul
	MOV DX, 000DH
	INT 10H


    SEG_1_5:
	CMP FIR, 5
 	JE SEG_1_6

 	CMP FIR, 6
 	JE SEG_1_6

	MOV AX, 0604H 
	MOV BX, 0C00H
	MOV CX, 0511H;ur
	MOV DX, 0011H
	INT 10H


    SEG_1_6:
 	CMP FIR, 1
 	JE SEG_1_7

 	CMP FIR, 3
 	JE SEG_1_7

 	CMP FIR, 4
 	JE SEG_1_7

 	CMP FIR, 5
	JE SEG_1_7

	CMP FIR, 7
 	JE SEG_1_7

	CMP FIR, 9
 	JE SEG_1_7

	MOV AX, 0604H 
	MOV BX, 0C00H
	MOV CX, 080DH;ll
	MOV DX, 000DH
	INT 10H


    SEG_1_7:
 	CMP FIR, 2
 	JE  FIR_DISPLAY_1

	MOV AX, 0604H 
	MOV BX, 0C00H
	MOV CX, 0811H;lr
	MOV DX, 0011H
	INT 10H
	
	FIR_DISPLAY_1:
  	MOV AH, 02H
  	MOV BH, 00H
  	MOV DH, 05H
  	MOV DL, 0DH
  	INT 10H

	MOV AH, 9
	LEA DX, DIS
	INT 21H

back:	

	mov ah,9 
	lea dx,PMT
	INT 21H
cur:	
	MOV AH,7
	INT 21H
			
	cmp al,27
	je exit
	
	cmp al,'i'
 	je increment
	
	cmp al,'d'
	je decrement
	jne cur
	
increment:	
inc FIR

cmp FIR,10
JE TIGIL

	
	MOV AX, 3
	INT 10H
	
	;BLACK_TEXT
	MOV AX, 0607H 
	MOV BX, 0000H
	MOV CX, 0541H
	MOV DX, 000DH
	INT 10H

   ; MATRIX_DISPLAY
  	MOV AH, 02H
  	MOV BH, 00H
    MOV DH, 05H
  	MOV DL, 0DH
  	INT 10H

	MOV AH, 9
	LEA DX, DIS
	INT 21H
	
	JMP INCR


decrement:
	DEC FIR

	cmp FIR,0
	JE TIGIL
	
	MOV AX, 3
	INT 10H

   ;BLACK_TEXT
	MOV AX, 0607H 
	MOV BX, 0000H
	MOV CX, 0541H
	MOV DX, 000DH
	INT 10H

    ;MATRIX_DISPLAY
  	MOV AH, 02H
  	MOV BH, 00H
  	MOV DH, 05H
  	MOV DL, 0DH
  	INT 10H

	MOV AH, 9
	LEA DX, DIS
	INT 21H	
		
	JMP INCR


TIGIL:
	mov ah,2
	mov dl,10
	int 21h

	mov dl,13
	int 21h

	MOV AH,9
	LEA DX,EXCLUDED
	INT 21H

EXIT:	
	MOV AH,4CH
	INT 21H

END


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1