Stacks & Breaks
  • Home
    • Home #1
      • Infinite Scroll Load More
      • Infinite Load More Posts
      • Home Featured Video
      • Home with Left Sidebar
      • Home with Sticky Sidebar
      • Standard Layout
      • Classic Layout
    • Home #2
      • Grid Layout
      • Grid with Sidebar
      • Grid 2 Columns Layout
      • List Layout
      • Masonry Layout
      • Masonry with Sidebar
      • Masonry 2 Columns Layout
      • Boxed Layout
      • Overlay Layout
    • Home #3
      • Mixed Layout
      • Mixed Style 2 Layout
      • Photography Layout
      • Magazine Layout 1
      • Magazine Layout 2
      • Magazine Layout 3
      • 1st Overlay Then Grid
      • 1st Overlay Then List
      • 1st Standard Then Grid
    • Home #4
      • 1st Standard Grid Sidebar
      • 1st Standard Then Grid 2
      • 1st Standard Then List
      • 1st Standard Then Boxed
      • 1st Classic Then Grid
      • 1st Classic Grid Sidebar
      • 1st Classic Then Grid 2
      • 1st Classic Then List
      • 1st Classic Then Boxed
  • Sliders
    • Slider #1
      • Home with Slider 1
      • Home with Slider 2
      • Home with Slider 3
      • Home with Slider 4
      • Home with Slider 5
      • Home with Slider 6
      • Home with Slider 7
      • Home with Slider 8
      • Home with Slider 9
    • Slider #2
      • Home with Slider 10
      • Home with Slider 11
      • Home with Slider 12
      • Home with Slider 13
      • Home with Slider 14
      • Home with Slider 15
      • Home with Slider 16
      • Home with Slider 17
      • Home with Slider 18
    • Slider #3
    • Slider #4
      • Home with Slider 28
      • Home with Slider 29
      • Home with Slider 30
      • Home with Slider 35
      • Home with Slider 36
      • Home with Slider 37
      • Home with Slider 38
      • Home Penci Slider 1
      • Home Penci Slider 2
  • Features
  • Coding
  • Guide
  • Resources
  • Portfolio
    • Masonry 3 Columns
    • Masonry 2 Columns
    • Masonry with Sidebar
    • Grid 3 Columns
    • Grid with Sidebar
    • Grid 2 Columns
    • Single Portfolio
  • Shop
  • Home with Slider 19
  • Home with Slider 20
  • Home with Slider 21
  • Home with Slider 22
  • Home with Slider 23
  • Home with Slider 24
  • Home with Slider 25
  • Home with Slider 26
  • Home with Slider 27
  • Post Templates
  • Headers
  • Menu Item Style 2
  • Real Awesome Gallery
  • Post Formats
  • Pages
  • Typography
  • Template Style 1
  • Template Style 2
  • Template Style 3
  • Style 3 with Parallax
  • Template Style 4
  • Style 4 with Parallax
  • Template Style 5
  • Style 5 with Parallax
  • Template Style 6
  • Style 6 with Parallax
  • Template Style 7
  • Style 7 with Parallax
  • Template Style 8
  • Style 8 with Parallax
  • Template Style 9
  • Style 9 with Parallax
  • Template Style 10
  • Style 10 with Parallax
  • Header Style 1
  • Header Style 2
  • Header Style 3
  • Header Style 4 (Centerd)
  • Header Style 5 (Centerd)
  • Header Style 6
  • Header Style 7
  • Header Style 8
  • Header Style 9
  • Standard Post
  • Gallery Post
  • Video Post
  • Audio Post
  • Quote Post
  • Link Post
  • Youtube Post
  • Vimeo Post
  • Soundcloud Audio
  • Self-hosted Audio
  • About me
  • Contact Me
  • Page Left Sidebar
  • Page Full Width
  • Page 404

Latest Video

Popular Posts

  • 1

    Computer Architecture (Windows/Intel): What a system debug engineer needs to know?

    November 2, 2020
  • 2

    Courses to Jumpstart Your Development Career

    January 25, 2019
  • 3

    Wireshark Basics Playlist

    November 2, 2020
