NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

.model small
.stack 100h
.data
titleMsg db 'AR 101 LABORATORY ACTIVITY$'
welcomeMsg db 'Welcome to Computer Architecture and Organization$'
passPrompt db 'Enter Password: $'
correctPass db '1234$'
wrongMsg db 'Incorrect Password! Press any key to try again...$'
input db 6 dup(?) ; input buffer
selected db 1 ; currently selected menu item (1-7)
menuTitle db ' M E N U$'
ex1 db 'Exercise 1 - Conditional Maximum$'
ex2 db 'Exercise 2 - Simple Arithmetic$'
ex3 db 'Exercise 3 - String Reversal$'
ex4 db 'Exercise 4 - Palindrome Checker$'
ex5 db 'Exercise 5 - Fibonacci Sequence$'
ex6 db 'Exercise 6 - Simple Calculator$'
ex7 db 'Exercise 7 - Bitwise Operations$'
.code
main proc
mov ax, @data
mov ds, ax

password_screen:
; --- SET TEXT MODE ---
mov ax, 03h
int 10h

; --- DISPLAY TITLE ---
mov ah, 02h
mov bh, 0
mov dh, 5
mov dl, 25
int 10h
mov ah, 09h
lea dx, titleMsg
int 21h

; --- DISPLAY WELCOME MESSAGE ---
mov ah, 02h
mov bh, 0
mov dh, 7
mov dl, 10
int 10h
mov ah, 09h
lea dx, welcomeMsg
int 21h

; --- ENTER PASSWORD PROMPT ---
mov ah, 02h
mov bh, 0
mov dh, 10
mov dl, 20
int 10h
mov ah, 09h
lea dx, passPrompt
int 21h

; --- CLEAR INPUT BUFFER ---
lea si, input
mov cx, 6
clear_input:
mov byte ptr [si], '$'
inc si
loop clear_input

; --- READ PASSWORD WITH * MASK ---
lea si, input
mov cx, 0
readLoop:
mov ah, 08h
int 21h

; Check for backspace
cmp al, 08h
je handle_backspace

cmp al, 0Dh
je doneRead

cmp cx, 4 ; Only accept 4 characters
jae readLoop

mov [si], al
inc si
inc cx
mov ah, 02h
mov dl, '*'
int 21h
jmp readLoop

handle_backspace:
cmp cx, 0 ; Check if there's anything to delete
je readLoop
dec si
dec cx
mov byte ptr [si], '$'
; Move cursor back and erase character
mov ah, 02h
mov dl, 08h ; backspace
int 21h
mov dl, ' ' ; space to clear
int 21h
mov dl, 08h ; backspace again
int 21h
jmp readLoop

doneRead:
mov byte ptr [si], '$'

; --- COMPARE PASSWORD ---
lea si, input
lea di, correctPass
mov cx, 0 ; counter for matched characters

compareLoop:
mov al, [si]
mov bl, [di]

; Check if we reached end of correctPass
cmp bl, '$'
je check_length

; Check if we reached end of input too early
cmp al, '$'
je wrong_pass

; Compare characters
cmp al, bl
jne wrong_pass

inc si
inc di
inc cx
jmp compareLoop

check_length:
; Make sure input also ends here
mov al, [si]
cmp al, '$'
je pass_ok ; Both strings ended at same point
jmp wrong_pass ; Input is longer than correct password

wrong_pass:
; Display error message
mov ah, 02h
mov bh, 0
mov dh, 12
mov dl, 10
int 10h
mov ah, 09h
lea dx, wrongMsg
int 21h

; Wait for any key press
mov ah, 00h
int 16h

; Go back to password screen
jmp password_screen

; --- CORRECT PASSWORD ---
pass_ok:
; Clear screen
mov ax, 03h
int 10h
; =========================
; DRAW 4-COLOR QUADRANTS
; =========================
; Top-left (YELLOW)
mov ah, 06h
mov al, 0
mov bh, 0EEh ; bright yellow background
mov ch, 0
mov cl, 0
mov dh, 12
mov dl, 39
int 10h
; Top-right (RED)
mov ah, 06h
mov al, 0
mov bh, 044h ; red background
mov ch, 0
mov cl, 40
mov dh, 12
mov dl, 79
int 10h
; Bottom-left (RED)
mov ah, 06h
mov al, 0
mov bh, 044h ; red background
mov ch, 13
mov cl, 0
mov dh, 24
mov dl, 39
int 10h
; Bottom-right (YELLOW)
mov ah, 06h
mov al, 0
mov bh, 0EEh ; bright yellow background
mov ch, 13
mov cl, 40
mov dh, 24
mov dl, 79
int 10h
; =========================
; BLUE BOX OVERLAY (LARGER, CENTERED)
; =========================
mov ah, 06h
mov al, 0
mov bh, 1Fh ; blue background, white text
mov ch, 2 ; start row (higher up)
mov cl, 17 ; start column
mov dh, 20 ; end row (lower down)
mov dl, 62 ; end column
int 10h

