Docsity

ASSEMBLY LANGUAGE LAB ON COMPLEX QUESTIONS, Lab Reports of Computer Architecture and Organization

Partial preview of the text

Download ASSEMBLY LANGUAGE LAB ON COMPLEX QUESTIONS and more Lab Reports Computer Architecture and Organization in PDF only on Docsity!

NUST

Military College of Signals,

Rawalpindi.

COA

LAB# 10

BATCH-26C

Submitted By:

AYMEN FATIMA

Cms:

Submitted To:

Mam Laraib

DEPARTMENT OF COMPUTER SOFTWARE ENGINEERING.

EXERCISES

Exercise 10.1:

Write a program to print the sum of series 1+3+6+ … n and also print the value of ax and bx after each step. Note:- ax contains the sum of series and bx used as counter. org 100h include 'emu8086.inc' .data num dw 0 sum dw 0 .code main proc Mov num, 1 Mov sum, 1 looop: Mov Ax, sum

include 'emu8086.inc' .data num1 dw 2 num2 dw 3 num3 dw 1 .code main proc ;printn 'Enter the First number: ' ;call scan_num ;Mov num1, Cx ;printn 'Enter the second number: ' ;call scan_num ;Mov num2, Cx ;printn 'Enter the third number: ' ;call scan_num ;Mov num3, Cx Mov Bx, num cmp num2, Bx jge num2G jle num1G num2G: Mov Bx, num cmp num3, Bx jge jnum jle jnum num1G: Mov Bx, num cmp num3, Bx jge jnum jle jnum jnum3: printn '' printn 'The Third is Largest' jmp end jnum2:

printn '' printn 'The Two is Largest' jmp end jnum1: printn '' printn 'The one is Largest' jmp end end: main endp define_scan_num define_print_num define_print_num_uns ret

Exercise 10.3:

Write an assembly language program that will repeatedly prompt for a number. After each number is entered, display the sum and average of all the numbers entered so far.

Mov Ax, sum Mov Bx, 2 idiv Bx printn '' printn 'Average:' call print_num jmp looop main endp define_scan_num define_print_num define_print_num_uns ret

Exercise 10.4:

Write an assembly language code that implements the following if statement. Input an integer from user and store in DX.

if (value < - 1000) or (value > 1000) then value := 0; end if; org 100h include 'emu8086.inc' .code main proc looop:

jmp looop main endp define_scan_num define_print_num define_print_num_uns ret

Exercise 10.5:

Write an assembly language code that takes input an integer (less than 10) from user and print it in English word e.g.

Please Input an integer (less than 10) = 6 You have Entered = Six org 100h include 'emu8086.inc' .data num dw 0 sum dw 0 avg dw 0 .code main proc looop: printn '' printn 'Enter the Number' call scan_num mov ax, 0

two: printn '' printn 'two' jmp end three: printn '' printn 'three' jmp end four: printn '' printn 'four' jmp end five: printn '' printn 'five' jmp end six: printn '' printn 'six' jmp end seven: printn '' printn 'seven' jmp end eight: printn '' printn 'eight' jmp end nine: printn '' printn 'nine' jmp end end: jmp looop main endp define_scan_num define_print_num define_print_num_uns

ret

Exercise 10.6:

Write an assembly language code that takes input an integer from user and print if its even or odd.

printn '' printn 'Enter the Number' call scan_num Mov Ax, Cx Mov Bx, 2 div Bx cmp Dx, 0 je even printn '' printn 'Odd:' jmp end even: printn '' printn 'Even:' jmp end end: jmp looop main endp define_scan_num define_print_num define_print_num_uns ret