@2021 - All Right Reserved. Designed and Developed by PenciDesign
ArchitectureBasics

All the “Truth” you need to know about “Truth Table”

by dnaadmin February 19, 2022
written by dnaadmin

February 19, 2022 0 comments
0 FacebookTwitterPinterestEmail
ArchitectureBasics

Registers & Computer Memory Primer for x86

by dnaadmin February 19, 2022
written by dnaadmin
Registers

The main tools to write programs in x86 assembly are the processor registers. The registers are like variables built in the processor. Using registers instead of memory to store values makes the process faster and cleaner. The problem with the x86 series of processors is that there are few registers to use.

Modern x86 processors have eight 32-bit general-purpose registers, as depicted in the figure below. The register names are mostly historical. For example, EAX used to be called the accumulator since it was used by a number of arithmetic operations, and ECX was known as the counter since it was used to hold a loop index. Whereas most of the registers have lost their special purposes in the modern instruction set, by convention, two are reserved for special purposes — the stack pointer (ESP) and the base pointer (EBP). More details are given below.

 

Here is a list of the available registers on the 386 and higher processors. This list shows the 32 bit registers. Most of the can be broken down to 16 or even 8 bits registers.

General registers
EAX EBX ECX EDX

Segment registers
CS DS ES FS GS SS

Index and pointers
ESI EDI EBP EIP ESP

Indicator
EFLAGS

General registers
As the title says, general register are the one we use most of the time Most of the instructions perform on these registers. They all can be broken down into 16 and 8 bit registers.


32 bits :  EAX EBX ECX EDX
16 bits : AX BX CX DX
 8 bits : AH AL BH BL CH CL DH DL

The “H” and “L” suffix on the 8 bit registers stand for high byte and low byte. With this out of the way, let’s see their individual main use


EAX,AX,AH,AL : Called the Accumulator register. 
               It is used for I/O port access, arithmetic, interrupt calls,
               etc...

EBX,BX,BH,BL : Called the Base register
               It is used as a base pointer for memory access
               Gets some interrupt return values

ECX,CX,CH,CL : Called the Counter register
               It is used as a loop counter and for shifts
               Gets some interrupt values

EDX,DX,DH,DL : Called the Data register
               It is used for I/O port access, arithmetic, some interrupt 
               calls.

Segment registers

Segment registers hold the segment address of various items. They are only available in 16 values. They can only be set by a general register or special instructions. Some of them are critical for the good execution of the program and you might want to consider playing with them when you’ll be ready for multi-segment programming


CS         : Holds the Code segment in which your program runs.
             Changing its value might make the computer hang.

DS         : Holds the Data segment that your program accesses.
             Changing its value might give erronous data.

ES,FS,GS   : These are extra segment registers available for
             far pointer addressing like video memory and such.

SS         : Holds the Stack segment your program uses.
             Sometimes has the same value as DS.
             Changing its value can give unpredictable results,
             mostly data related.

 

Indexes and pointers

Indexes and pointer and the offset part of and address. They have various uses but each register has a specific function. They some time used with a segment register to point to far address (in a 1Mb range). The register with an “E” prefix can only be used in protected mode.


ES:EDI EDI DI : Destination index register
                Used for string, memory array copying and setting and
                for far pointer addressing with ES

DS:ESI EDI SI : Source index register
                Used for string and memory array copying

SS:EBP EBP BP : Stack Base pointer register
                Holds the base address of the stack
                
SS:ESP ESP SP : Stack pointer register
                Holds the top address of the stack

CS:EIP EIP IP : Index Pointer
                Holds the offset of the next instruction
                It can only be read 

The EFLAGS register

The EFLAGS register hold the state of the processor. It is modified by many intructions and is used for comparing some parameters, conditional loops and conditionnal jumps. Each bit holds the state of specific parameter of the last instruction. Here is a listing :


