Jazan University: Kingdom of Saudi Arabia Ministry of Higher Education
Jazan University: Kingdom of Saudi Arabia Ministry of Higher Education
:Instructions
.Write a program to display your name five times using a call and jump or loop statement
org 100h
model small.
stack 100h.
data.
'$',message db "Asala",0dh,0ah
code.
main proc
mov ax,@data
mov ds,ax
MOV CL,05H
:LOP
mov ah,9
int 21h
DEC CL
JNZ LOP
mov ax,4C00h
int 21h
main endp
end main
Question 2: Write a program that display your ID number then add the largest and smallest
.numbers of your ID number
;stack 100h; You may customize this and other start-up templates .
org 100h
model small.
stack 100h.
data.
'$',ID db "279000027",0dh,0ah
? sum db
code.
main proc
mov ax,@data
mov ds,ax
mov ah,9
mov dx,offset ID
int 21h
LEA BX,ID
MOV CL,02
MOV AL,00
JG L2
Jng L3
L3:INC BX
DEC CL
CMP CL,00
JNZ L1
:ADDITION
add AL,AH
MOV AH,00
mov sum,al
mov ah,9
mov dL,sum
int 21h
mov ax,4C00h
int 21h
main endp
end main
:Question 3
.Write a program to convert your serial number into binary no
org 100h
model small.
stack 100h.
data.
msg1 db 0Dh,0Ah, " enter any number from -32768 to 65535 inclusive, or zero to
"$ :stop
:for result ;
? binary dw
code.
:start
mov ah, 9
int 21h
:input string ;
int 21h
mov bx, 0
mov bl, buffer[1]
mov buffer[bx+2], 0
call tobin
mov binary, cx
jcxz stop
int 21h
mov cx, 16
jz zero
shl bx, 1
loop print
:stop
; binary number. number can have a this procedure converts string number to 103 ;
.)'-'( sign
:parameters ;
push dx
push ax
push si
jmp process
=========================;
:process
:reset the accumulator ;
mov cx, 0
:reset flag ;
mov cs:make_minus, 0
:next_digit
inc si
cmp al,0
jne not_end
jmp stop_input
:not_end
'-',cmp al
jne ok_digit
mov cs:make_minus,1
jmp next_digit
:ok_digit
push ax
mov ax,cx
mul cs:ten
mov cx,ax
pop ax
sub al,30h
mov ah,0
mov dx,cx
add cx,ax
jmp next_digit
:stop_input
cmp cs:make_minus,0
je not_minus
neg cx
:not_minus
pop si
pop ax
pop dx
ret
tobin endp