MASM Port for Test::More

agent on 2005-11-05T05:50:07

The upcoming CPAN module, Test::Masm::Dos, will be a MASM port for the excellent Test::More module on Perl's land. The approach is to give special meanings to MASM comments so that we can write something like mov ax, 0ffffh ; is ax, -1, "Test a negative number"; directly in the context of 16-bit MASM source code. The implementation for these smart comments is straightforward too -- expand each comment with a piece of assembly code that implements exactly what the comment says. Hence most of the amazing power the Perl QA Group owns can be brought to the poor 16-bit MASM, a legacy MS-DOS assembly language developed by Microsoft.

Here is a complete (thought still trivial) example: ; foo.asm code segment assume cs:code start: ; tests => 5; mov ax, 1011011B inc ax ; is ax, 91; mov cx, 5 next: ; say "# cx = ", cx; ; ok cx <= 5, "cx is ok" loop next ; summarize; mov ax, 4c00h int 21h code ends end start Then we could feed it to my masmt script: masmt -o ~foo.asm foo.asm where ~foo.asm is a temporary program with all the smart comments expanded by corresponding assembly instructions. So now we can assemble this to an executable named ~foo.exe, which is a MASM tester that produces TAP report!

At this point, I've only implemented the "say" comment. However, my classmates and I have already found it very helpful, especially when debugging our assembly programs. You know, it's really a painful experience to do even simple I/O in MASM!

With smart comments in hand, we can easily realize our dreams of applying Perl's debugging strategy to MASM: tweak, run, and tweak, run!


Re:

Aristotle on 2005-11-06T03:12:28

You are a sick, sick man. :-)