Bit   Label    Desciption
---------------------------
0      CF      Carry flag
2      PF      Parity flag
4      AF      Auxiliary carry flag
6      ZF      Zero flag
7      SF      Sign flag
8      TF      Trap flag
9      IF      Interrupt enable flag
10     DF      Direction flag
11     OF      Overflow flag
12-13  IOPL    I/O Priviledge level
14     NT      Nested task flag
16     RF      Resume flag
17     VM      Virtual 8086 mode flag
18     AC      Alignment check flag (486+)
19     VIF     Virutal interrupt flag
20     VIP     Virtual interrupt pending flag
21     ID      ID flag

Those that are not listed are reserved by Intel.

Undocumented registers

There are registers on the 80386 and higher processors that are not well documented by Intel. These are divided in control registers, debug registers, test registers and protected mode segmentation registers. As far as I know, the control registers, along with the segmentation registers, are used in protected mode programming, all of these registers are available on 80386 and higher processors except the test registers that have been removed on the pentium. Control registers are CR0 to CR4, Debug registers are DR0 to DR7, test registers are TR3 to TR7 and the protected mode segmentation registers are GDTR (Global Descriptor Table Register), IDTR (Interrupt Descriptor Table Register), LDTR (Local DTR), and TR.

February 19, 2022 0 comments
0 FacebookTwitterPinterestEmail
Blocks

Top listing blocks and reviews

by dnaadmin June 29, 2021
written by dnaadmin

Sometimes you need to compare courses, this block can help you to do this. You can also build top listings, top reviews, pros and cons blocks and much much more with bundled Gutencon extension in Rehub

With more than 2 million websites internationally, Hosting is one of the most popular hosting services in the industry. Our all-in-one solutions make website protection and reliability easy with free SSL, malware detection, automated security updates and 24/7 expert support. Track your visitor analytics, user comments and anything else happening on your website right from your Hosting dashboard. 

Choose from shared hosting to VPS and dedicated hosting plans all at affordable rates. Bluehost also has dedicated WordPress hosting plans. Add bookings, online ordering, customer chat windows and anything else you need to transform your website
into the ultimate can-do machine. Customize your website to your heart’s content with true design flexibility. No other builder lets you create and modify with such boundless creativity.


With more than 2 million websites internationally, Hosting is one of the most popular hosting services in the industry. Our all-in-one solutions make website protection and reliability easy with free SSL, malware detection, automated security updates and 24/7 expert support. Track your visitor analytics, user comments and anything else happening on your website right from your Hosting dashboard. 

Choose from shared hosting to VPS and dedicated hosting plans all at affordable rates. Bluehost also has dedicated WordPress hosting plans. Add bookings, online ordering, customer chat windows and anything else you need to transform your website
into the ultimate can-do machine. Customize your website to your heart’s content with true design flexibility. No other builder lets you create and modify with such boundless creativity.


With more than 2 million websites internationally, Hosting is one of the most popular hosting services in the industry. Our all-in-one solutions make website protection and reliability easy with free SSL, malware detection, automated security updates and 24/7 expert support. Track your visitor analytics, user comments and anything else happening on your website right from your Hosting dashboard. 

Choose from shared hosting to VPS and dedicated hosting plans all at affordable rates. Bluehost also has dedicated WordPress hosting plans. Add bookings, online ordering, customer chat windows and anything else you need to transform your website
into the ultimate can-do machine. Customize your website to your heart’s content with true design flexibility. No other builder lets you create and modify with such boundless creativity.

June 29, 2021 0 comments
0 FacebookTwitterPinterestEmail
Blocks

Step list block

by dnaadmin June 29, 2021
written by dnaadmin

Theme has a lot of ready Gutenberg blocks which can be used for Learning sites. Here is another helpful block – Itinerary. It’s made for booking sites, but you can use it also for making Course overviews. Here is example

June 29, 2021 0 comments
0 FacebookTwitterPinterestEmail
Blocks

How to blocks

by dnaadmin June 29, 2021
written by dnaadmin

Learning sites have some important blocks which you need to format content. How to blocks and FAQ blocks can give you some blocks for this. Both have also SEO schema to get better positions in google

June 29, 2021 0 comments
0 FacebookTwitterPinterestEmail
Interview

