0% found this document useful (0 votes)
9 views12 pages

Internet Programming

The document covers various topics in Internet Programming and Microprocessor concepts. It explains Django Template Language, HTML & CSS integration, and the organization of RAM and Special Function Registers in 8051 microcontroller. Additionally, it discusses memory interfacing for the 8086 microprocessor and provides details on GPIO pins and memory mapping.

Uploaded by

vpn76332
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views12 pages

Internet Programming

The document covers various topics in Internet Programming and Microprocessor concepts. It explains Django Template Language, HTML & CSS integration, and the organization of RAM and Special Function Registers in 8051 microcontroller. Additionally, it discusses memory interfacing for the 8086 microprocessor and provides details on GPIO pins and memory mapping.

Uploaded by

vpn76332
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Internet Programming

1) Django Template Language (DTL) কী?


Django Template Language হলো Django-র একটি presentation layer, যা দিয়ে আমরা
HTML এর ভিতরে dynamic data (variable, loop, condition) দেখাতে পারি।
এটি মূলত:
 Python code কে HTML থেকে আলাদা রাখে
 Backend data → Frontend এ পাঠাতে সাহায্য করে
✅ 2) Django template এ variable কিভাবে ব্যবহার করবো?
Template এ variable দেখাতে {{ }} ব্যবহার করা হয়।
🔹 [Link]
def home(request):
name = "Rifat"
return render(request, '[Link]', {'username': name})
🔹 [Link]
<h1>Hello {{ username }}</h1>
👉 Output হবে:
Hello Rifat

✅ 3) Django template এর উদাহরণ (Example সহ)


🔹 Loop ব্যবহার
<ul>
{% for item in items %}
<li>{{ item }}</li>
{% endfor %}
</ul>
🔹 Condition ব্যবহার
{% if user.is_authenticated %}
<p>Welcome User</p>
{% else %}
<p>Please Login</p>
{% endif %}

=====================
HTML & CSS
=====================
✅ 4) CSS কে HTML এর সাথে কিভাবে link করবো?
<link rel="stylesheet" href="[Link]">
Django হলে:
{% load static %}
<link rel="stylesheet" href="{% static 'css/[Link]' %}">

✅ 5) CSS লেখার 3 টি উপায়


1️⃣ Inline CSS
<p style="color:red;">Hello</p>
2️⃣ Internal CSS
<style>
Internet Programming
p { color: red; }
</style>
3️⃣ External CSS ✅ (Best practice)
<link rel="stylesheet" href="[Link]">

✅ 6) HTML Element কী?


HTML Element = Tag + Content
<p>Hello World</p>
এখানে:
 <p> → opening tag
 </p> → closing tag
 Hello World → content

✅ 7) HTML Table ও Form


🔹 Table
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Rifat</td>
<td>22</td>
</tr>
</table>
🔹 Form
<form method="post">
<input type="text" name="username">
<input type="submit">
</form>

=====================
Django
=====================
✅ 8) Django App কী?
App হলো Django project এর একটি feature/module
যেমন: accounts, product, blog ইত্যাদি
python [Link] startapp app_name

✅ 9) [Link] কী?
[Link] ব্যবহার হয় URL → view connect করার জন্য।
from [Link] import path
from . import views

urlpatterns = [
path('', [Link]),
]

Internet Programming
✅ 10) [Link] কী?
[Link] হলো যেখানে logic লেখা হয়।
from [Link] import render

def home(request):
return render(request, '[Link]')

✅ 11) HTML file এর কাজ কী?


HTML file ব্যবহার হয়:
 Web page structure বানাতে
 Django template হিসেবে data দেখাতে

✅ 12) [Link] / [Link] কেন ব্যবহার করা হয়?


Repeated code (header, footer, navbar) একবার লিখে reuse করার জন্য।
🔹 [Link]
<body>
{% block content %}{% endblock %}
</body>
🔹 [Link]
{% extends '[Link]' %}

{% block content %}
<h1>Hello</h1>
{% endblock %}

Microprocessor

1. How to search the largest data in an array using 8086 assembly language?
A- Searching the Largest Data in an Array using 8086 Assembly Language
Algorithm
1. Initialize the data segment.
2. Load the first element of the array into AL as the largest value.
3. Set a counter for the remaining elements.
4. Compare each array element with the current largest value.
5. If the current element is greater, update the largest value.
6. Repeat until all elements are checked.
7. The largest value will be stored in AL.
Program (8086 Assembly)
.model small
.stack 100h
.data
array db 25h, 17h, 3Ah, 10h, 2Fh
count db 05h
largest db ?

