Monday, 26 May 2008
Sunday, 25 May 2008
C: Hello, World!
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
#include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }
Labels:
C,
Hello World
Thursday, 1 May 2008
Java: generating a DOS executable
By incrementally changing instructions in an assembly language, it is possible to build up a picture of how the bytes relate to the assembly instructions (without going to the trouble of actually reading the documentation). Note that, for these trivial examples at least, there is no difference between the binaries generated by NASM and the equivalent MS Debug instructions.
Labels:
assembler,
DOS,
Hello World,
Java
Assembler: Hello, World! [2]
NASM version 0.98.39 compiled on Feb 25 2005
DOS, 16bit, x86
Compare and contrast with the debug.exe version.
DOS, 16bit, x86
;syntax expected by NASM ;DOS, x86, 16bit org 100h ;start at address 100 mov ax,0200h ;AH=2 mov dx,0048h ;'H' int 21h ;int 21,2 (print char) mov dx,0065h ;'e' int 21h mov dx,006Ch ;'l' int 21h mov dx,006Ch ;'l' int 21h mov dx,006Fh ;'o' int 21h mov dx,002Ch ;',' int 21h mov dx,0020h ;' ' int 21h mov dx,0057h ;'W' int 21h mov dx,006Fh ;'o' int 21h mov dx,0072h ;'r' int 21h mov dx,006Ch ;'l' int 21h mov dx,0064h ;'d' int 21h mov dx,0021h ;'!' int 21h int 20h ;int 20 (terminate)
Compare and contrast with the debug.exe version.
Labels:
assembler,
DOS,
Hello World,
NASM
Assembler: using debug.exe to write DOS programs
C:\WINDOWS\system32\debug.exe
Windows (XP) still comes with Debug.
C:\test>DEBUG -a 0C8A:0100 mov ax,0200 0C8A:0103 mov dx,0041 0C8A:0106 int 21 0C8A:0108 int 20 0C8A:010A -h 010A 0100 020A 000A -n PCHAR.COM -rcx CX 0000 :000A -w Writing 0000A bytes -q C:\test>PCHAR.COM A
Assembler: Hello, World!
DOS, x86, 16bit, debug.exe
mov ax,0200 mov dx,0048 int 21 mov dx,0065 int 21 mov dx,006C int 21 mov dx,006C int 21 mov dx,006F int 21 mov dx,002C int 21 mov dx,0020 int 21 mov dx,0057 int 21 mov dx,006F int 21 mov dx,0072 int 21 mov dx,006C int 21 mov dx,0064 int 21 mov dx,0021 int 21 int 20
Labels:
assembler,
debug.exe,
DOS,
Hello World,
x86
Subscribe to:
Posts (Atom)