Binary Search in C++

by dnaadmin November 15, 2020
written by dnaadmin
#include<iostream>
using namespace std;
// A recursive binary search function. It returns
// location of x in given array arr[l..r] is present,
// otherwise -1
int binarySearch(int arr[], int l, int r, int x)
{
if (r >= l) {
int mid = l + (r - l) / 2;
// If the element is present at the middle
// itself
if (arr[mid] == x)
return mid;
// If element is smaller than mid, then
// it can only be present in left subarray
if (arr[mid] > x)
return binarySearch(arr, l, mid - 1, x);
// Else the element can only be present
// in right subarray
return binarySearch(arr, mid + 1, r, x);
}
// We reach here when element is not
// present in array
return -1;
}
int main(void)
{
int arr[] = { 2, 3, 4, 10, 40 };
int x = 10;
int n = sizeof(arr) / sizeof(arr[0]);
int result = binarySearch(arr, 0, n - 1, x);
(result == -1) ? cout << "Element is not present in array"
: cout << "Element is present at index " << result;
return 0;
}

#include<iostream>
using namespace std;
int binarySearch(int arr[], int num, int n)
{
int min = 0;
int max = n-1;
while (min <= max)
{
int mid = (max + (max - min)) / 2;
if (arr[mid] == num)
return mid;
if (arr[mid] > num)
{
max = mid - 1;
}
else
{
min = mid + 1;
}
}
return -1;
}
int main(void)
{
int arr[] = { 1, 2, 3, 4, 10, 40 };
int x = 10;
int n = sizeof(arr) / sizeof(arr[0]);
int result = binarySearch(arr, 10, n);
(result == -1) ? cout << "Element is not present in array"
: cout << "Element is present at index " << result;
return 0;
}
November 15, 2020 0 comments
0 FacebookTwitterPinterestEmail
Interview

Program to reverse a string

by dnaadmin November 14, 2020
written by dnaadmin

Write a program to reverse a string in C++

There are numerous ways to solve this problem. Let’s start with the simplest one – Using the inbuilt “reverse” function. In the example below, the string to be reversed is initialized within the program to a string variable “greeting”. As a challenge, you can try to implement by prompting the user to Enter the string to be reversed.

reverse() is a predefined function in header file algorithm. It is defined as a template in the above mentioned header file. It reverses the order of the elements in the range [first, last) of any container. The time complexity is O(n).  Click here to learn more about reverse().

 

#include <iostream>
#include <string>
using namespace std;
int main() {
string greeting = "Hello";
reverse(greeting.begin(), greeting.end());
cout << greeting << endl;
}



#include <iostream>
using namespace std;
int main() {
string greeting = "Hello";
int len = greeting.length();
int n=len-1;
for(int i=0;i<(len/2);i++){
//Using the swap method to switch values at each index
swap(greeting[i],greeting[n]);
n = n-1;
}
cout<<greeting<<endl;
}



#include <iostream>
using namespace std;
int main() {
string greeting = "Hello";
int len = greeting.length();
int n=len-1;
for(int i=0;i<(len/2);i++){
//Using temp to store the char value at index i so
//you can swap it in later for char value at index n
char temp = greeting[i];
greeting[i] = greeting[n];
greeting[n] = temp;
n = n-1;
}
cout<<greeting<<endl;
}



// A simple C++ program to reverse string using constructor
#include <iostream>
#include <string>
using namespace std;
int main() {
string str = "Hello";
//Use of reverse iterators
string rev = string(str.rbegin(), str.rend());
cout << rev << endl;
return 0;
}



// C++ Program to reverse a string without
// using temp variable
#include <iostream>
using namespace std;
// Function to reverse string and return revesed string
string reversingString(string str, int start, int end)
{
// Iterate loop upto start not equal to end
while (start < end)
{
// XOR for swapping the variable
str[start] ^= str[end];
str[end] ^= str[start];
str[start] ^= str[end];
++start;
--end;
}
return str;
}
int main()
{
string s = "HelloW";
int len = s.length();
cout << reversingString(s, 0, len-1);
return 0;
}