.code
main proc
mov ax, @data
mov ds, ax

lea si, array


mov al, [si] ; Assume first element is largest
mov cl, count
dec cl ; Remaining elements
inc si

next:
cmp al, [si]
jnc skip
mov al, [si] ; Update largest

skip:
inc si
loop next

mov largest, al ; Store largest value

mov ah, 4Ch


int 21h
main endp
end main

2. GPIO Pins!
A - GPIO (General Purpose Input/Output) pins are programmable digital pins of a microcontroller or processor that
can be configured either as input or output to interact with external devices.
Functions of GPIO Pins
Input Mode
o Reads digital signals (HIGH or LOW) from external devices such as:
 Switches
 Sensors
 Keypads
2. Output Mode
o Sends digital signals to control external components like:
 LEDs
 Relays
 Motors
 Buzzers
GPIO Pin States
 HIGH (Logic 1) → Typically +5V or +3.3V
 LOW (Logic 0) → 0V (Ground)
GPIO Pin Configuration
GPIO pins can be configured using internal registers:
 Direction Register → Sets pin as input or output
 Data Register → Reads or writes data
 Pull-up / Pull-down Resistors → Prevent floating input

Features of GPIO Pins


 Bidirectional (Input/Output selectable)
 Fast switching speed
 Software controllable
 Can generate or detect interrupts
 Some pins support alternate functions (UART, SPI, I²C, PWM)
Applications of GPIO Pins
 LED blinking
 Button interfacing
 Sensor data reading
 Device control in embedded systems
 Communication with peripherals

3. Explain Organization of Internal RAM and Special functions registers of 8051 microcontroller.

A- Organization of Internal RAM and Special Function Registers (SFR) of 8051 Microcontroller
1. Internal RAM Organization of 8051
The 8051 microcontroller contains 128 bytes of internal RAM, addressed from 00H to 7FH. This internal RAM is
divided into three main sections.

(a) Register Banks (00H – 1FH)


 Size: 32 bytes
 Divided into four register banks
 Each bank contains 8 registers (R0–R7)
Register Bank Address Range
Bank 0 (Default) 00H – 07H
Bank 1 08H – 0FH
Bank 2 10H – 17H
Bank 3 18H – 1FH
👉 Bank selection is controlled by PSW register bits (RS0, RS1).

(b) Bit-Addressable RAM (20H – 2FH)


 Size: 16 bytes (128 bits)
 Each bit can be individually accessed
 Used for flags, status bits, and Boolean operations
Example:
SETB 20H
CLR 21H

(c) General Purpose RAM (30H – 7FH)


 Size: 80 bytes
 Used for:
o Variable storage
o Stack
o Temporary data
Summary of Internal RAM
Address Range Purpose
00H – 1FH Register Banks
20H – 2FH Bit-addressable RAM
30H – 7FH General Purpose RAM

2. Special Function Registers (SFR) Organization


 SFRs are located in address range 80H – FFH

 Used to control:

o I/O ports

o Timers

o Serial communication

o Interrupts

o CPU operations

⚠ These addresses overlap with RAM but are accessed differently.

Important Special Function Registers

SFR Address Function

ACC (Accumulator) E0H Arithmetic & logic operations

B Register F0H Used in MUL/DIV

PSW D0H Program Status Word

SP 81H Stack Pointer

DPTR 82H–83H Data Pointer

P0 80H Port 0

P1 90H Port 1

P2 A0H Port 2

P3 B0H Port 3

TMOD 89H Timer Mode

TCON 88H Timer Control

SCON 98H Serial Control

IE A8H Interrupt Enable


SFR Address Function

IP B8H Interrupt Priority

Bit-Addressable SFRs
Some SFRs allow bit-level access, such as:
 PSW
 TCON
 SCON
 IE
 IP
 Port registers
Example:
SETB EA ; Enable interrupts
CLR TF0 ; Clear Timer 0 flag

3. Difference Between Internal RAM and SFR

Feature Internal RAM SFR

Address Range 00H – 7FH 80H – FFH

Purpose Data storage Hardware control

Bit-Addressable Partially Selected registers

User Accessible Yes Yes (control specific)

4. Conclusion

The 8051 internal RAM is used for data storage and register operations, while Special Function Registers (SFRs) are
used to control and monitor the microcontroller’s hardware resources. Proper understanding of both is essential for
efficient 8051 programming.

