; Listing 4-7
;
; A simple bubble sort example
;
; Note: This example must be assembled
; and linked with LARGEADDRESSAWARE:NO


        option  casemap:none

nl      =       10
maxLen  =       256
true    =       1
false   =       0

ary4    typedef ptr byte

        .const
ttlStr  byte    "Listing 4-5", 0
ary     word    1, 2, 3, 4

        
        .data
        
student   struct
sName     byte  64 dup (?)  ;"Name" is a MASM reserved word
Major     word  ?
SSN       byte  12 dup (?)
Midterm1  word  ?
Midterm2  word  ?
Final     word  ?
Homework  word  ?
Projects  word  ?
student   ends

John    student {}
sss     student 4 dup ({})


x       = 123456789abcdefh
a       = high x
b       = highword x
d       = high32 x
e       = lengthof ttlStr
f       = lengthof ary
g       = low x
h       = lowword x
i       = low32 x


        
        .code
        externdef printf:proc
        
        

; Return program title to C++ program:

         public getTitle
getTitle proc
         lea rax, ttlStr
         ret
getTitle endp

; Here is the "asmMain" function.



        
        public  asmMain
asmMain proc

; "Magic" instruction offered without
; explaination at this point:

        sub     rsp, 40

	mov	ax, [rbx].student.Final

        add     rsp, 40
        ret     ;Returns to caller
asmMain endp
        end