#include <iostream>
using namespace std;
// Recursive function to reverse a given string
// Note string is passed as reference parameter
void reverse(string &str, int k)
{
static int i = 0;
// if we have reached the end of the string
if (k == str.length())
return;
reverse(str, k + 1);
if (i <= k)
swap(str[i++], str[k]);
}
int main()
{
string str = "Hello";
reverse(str, 0);
cout << "Reverse of the given string is : " << str;
return 0;
}
November 14, 2020 0 comments
0 FacebookTwitterPinterestEmail
Interview

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target

by dnaadmin November 8, 2020
written by dnaadmin

Here is  a brute force solution:




#include <iostream> 
#include <vector> 
using namespace std;
class Solution { 
public: 
vector<int> twoSum(vector<int>& nums, int target)  {
 int n = nums.size(); 
for (int i=0;i<n;++i) 
for(int j=0;j<n;++j) if(i!=j) if (nums[i] + nums[j] == target) { vector<int> ret{ i,j };
 return ret;
 } 
} 
}; 
int main() 
{
 int target = 7;
 vector<int> nums{ 1,2,3,4 }; vector<int> ret; 
 Solution Sol1;
 ret = Sol1.twoSum(nums, target); 
 cout << "Solution is "; 
 for (auto i = ret.begin(); i != ret.end(); ++i) std::cout << *i << ' '; 
}
November 8, 2020 0 comments
0 FacebookTwitterPinterestEmail
  • 1
  • 2
  • 3
  • …
  • 7

Archives

  • February 2022
  • June 2021
  • November 2020
  • January 2019

Categories

  • Architecture
  • Backend
  • Basics
  • Blocks
  • Debugging
  • Device Drivers
  • Frontend
  • Guide
  • Interview
  • Network
  • Resources

Archives

  • February 2022
  • June 2021
  • November 2020
  • January 2019

Categories

  • Architecture
  • Backend
  • Basics
  • Blocks
  • Debugging
  • Device Drivers
  • Frontend
  • Guide
  • Interview
  • Network
  • Resources

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

About Me

About Me

Freelance Developer

My name is Brian, freelance developer based in London, UK. Welcome to my internet journal where I started my learning journey.

Keep in touch

Facebook Twitter Linkedin Youtube Github

Resources

  • All the “Truth” you need to know about “Truth Table”

    February 19, 2022
  • Registers & Computer Memory Primer for x86

    February 19, 2022
  • Top listing blocks and reviews

    June 29, 2021

Recent Posts

  • All the “Truth” you need to know about “Truth Table”

    February 19, 2022
  • Registers & Computer Memory Primer for x86

    February 19, 2022
  • Top listing blocks and reviews

    June 29, 2021
  • Step list block

    June 29, 2021
  • How to blocks

    June 29, 2021

Categories

  • Architecture (5)
  • Backend (6)
  • Basics (6)
  • Blocks (3)
  • Debugging (11)
  • Device Drivers (1)
  • Frontend (6)
  • Guide (6)
  • Interview (6)
  • Network (1)
  • Resources (6)

Sign Up for Weekly Newsletter

Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.

[rh_mailchimp action=”//fleek.us10.list-manage.com/subscribe/post?u=4b4bbda55bb6deb367e6f52d9&id=6b32851a5b” inputname=”b_4b4bbda55bb6deb367f52d9_6b32851a5b” flat=1 button=”Subscribe” placeholder=”Email address”]

Frontend

  • All the “Truth” you need to know about “Truth Table”

    February 19, 2022
  • Registers & Computer Memory Primer for x86

    February 19, 2022
  • Top listing blocks and reviews

    June 29, 2021
  • Step list block

    June 29, 2021

Subscribe Newsletter

  • Facebook
  • Twitter
  • Linkedin
  • Youtube
  • Email
  • Github
  • Stack-overflow

Read alsox

System Architecture & BIOS

November 2, 2020

Registers & Computer Memory Primer for x86

February 19, 2022

Lauterbach Basics Playlist

November 2, 2020

Shopping Cart

Close

No products in the cart.

Close