Skip to content

Instantly share code, notes, and snippets.

@web3author
web3author / factorial_8086.asm
Created August 26, 2023 00:33
Program to calculate factorial using looping
; Program to calculate factorial using looping
NUM: DW 0x6 ; calculate factorial of 6
RESULT: DW 0 ; place to store the reult
; actual entry point of the program
start:
MOV CX,word NUM ; move number into cx
MOV AX, 0x1 ; initialize accumulator with 1
NOTZEROLOOP: ; label to jump back to
MUL CX ; multiple by the number
@web3author
web3author / lcm_8086.asm
Created August 26, 2023 00:32
Program to calculate LCM of two numbers
; Program to calculate LCM of two numbers
no1: dw 0x6 ; number 1
no2: dw 0x12 ; number 2
gcd: dw 0 ; place to store gcd
; actual entry point of the program
start:
mov ax, word no1 ; move number 1 in accumulatore
mov bx, word no2 ; move number 2 in register BX
@web3author
web3author / sum_8086.asm
Last active August 26, 2023 00:30
Program to add two word length numbers
; Program to add two word length numbers
OPR1: DW 0x6969 ; declare first number
OPR2: DW 0x0420 ; declare second number
RESULT: DW 0 ; declare place to store result
; actual entry point of the program
start:
MOV AX, word OPR1 ; move first number to AX
MOV BX, word OPR2 ; move second number to BX
CLC ; clear the carry flag
@web3author
web3author / factorial.asm
Created August 24, 2023 12:39
Program to calculate the factorial of a number
; Program to calculate the factorial of a number i.e. n!
; Finally, factorial will be stored in register A
; Load number for which factorial will be calculated, into register B
MOV B, 5
; Initialize accumulator with 1 (as factorial calculation will go from 1 to number)
MOV A, 1
; LOOP to calculate factorial
@web3author
web3author / compare.asm
Created August 24, 2023 12:38
Program to compare two numbers and find the greater number
; Program to compare two numbers and find the greater number
; Finally, greater number will be stored in register A
; Load first value in register A
MOV A, 47
; Load second value in register B
MOV B, 32
; Compare the values in registers A and B
@web3author
web3author / sum.asm
Created August 24, 2023 12:36
Program to calculate sum of two numbers
; Program to calculate sum of two numbers
; Finally, sum will be stored in register A
; Load first value in register A
MOV A, 10
; Load second value in register B
MOV B, 10
; Add contents of registers A and B, store result in A
@web3author
web3author / ethereum-rpc-api-calls.json
Created August 4, 2023 11:07
HTTP RPC calls collection for Thunder Client VS Code extension
{
"client": "Thunder Client",
"collectionName": "blockchain-interaction-commands",
"dateExported": "2023-08-04T07:57:26.934Z",
"version": "1.1",
"folders": [],
"requests": [
{
"_id": "b395a4c2-2365-4a5e-ab7b-eebe61ff918f",
"colId": "6ffd056b-4a07-42ed-894b-b8a43a517039",
@web3author
web3author / views.py
Last active March 23, 2023 10:26
Django webapp view file
# Import required libraries
from django.http import HttpResponse
from django.shortcuts import render
from web3 import Web3
# Initialize web3 connection
web3 = Web3(Web3.HTTPProvider('http://10.0.2.15:8545'))
# Define contract address and ABI (Application Binary Interface)
contract_address = '0x4235d917d3420BF5adf03aE5146701B87D179752'
@web3author
web3author / client.html
Created March 18, 2023 08:07
HTML template file for Django application (Client side interaction)
<html>
<head>
<title>numberStore - Client Side</title>
<script src="https://cdn.jsdelivr.net/npm/web3@1.5.2/dist/web3.min.js"></script>
<script>
const abi = [{"stateMutability": "nonpayable", "type": "function", "name": "setNumber", "inputs": [{"name": "_number", "type": "uint256"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "getNumber", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "storedNumber", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}];
const address = '0x4235d917d3420BF5adf03aE5146701B87D179752';
// Connect to MetaMask on page load
@web3author
web3author / server.html
Last active March 18, 2023 08:07
HTML template file for Django application (Server side interaction)
<html>
<head>
<title>numberStore - Server Side</title>
<script src="https://cdn.jsdelivr.net/npm/web3@1.5.2/dist/web3.min.js"></script>
<script>
// Connect to MetaMask on page load
window.addEventListener('load', async () => {
// Modern dapp browsers...
if (window.ethereum) {
window.web3 = new Web3(window.ethereum);