Skip to main content

Program 1: Hello World

 **Program 1: Hello World**


```assembly

.model small

.stack 100h


.data

    message db 'Hello, World!', '$'


.code

    main proc

        mov ah, 09h          ; DOS function to print string

        lea dx, message      ; Load effective address of message

        int 21h              ; Call DOS interrupt

        mov ah, 4Ch          ; Exit program

        int 21h

    main endp

end main

```


Explanation:

1. `.model small` and `.stack 100h`: Memory model and stack size definitions.

2. `.data` section: Declares the data segment.

   - `message db 'Hello, World!', '$'`: Defines a null-terminated string.

3. `.code` section: Contains the main code.

   - `mov ah, 09h`: Load DOS function code for printing a string.

   - `lea dx, message`: Load effective address of the message string.

   - `int 21h`: Call DOS interrupt to print the string.

   - `mov ah, 4Ch`: Set the exit code for DOS.

   - `int 21h`: Call DOS interrupt to exit the program.

   


Comments

Popular posts from this blog

12. Write a program to convert NFA to DFA.

Converting a Non-Deterministic Finite Automaton (NFA) to a Deterministic Finite Automaton (DFA) involves creating a new DFA where each state corresponds to a set of NFA states reachable under certain conditions. Below is a simple Python program to perform this conversion. I'll explain each line of code: ```python from collections import defaultdict def epsilon_closure(states, transitions, epsilon):     closure = set(states)     stack = list(states)          while stack:         state = stack.pop()         for next_state in transitions[state].get(epsilon, []):             if next_state not in closure:                 closure.add(next_state)                 stack.append(next_state)          return closure def nfa_to_dfa(nfa_states, nfa_transitions, alphabet, start_state, n...