4. Discuss memory MAP for a 1K memory describe its address range.


A - Definition
A 1K memory consists of 1024 memory locations, where
1K=1024=2101K = 1024 = 2^{10}1K=1024=210
Each memory location stores 1 byte (8 bits) of data.
Address Range of 1K Memory
Since 1024 locations are required, 10 address lines are needed:
Number of address lines=log⁡2(1024)=10\text{Number of address lines} = \log_2(1024) =
10Number of address lines=log2(1024)=10
Address Range
 Starting Address: 000H
 Ending Address: 3FFH
So, the address range is:
000H → 3FFH
Memory Map Representation
Address (Hex) Description
000H First memory location
001H Second memory location
... ...
3FFH Last memory location
Binary Explanation
 Lowest address: 0000000000₂ (10 bits)
 Highest address: 1111111111₂ (10 bits)

Which equals:

 000H to 3FFH in hexadecimal

Memory Map Diagram (Conceptual)

3FFH ──────────── ← Last address


│ │
│ 1K Memory │
│ │
000H ──────────── ← First address

5. Explain a memory interface for an 8086 microprocessor with 32 KB RAM and 16 KB Rom
A- Memory Interface of 8086 Microprocessor with 32 KB RAM and 16 KB ROM
1. Introduction
Memory interfacing is the process of connecting external memory devices (RAM and ROM) with the 8086
microprocessor so that the CPU can read and write data correctly using address, data, and control signals.
In this system:
 RAM = 32 KB
 ROM = 16 KB
 Total memory = 48 KB
2. Key Features of 8086 Relevant to Memory Interfacing
 8086 has a 20-bit address bus → can address 1 MB memory
 16-bit data bus
 Uses even–odd memory banking:
o Even bank → lower byte (D0–D7)
o Odd bank → higher byte (D8–D15)
 Control signals:
o RD̅ (Read)
o WR̅ (Write)
o M/IO̅ (Memory or I/O select)
o A0 and BHE̅ for byte selection
3. Memory Size and Address Lines
(a) RAM
 32 KB = 32 × 1024 = 32768 bytes
 Requires 15 address lines (A0–A14)
(b) ROM
 16 KB = 16 × 1024 = 16384 bytes
 Requires 14 address lines (A0–A13)
4. Address Allocation (Memory Map)
A typical and exam-friendly memory map:
ROM (16 KB)
 Used for program storage
 Placed at higher address, because 8086 fetches reset vector from top of memory
ROM Address Range:
FC000H – FFFFFH (16 KB)
RAM (32 KB)
 Used for data and stack
RAM Address Range:
00000H – 07FFFH (32 KB)
Memory Map Diagram

FFFFFH ────────────
│ 16 KB │
│ ROM │
FC000H ────────────

07FFFH ────────────
│ 32 KB │
│ RAM │
00000H ────────────

5. Chip Selection Logic


 Higher address lines (A15–A19) are used for chip select decoding
 A 3-to-8 decoder (e.g., 74LS138) is commonly used
 Decoder outputs activate:
o ROM chip select
o RAM chip select
6. Even–Odd Memory Banking
Because 8086 has a 16-bit data bus, memory is divided into two banks:
Bank Data Bus Selected When
Even Bank D0–D7 A0 = 0
Odd Bank D8–D15 BHE̅ = 0
This allows:
 Byte access
 Word access in a single cycle (if aligned)
7. Control Signal Connections
 RD̅ → connected to OE̅ of ROM and RAM
 WR̅ → connected to WE̅ of RAM
 M/IO̅ → used to indicate memory operation
 A0 & BHE̅ → select lower or upper memory bank
8. Summary Table
Component Size Address Range
RAM 32 KB 00000H – 07FFFH
ROM 16 KB FC000H – FFFFFH
6. Draw and explain pin configuration 8086 microprocessor.
A - Introduction
The 8086 microprocessor is a 16-bit CPU with a 40-pin DIP (Dual In-line Package). Its pins are used for addressing,
data transfer, control signals, interrupts, and power supply.
The pin functions vary depending on Minimum Mode and Maximum Mode of operation.
Pin Diagram of 8086 (40-pin DIP)
┌──────────────────────────┐
GND ─│1 40│─ VCC
AD14─│2 39│─ AD15
AD13─│3 38│─ A19 / S6
AD12─│4 37│─ A18 / S5
AD11─│5 36│─ A17 / S4
AD10─│6 35│─ A16 / S3
AD9─│7 34│─ BHE̅ / S7
AD8─│8 33│─ MN/MX̅
AD7─│9 32│─ RD̅
AD6─│10 31│─ HOLD
AD5─│11 30│─ HLDA
AD4─│12 29│─ WR̅
AD3─│13 28│─ M/IO̅
AD2─│14 27│─ DT/R̅
AD1─│15 26│─ DEN̅
AD0─│16 25│─ ALE
NMI─│17 24│─ INTA̅
INTR─│18 23│─ READY
CLK ─│19 22│─ RESET
└──────────────────────────┘
Functional Groups of Pins
1. Address/Data Bus (AD0–AD15)
 Multiplexed pins
 Carry:
