Assembly Language Assesment
Assembly Language Assesment
M. Muneeb Ur Rehman
221370154 CS-248
Q#1:
Stack:
It is a data structure that works on First in Last out (FILO) principle. The data pushed on stack
first is retrieved at last.
When a subroutine is called, the CPU pushes the current execution context onto the stack. This
includes the return address, parameters, and local variables. When the subroutine completes its
execution, the CPU pops the context off the stack, restoring the previous state. This mechanism
ensures that each function call has its own space in memory, preventing interference between
different function calls.
• To move into the stack using SP, you increment or decrement the stack pointer directly.
Q#2
[org 0x0100]
jmp start
series:dw 0,0,0,0,0,0,0,0
size:dw 8
CreateSeries: push bp
mov bp, sp
push ax
push bx
push cx
push dx
push si
mov cx, [bp + 4]
mov bx, [bp + 6]
mov si,0
mov ax,1
mov word[bx+si],ax
sub cx,1
seeNext: dec cx
jnz seriesLoop
pop si
pop dx
pop cx
pop bx
pop ax
pop bp
ret 4
start: mov ax, word[size]
mov bx, series
push bx
push ax
call CreateSeries
Stack:
Si
FFEC Dx
FFEE Cx
FFF0
Bx
FFF2
Ax
FFF4
Bp
FFF6
Return
FFF8
address
FFFA Ax
FFFC Bx
FFFE