40 Reusable Code Snippet Topics
Remove Filter
|
|
For those interested in operating system development, this snippet tests status of A20. It is the line that allows memory beyond 1 meg to be addressed, otherwise it will just wrap around which some applications and versions of DOS depend on. My bootloader **MBR1_44** has switched system to protected (*32 … |
|
I, and many others, desired a "switch" keyword in Python. For me it was to a desire to make some of my code more compact and readable, as I often have many user selected options for the code to weed through. So I set off on a journey to figure … |
|
This will take a value in EAX or AX, convert to ASCII hex with optional padding and upper or lower case This example would yield "---fc103a" push word 0x222d ; 32 bit conversion, padd output with '-' push word ASCPntr ; Pointer to end of conversion buffer push 0xfc103a call … |
|
This is a special purpose boot loader for a system I've called Proto-Sys. Eventually it is going to become a 64 bit application that will encompass all the resources to hook into drivers, benchmark code and optomize algorithms. Synopsis: * Preserve registers as they were passed by BIOS * Create … |
|
This is a program I wrote for my x86 assembly class which is basically the Spade Invaders game in all its glory. It uses Irvine32.inc which came with the textbook. |
|
One of the more common functions in any language is conversion of an integer to a string. This implementation, which demonstrates not only the common function activation record format but also a simple recursive function, was written in response to a recent question in which the OP posted an incomplete … |
|
This is a program I wrote for my x86 assembly class which generates matrices, multiplies them, and computes how long the arithmetic took. It uses Irvine32.inc which came with the textbook. |
|
**NOTE** This code won't work at the application level. It directly addresses memory at 0xB8000 which will result in a segfault at the application level. This code must be part of an OS or an application in a not-so-secure operating system like DOS, where applications can directly address any part … |
|
Hey guys.. need some help with this; I'm pulling my hair out.. i've trawled these boards but can't find anything that answers my question. I, like many others before me (so it seems!) am trying to create a program to check for a palindrome.. this is what I have so … |
|
This code will not work on EMU8086 or any processor prior to 80286. Line 40 would need to be changed. |
|
I bet all Computer Science related courses would learn low level or machine level languanges in due time and in our university we used the portable 80x86 assembler NASM for our Assembly code So here's my experimentation on how to use "functions" and recursion using a Fibonacci Solver as a … |
|
Figured I've been working on material for a while and would throw these up for everyone that needs them in the future to use. It's very simple implementation; if I get enough people asking me to, I will write the methods for each of the instructions so you don't have … |
|
An integer is loaded in from memory. ran through two loops to determine the tens place and the ones place. Integer is stored back to memory and displayed. Example #98 Tens place -->9 Ones place -->8 :) |
|
Hey people. What I'm trying to do is get a String input from the user. And then displaying that string. I have no idea how to do it. I have most of the code figured out except that one part. Any help will be greatly appreciated! Thanks!! (By the way … |
|
Aslam o Alikum to all, here is my code to get and change the attributes of a txt file. I want to change the hidden attribute of file. In this code, when i get attribute of file, the number 20 (100000) is returned in cx. I changed this number to … |
|
Assembles under NASM 16-bit, invoke INT 0x65 to display message. |
|
this code was written by me for my projects. all it does is increments by 1 the string which is passed to the function. if you have any improvements to my code ill be glad to hear from you ;) |
|
Compile this with NASM16 (Must be compiled in .COM format!) It will display all 256 colors usable by the BIOS in a neat rectangle that contains 16 columns, 17 rows (Just counted, it may be different). KNOWN BUGS: If you enter FULLSCREEN or run this program from a DOS operating … |
|
This procedure dispatches application defined event handlers and alternately executes default process for both standard or sub/super classed windows. Map is defined as follows. In most cases I define this table in .data, but in can be in .const also. I choose writeable memory as application can redefine characteristics. [code] … |
|
This is a program I wrote for my x86 assembly class which computes the sum of n numbers. It uses Irvine32.inc which came with the textbook. |
|
This is somewhat a simple project I wrote by getting help from google groups I always recommend. assemble this code using this command: [QUOTE]nasm -o 1.com 1.asm[/QUOTE] |
|
compile using A86 assembler however you can adapt it for any other one easily... It just draws out a 3D like shape. It was annoying to get the angles right but suggestions on improvement to code is appreciated. :) Adequately commented so it is understandable not fully as it is … |
|
First it is in RosAsm style. Sorry I am addicted to its simplicity of use. The Proc is called from Dialog initiation [CODE] [Counter:D$ 0] ; Call for the first ToolTip Call SetTTip D$hdlg, ; H Dialog Handle of Dialog or Window 1, ; Tool tip number ID 1, ; … |
|
This is a very simple program that uses text mode to display a boucing "ball." The ball is just a character that moves across the screen, erasing all in its path. It is coded to work like a screensaver, so the program ends when any key is hit. NOTE: I … |
|
I use GetTickCount in a lot of my applications, so I built this snippet to convert to hours minutes and seconds. Leading extraneous data is excluded from output. |
|
User can enter an ascii string of up to 48 characters consisting of 1's or 0's, with randomly interspersed whitespace. IE: [B]1011111001011110 [/B]will be evaulated equally to [B][1011][111....cc001cccx01 111hhhh0 [/B]Algorithm parses from right to left so will be truncated at 16 position Purpose is to give all those still programming … |
|
[LEFT]This is a program I wrote for my x86 assembly class which revolves a "roulette wheel" around. Wait about a minute and it will eventually slow down to a stop. It uses Irvine32.inc which came with the textbook.[/LEFT] |
|
This is a program I wrote for my x86 assembly class which bounces an ASCII ball across the screen. It uses Irvine32.inc which came with the textbook. |
|
FASM can output an executable PE directly, but sometimes you want to output an object file for linking with modules in other languages. The following program can be used to link with the C library of the GCC compiler with the following commands: C:\>fasm hello.asm hello.obj C:\>gcc hello.obj -o hello.exe … |
|
Some languages are hard to get started in. FASM appears to be one of these languages because the documentation is not detailed enough for a beginner. That's a shame because FASM is (in my opinion) one of the better assemblers. The following snippet is a simple Hello, world! program which … |
The End.