CHAPTER 6

HLA LANGUAGE CODE EXAMPLE.

The previous chapter introduced Assembly Language macros that can be used to create equivalents of higher level language statements.

This effectively results in the creation of new programming languages, which are referred to as HLA Languages ( 'High Level Assembly'). I use the plural because there can be many different HLA Languages, depending on the particular set of HLL type statements that might be created by a particular programmer, who can create macros to suit his own preferences, as desired. As a matter of interest and comparison, the following code is the same as the previous Assembly Language code example, that can be used for converting a binary number to character codes, or character codes to a binary number, but is written in the HLA Language I use if writing code.

I first briefly explain what all the HLA statements are, that are used in the code, and what they mean, and then present the code, to show how they can make the code shorter and easier to read than the original code in pure Assembly Language.

If you compare the length of the code here with the same in pure Assembly Language, in Chapter 4, you can see that the code here is about half the length of the pure Assembly Language version.

The HLA macros used are:

zero.d A,B,C…
means set A and B and C… etc. all to zero. The '.d' means A, B, C are dwords

until.d '>', A,B
means loop through the code, between until and end.until, until A is greater than B. until.d means A and B are dwords.

until.b '=', A,B
means loop through the code, between until and end.until, until A is equal to B. until.b means A and B are byte sized

until.b '==&', A,B, C,D…
means loop through the code, between until and end.until, until A=B and C=D… etc. until statements can be nested within one another

set.d '==&', A,B C,D…
means set A=B and C=D... etc.

set.b '=', A,B
means set A=B

inc.d A,B,C…
means increase dwords A, and B, and C… etc. by 1

call. Procedure, if.b, '=', A,B
means call the Procedure if A=B. if.b means A and B are byte sized (if.d, for example, would mean they were dwords).

________________

THE HLA CODE:

NUMBER_
   .GetCharsFromNumber:
        jmp .start
   .GetNumberFromChars:
        zero.d ebx,ecx,edx
        mov esi,NUMBER.Chars.in
   until.d '>',ebx,3
        until.b '=',[esi+ebx],[NUMBER.Chars.Src+ecx]
           inc ecx
        end.until
           mov NUMBER.Numerical.Digits.in+ebx],cl
           inc ebx
           mov ecx,0
   end.until
           mov [NUMBER.in],dword 0FFFFFFFFh
.start:
        set.d '==&',esi,NUMBER.Numerical.Digits.out, edi,NUMBER.Numerical.Digits.in
           zero.d ecx, [NUMBER.Out], [esi]
        until.b '==&',[esi],[edi], [esi+1],[edi+1], [esi+2],[edi+2], [esi+3],[edi+3]
        or.until.d '=',[NUMBER.Out],[NUMBER.in]
           inc.d [NUMBER.Out], [esi+3]
           call. .digit2, if.b, '=',[esi+3],10
end.until
        call. .get_output_chars, if.d, '=',[NUMBER.Out],[NUMBER.in]
        ret
.get_output_chars:
   until.d '>',ebx,3
           mov cl,[esi+edx]
           set.b '=',[NUMBER.Chars.out+ebx],[NUMBER.Chars.Src+ecx]
           inc.d ebx, edx
           mov ecx,0
   end.until
           ret
.digit2:
           mov [esi],byte 0
           inc byte [esi-1]
           call. .digit3, if.b, '=', [esi-1],10
           ret
digit3:
           mov [esi-1],byte 0
           inc byte [esi-2]
           call. .digit4, if.b, '=', [esi-2],10
           ret
.digit4:
           mov [esi-2],byte 0
           inc byte [esi-3]
           ret

                  Part I: Part I Introduction
                  Chapter 1: Binary numbers, code, and procedures
                  Chapter 3: Assembly Language
                  Chapter 4: Assembly Language Code example
                  Chapter 5: Macros and HLA
                  Chapter 6: HLA code example
                  Chapter 7: The Windows operating system
                  Chapter 8: Data Structures
                  Chapter 9: How to Create a Windows Program
                  Chapter 10: How to Create an Exe File
                  Chapter 11: Structured Programming and OOP
                  Part II: Part II Introduction
                  Chapter 12: Debugging a Windows Program Code
                  Chapter 13: Painting the Window Client Area
                  Chapter 14: Creating Window Menus
                  Chapter 15: How to Create Toolbars
                  Chapter 16: How to Create Popup Menus
                  Chapter 17: About the Windows Clipboard
                  Chapter 18: How to Create Bitmaps
                  Chapter 19: Icons and the Ico Format
                  Chapter 20: Common Dialog Boxes
                  Chapter 21: Working with Files
                  Chapter 22: Scrollbars and Scrolling
                  Chapter 23: How to Send Data to the Printer
                  Chapter 24: Miscellaneous Topics

© Alen, August 2013
alen@alenspage.net


Material on this page may be reproduced
for personal use only.