menu_loop:
; Redraw blue box to clear previous highlights
mov ah, 06h
mov al, 0
mov bh, 1Fh ; blue background, white text
mov ch, 2
mov cl, 17
mov dh, 20
mov dl, 62
int 10h

; Display menu items with highlight
call display_menu

; Wait for arrow key input
mov ah, 00h
int 16h

; Check for Enter key
cmp ah, 1Ch ; Enter scan code
je menu_selected

; Check for Up arrow
cmp ah, 48h ; Up arrow scan code
je move_up

; Check for Down arrow
cmp ah, 50h ; Down arrow scan code
je move_down

jmp menu_loop

move_up:
mov al, selected
cmp al, 1
je menu_loop ; Already at top
dec selected
jmp menu_loop

move_down:
mov al, selected
cmp al, 7 ; Changed to 7
je menu_loop ; Already at bottom
inc selected
jmp menu_loop

menu_selected:
; Here you can add code to handle the selected menu item
; For now, just exit
jmp stop_here

display_menu proc
; Menu title
mov ah, 02h
mov bh, 0
mov dh, 4
mov dl, 38
int 10h
mov ah, 09h
lea dx, menuTitle
int 21h

; Exercise 1
mov al, selected
cmp al, 1
je draw_highlight1
jmp draw_normal1
draw_highlight1:
; Draw highlight background
mov ah, 06h
mov al, 0
mov bh, 70h ; black on white
mov ch, 6
mov cl, 19
mov dh, 6
mov dl, 60
int 10h
draw_normal1:
mov ah, 02h
mov bh, 0
mov dh, 6
mov dl, 22
int 10h
mov ah, 09h
lea dx, ex1
int 21h

; Exercise 2
mov al, selected
cmp al, 2
je draw_highlight2
jmp draw_normal2
draw_highlight2:
mov ah, 06h
mov al, 0
mov bh, 70h
mov ch, 8
mov cl, 19
mov dh, 8
mov dl, 60
int 10h
draw_normal2:
mov ah, 02h
mov bh, 0
mov dh, 8
mov dl, 22
int 10h
mov ah, 09h
lea dx, ex2
int 21h

; Exercise 3
mov al, selected
cmp al, 3
je draw_highlight3
jmp draw_normal3
draw_highlight3:
mov ah, 06h
mov al, 0
mov bh, 70h
mov ch, 10
mov cl, 19
mov dh, 10
mov dl, 60
int 10h
draw_normal3:
mov ah, 02h
mov bh, 0
mov dh, 10
mov dl, 22
int 10h
mov ah, 09h
lea dx, ex3
int 21h

; Exercise 4
mov al, selected
cmp al, 4
je draw_highlight4
jmp draw_normal4
draw_highlight4:
mov ah, 06h
mov al, 0
mov bh, 70h
mov ch, 12
mov cl, 19
mov dh, 12
mov dl, 60
int 10h
draw_normal4:
mov ah, 02h
mov bh, 0
mov dh, 12
mov dl, 22
int 10h
mov ah, 09h
lea dx, ex4
int 21h

; Exercise 5
mov al, selected
cmp al, 5
je draw_highlight5
jmp draw_normal5
draw_highlight5:
mov ah, 06h
mov al, 0
mov bh, 70h
mov ch, 14
mov cl, 19
mov dh, 14
mov dl, 60
int 10h
draw_normal5:
mov ah, 02h
mov bh, 0
mov dh, 14
mov dl, 22
int 10h
mov ah, 09h
lea dx, ex5
int 21h

; Exercise 6
mov al, selected
cmp al, 6
je draw_highlight6
jmp draw_normal6
draw_highlight6:
mov ah, 06h
mov al, 0
mov bh, 70h
mov ch, 16
mov cl, 19
mov dh, 16
mov dl, 60
int 10h
draw_normal6:
mov ah, 02h
mov bh, 0
mov dh, 16
mov dl, 22
int 10h
mov ah, 09h
lea dx, ex6
int 21h

; Exercise 7
mov al, selected
cmp al, 7
je draw_highlight7
jmp draw_normal7
draw_highlight7:
mov ah, 06h
mov al, 0
mov bh, 70h
mov ch, 18
mov cl, 19
mov dh, 18
mov dl, 60
int 10h
draw_normal7:
mov ah, 02h
mov bh, 0
mov dh, 18
mov dl, 22
int 10h
mov ah, 09h
lea dx, ex7
int 21h

ret
display_menu endp

stop_here:
mov ah, 4Ch
int 21h

end main


     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.