Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Kingdom of Saudi Arabia

Ministry of Higher Education ‫المملكة العربية السعودية‬


‫وزارة التعليم العالى‬
Jazan University ‫جــامـعــة جـــــازان‬
College of Computer Science & Information Systems
‫كلية الحاسب اآللى ونظم المعلومات‬

:‫الرقم الجامعي‬ :‫اسم الطالب‬


:‫رقم التسلسل‬ : ‫رقم الشعبة‬

ACADEMIC YEAR 1441/1442H


CNET-213, COMPUTER ORGANISATION &
ARCHITECTURE Assignment
Maximum Marks: 10

:Instructions

1. Answer all the questions. All questions are mandatory.


2. Hand writing is not allowed.
3. Don't submit copied assignments.
Date of Submission: 15/11/2020
:Question 1

.Write a program to display your name five times using a call and jump or loop statement

;You may customize this and other start-up templates ;

The location of this template is c:\emu8086\inc\0_com_template.txt ;

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

mov dx,offset message

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 .

The location of this template is c:\emu8086\inc\0_com_template.txt ;

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

MOV AH,BYTE PTR[BX]

L1: CMP AL,BYTE PTR[BX]

JG L2

MOV AL,BYTE PTR[BX]

L2: CMP AH,BYTE PTR[BX]

Jng L3

MOV AH,BYTE PTR[BX]

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

"$ :msg2 db 0Dh,0Ah, " binary form

buffer for int 21h/0ah ;

,fist byte is buffer size ;

.second byte is number of chars actually read (set by int 21h/0ah) ;

buffer db 7,?, 5 dup (0), 0, 0

:for result ;

? binary dw

code.

:start

:print welcome message ;

mov dx, offset msg1

mov ah, 9

int 21h

:input string ;

mov dx, offset buffer

mov ah, 0ah

int 21h

:make sure the string is zero terminated ;

mov bx, 0
mov bl, buffer[1]

mov buffer[bx+2], 0

.lea si, buffer + 2 ; buffer starts from third byte

call tobin

.the number is in cx register ;

for '-1234' it's 0fb2eh ;

mov binary, cx

jcxz stop

:print pre-result message ;

mov dx, offset msg2

int 21h

:print result in binary ;

mov bx, binary

mov cx, 16

.print: mov ah, 2 ; print function

'mov dl, '0

.test bx, 1000000000000000b ; test first bit

jz zero

'mov dl, '1

zero: int 21h

shl bx, 1

loop print

:print binary suffix ;

'mov dl, 'b


int 21h

jmp start ; loop

:stop

.ret ; return control to the operating system

; binary number. number can have a this procedure converts string number to 103 ;
.)'-'( sign

.the result is stored in cx register ;

:parameters ;

.si - address of string number (zero terminated) ;

tobin proc near

push dx

push ax

push si

jmp process

==== local variables ====;

.make_minus db ? ; used as a flag

.ten dw 10 ; used as multiplier

=========================;

:process
:reset the accumulator ;

mov cx, 0

:reset flag ;

mov cs:make_minus, 0

:next_digit

: ; point to next byte read char to al and 132 ;

mov al, [si]

inc si

:check for end of string ;

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

You might also like