SAP – 1 Processor

Architecture Introduction

The Simple-As-Possible (SAP)-1 computer is a very basic model of a microprocessor. The SAP-1 design contains the basic necessities for a functional Microprocessor. Its primary purpose is to develop a basic understanding of how a microprocessor works, interacts with memory and other parts of the system like input and output. The instruction set is very limited and is simple.

1537093478378.png

1. Program Counter

The program is stored at the beginning of the memory with the first instruction at binary address 0000, the second instruction at 0001, the third at address 0010 and so on. The program counter which is part of the control unit, counts from 0000 to 1111. Its job is to send to the memory the address of the next instruction to be fetched and executed. It does this as mentioned in the next paragraph.

The program counter is reset to 0000 before each computer run. When the computer run begins, the program counter sends the address 0000 to the memory. The program counter is then incremented to get 0001. After the first instruction is fetched and executed, the program counter sends address 0001 to the memory. Again the program counter is incremented. After the second instruction is fetched and executed, the program counter sends address 0010 to the memory. So this way, the program counter keeps track of the next instruction to be fetched and executed.

The program counter is like someone pointing a finger at a list of instructions saying do this first, do this second, do this third, etc. This is why the program counter is called a pointer; it points to an address in memory where the instruction or data is being stored.

Read More »

Run MASM on Linux

In this blog, I am going to show you the step by step method to run masm on linux.let’s start.

Dosbox Installation:

First thing you have to do is to instal dosbox on linux via command:

sudo apt install dosbox

That’s it now you can run your masm program on linux.

 

Run MASM:

So, let me show you a demo of how to run the programs using dosbox.Click here
to download masm folder in your system.(This link will direct you to my github repo.From where you can clone masm. ).

Now run the dosbox by typing simple command in your terminal:

dosbox

Mount the location where the downloaded masm folder is available.My masm folder is in Documents.

mount c /home/yourusername/Documents/masm

This will be the output.Screenshot from 2018-09-15 15-01-35

When it is mounted and change your present working directory to C. To do this simple type this command in dosbox:

Read More »

Python Virtual Environment on Linux

In this blog, you can learn how to install python and pip globally on your linux system and also install the python virtual environment.

Python Installation:

On linux python is installed as default python2.7.
First you have to install python3.6 or the latest version by using ppa repository. This is  done by typing this command on terminal.

sudo add-apt-repository ppa:jonathonf/python-3.6

Then update and install the python3.6.

sudo apt update
sudo apt install python3.6

Now python3.6 is installed in your system but you have to set python3.6 as your default. You can do this by running following command.

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

Finally switch between the two python versions for python via command:

sudo update-alternatives --config python3

Following output come on your screen:

There are 2 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.6   2         auto mode
  1            /usr/bin/python2.7   1         manual mode
  2            /usr/bin/python3.6   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 2

You can check your version via command:

Read More »

Setting up Anaconda Environment On Linux

In this blog I am going to show you the Installation process and creation of your own conda environment.So let’s start.

Installation:

First thing you have to do is click here to open a link and select a version of anaconda that you want to install on your system.You can simply click on it to download or you can download it via command:

wget https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh

After downloading bash script of anaconda you can run this script via command:

bash Anaconda3-5.2.0-Linux-x86_64.sh

Then installation of Anaconda is started:

Welcome to Anaconda3 5.2.0

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>

You’ll receive the following output:

Anaconda End User License Agreement
===================================

Copyright 2015, Anaconda, Inc.

All rights reserved under the 3-clause BSD License:

Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:

  * Redistributions of source code must retain the above copyright notice, this 
list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above copyright notice, th
is list of conditions and the following disclaimer in the documentation and/or o
ther materials provided with the distribution.
  * Neither the name of Anaconda, Inc. ("Anaconda, Inc.") nor the names of its c
ontributors may be used to endorse or promote products derived from this softwar
e without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WA
RRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
--More--

Read More »

Creating New Activity and Transferring Data

How to create new activities and transfer data from one activity to another activity?

Intro

So far we are working on a single screen on a single activity.
How we start one activity from another activity, instead of having activities directly call each other, android facilitates communication using message object called intent.Intents let an app request that an action take place, that will be any thing i.e start a new activity ,open a gallery or open a camera etc.Intents is like envalop, each one include who, component you want to deliver to.component recieve this and read it. And open the intent.

Working

First start a new project and open the activity_main.xml and make linear layout and inside linear layout make EditText and button and give them proper ID’s .And also set dimens.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">
    
    

Read More »