Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

how to work with zero

$
0
0
How to work this code with zero/0 ?
; this program asks the user to enter two numbers, and decides whether ; the first or the second entered number is bigger.

.model small
.stack
.data
      text1 db 'Enter first number: $'
      text2 db 'Enter second number: $'
      text3 db 'First is bigger.',10,13,'$'
      text4 db 'Second is bigger.',10,13,'$'
      text5 db 'Equal numbers.',10,13,'$'
      new_line db 10, 13, '$'
.code

start:
mov ax, _data		; ds - data segment
mov ds, ax

mov ax, 3		; clear screen
int 10h

mov ah, 9		; text1 to screen
lea dx, text1
int 21h

mov ah, 1		; read char
int 21h

push ax			; char to stack

mov ah, 9		; jump to the start of the next line	
lea dx, new_line
int 21h

mov ah, 9		; text2 to screen
lea dx, text2
int 21h

mov ah, 1		; read char
int 21h

push ax			; second char to stack

mov ah, 9		; jump to the start of the next line
lea dx, new_line
int 21h

pop cx			; second char from stack to cx
pop bx			; first char from stack to bx

cmp bx,cx		; compare chars
je lab_equal

cmp bx,cx		; compare chars
jg lab_first

        mov ah, 9	; text4 to screen
	lea dx, text4
	int 21h
	jmp vege

lab_equal:
	mov ah, 9	; text 5 to screen
	lea dx, text5
	int 21h
	jmp vege

lab_first:
	mov ah, 9	; text3 to screen
	lea dx, text3
	int 21h

vege:
mov ax,4c00h		; exit
int 21h

end start


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>