o Address during T1
o Data during T2–T4
 Lower 16-bit address and data bus
2. Higher Address / Status Lines (A16–A19 / S3–S6)
 Carry:
o Higher-order address bits
o Status information (segment being accessed)
3. Control Signals
Pin Function
RD̅ Read signal
WR̅ Write signal
M/IO̅ Memory or I/O select
ALE Address Latch Enable
DEN̅ Data Enable
DT/R̅ Data Transmit / Receive

4. Interrupt Pins
Pin Description
INTR Maskable interrupt
NMI Non-maskable interrupt
INTA̅ Interrupt acknowledge
5. DMA & Bus Control Pins
Pin Function
HOLD DMA request
HLDA DMA acknowledge
READY Inserts wait states
6. Mode Selection Pin
Pin Function
MN/MX̅ Selects operating mode
1 → Minimum Mode
0 → Maximum Mode
7. Clock, Reset & Power Pins
Pin Function
CLK System clock
RESET Resets CPU
VCC +5V supply
GND Ground
Minimum vs Maximum Mode
 Minimum Mode: Single-processor system
 Maximum Mode: Multi-processor / co-processor system (uses 8288 bus controller)

7. Explain 8051 is interface with 8086 and use for serial communication
A - Interfacing 8051 with 8086 Microprocessor for Serial Communication
1. Introduction
The 8086 microprocessor is a 16-bit CPU used in general computing, while 8051 microcontroller is an 8-bit device
with built-in UART for serial communication.
By interfacing 8051 with 8086:
 8086 can offload serial communication tasks to 8051.
 8051 acts as a serial I/O processor for transmitting and receiving data via RS-232 or TTL serial lines.

2. Block Diagram (Conceptual)

8086 Microprocessor
+-----------------+
| Address / Data |
| Control Signals |
+-----------------+

│ Data Bus / Control

+-----------------+
| 8051 MCU |
| (UART Enabled) |
+-----------------+

│ Serial Tx/Rx

External Device
(PC, Modem, Sensor)
3. Interfacing Concept
(a) Hardware Connections
1. Data Bus Connection
o Lower 8-bit data bus of 8086 (D0–D7) connected to 8051 Port 0 or Port 1.
o Address bus lines (A0–A7) select registers or buffers in 8051.
2. Control Signals
o RD̅ → Read from 8051
o WR̅ → Write to 8051
o ALE / CS → Chip select for 8051
3. Serial Lines
o TXD → Transmit Data
o RXD → Receive Data
o Connected to external devices like PC or modem.
(b) Software Flow
 8086 Side
1. Load data into 8051 via data bus.
2. Trigger write operation using WR̅ .
3. For receiving, read data using RD̅ .
 8051 Side
1. Use UART (Serial Control SCON register) for serial transmission.
2. Set baud rate in Timer1.
3. Send/receive data via serial buffer (SBUF register).4. Example: Data Transfer
1. 8086 sends data to 8051
MOV AL, 55H ; Data to send
OUT 80H ; 8051 Port (mapped via address decoder)
2. 8051 transmits serially
MOV SBUF, A ; Load data to serial buffer
SETB TI ; Wait until transmit complete
3. 8051 receives serial data
JNB RI, $ ; Wait until reception complete
MOV A, SBUF ; Read received data
CLR RI ; Clear receive flag
4. 8086 reads data from 8051
IN AL, 80H ; Read data from 8051 mapped port
5. Applications
 Serial communication between 8086 computer and external devices (PC, sensors, printers)
 Offloading UART tasks to 8051 reduces CPU overhead
 Data logging, terminal communication, embedded system control
6. Advantages of Using 8051 with 8086
 Provides built-in UART for reliable serial communication
 Reduces software complexity on 8086
 Can handle full-duplex serial communication
 Compatible with RS-232 / TTL devices

You might also like