Re: Article about HLA on Linux Journal's website
- From: "Evenbit" <nbaker2328@xxxxxxxxxxx>
- Date: 30 Jun 2005 01:20:56 -0700
Herbert Kleebauer wrote:
> dunric@xxxxxxxxx wrote:
> >
> > It's about HLA and assembly language.
>
> Are you sure? I just looked at the code and I think
> this is batch programming and not assembly programming.
> Ok, I had to insert a few "::" and "call", but then
> cmd.exe executes it without any problem:
>
Obee-tabee... that was easy to convert to batch b/c his example only
displayed text on the screen. But try something a little more
elaborate like:
\|||/
(o o)
+-oooO--(_)-------+
| |
| b2h.hla |
| |
+------------Ooo--+
|__|__|
|| ||
ooO Ooo
program b2h;
#include ("stdlib.hhf")
var
hIn :dword; // input file handle
hOut :dword; // output file handle
bBin :char; // input byte
bHex :char[2]; // output text
begin b2h;
arg.c(); // check command line arguments
if ( eax = 3 ) then
try
fileio.open(arg.v(1),fileio.r);
mov(eax, hIn);
fileio.openNew(arg.v(2));
mov(eax, hOut);
xor(edx, edx); // column count
forever
lea(ebx, bBin);
fileio.read(hIn, [ebx], 1);
if (fileio.eof(hIn)) then
break; // exit the loop at EOF
endif;
lea(ecx, bHex);
xor(eax, eax); // clear the workbench
mov([ebx], al);
push(ax);
shr(4, al); // convert H.O. nibble
if (al < 10) then
add($30, al); // '0 - 9'
else;
add($37, al); // 'A - F'
endif;
mov(al, [ecx]);
pop(ax);
and($0F, al); // convert L.O. nibble
if (al < 10) then
add($30, al); // '0 - 9'
else;
add($37, al); // 'A - F'
endif;
mov(al, [ecx + 1]);
fileio.write(hOut, [ecx], 2);
mov($20, al);
fileio.putc(hOut, al); // add ' ' spacing
inc(edx);
if (edx = 16) then // check for last column
xor(edx, edx);
mov($0D, al);
fileio.putc(hOut, al); // add CR/LF
mov($0A, al);
fileio.putc(hOut, al);
endif;
endfor;
mov($0D, al);
fileio.putc(hOut, al);
mov($0A, al);
fileio.putc(hOut, al);
fileio.close(hIn);
fileio.close(hOut);
exception(ex.FileOpenFailure);
stdout.put( "File Open Failure!" nl );
endtry;
else;
stdout.puts( nl "Binary File --> Hex File Convertor" nl nl );
stdout.puts( "USAGE: b2h <binfile> <hexfile>" nl nl);
stdout.puts( "EXAMP: b2h notepad.exe notepad.txt" nl );
stdout.puts( " OR: b2h con: myhex.txt" nl );
stdout.puts( " {use CTRL-C to exit}" nl );
endif;
end b2h;
Nathan.
.
- Follow-Ups:
- Re: Article about HLA on Linux Journal's website
- From: Herbert Kleebauer
- Re: Article about HLA on Linux Journal's website
- References:
- Article about HLA on Linux Journal's website
- From: dunric
- Re: Article about HLA on Linux Journal's website
- From: Betov
- Re: Article about HLA on Linux Journal's website
- From: dunric
- Re: Article about HLA on Linux Journal's website
- From: Herbert Kleebauer
- Article about HLA on Linux Journal's website
- Prev by Date: Re: Article about HLA on Linux Journal's website
- Next by Date: Re: Article about HLA on Linux Journal's website
- Previous by thread: Re: Article about HLA on Linux Journal's website
- Next by thread: Re: Article about HLA on Linux Journal's website
- Index(es):
Relevant Pages
|