Cs Practical

You might also like

Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 3

BSCS

VU ID : Bc230208890

Name : Mahdia

section .data

vuid db "230208890", 0 ; Replace "230208890" with your actual VUID

section .bss

largest_digit resb 1

smallest_digit resb 1

result resb 1

section .text

global _start

_start:

; Find the largest and smallest digits

mov esi, vuid

movzx ecx, byte [esi] ; Initialize counter

movzx bl, byte [esi + ecx - 1] ; Initialize largest_digit with the first digit

find_digits_loop:

cmp byte [esi], 0


je found_digits

mov al, [esi] ; Load the current digit

; Check if the current digit is larger than the stored largest_digit

cmp al, bl

jg update_largest_digit

; Check if the current digit is smaller than the stored smallest_digit

cmp al, [smallest_digit]

jl update_smallest_digit

jmp next_digit

update_largest_digit:

mov bl, al ; Update largest_digit

jmp next_digit

update_smallest_digit:

mov [smallest_digit], al ; Update smallest_digit

next_digit:

inc esi

jmp find_digits_loop
found_digits:

; Calculate the multiplication of the largest and smallest digits

movzx eax, byte [largest_digit]

imul eax, byte [smallest_digit]

mov [result], al

; Your program may continue here to perform further actions or terminate

; Terminate the program

mov eax, 1 ; syscall: exit

xor ebx, ebx ; status: 0

int 0x80 ; Call kernel

You might also like