Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include(macro_defs.m)
- define(FALSE,0) !#define FALSE 0
- define(TRUE,1) !#define TRUE 1
- begin_struct(point) !struct point
- field(x,4)
- field(y,4)
- end_struct(point)
- begin_struct(dimension) !struct dimension
- field(width,4)
- field(height,4)
- end_struct(dimension)
- begin_struct(box) !struct box
- field(origin,align_of_point,size_of_point)
- field(size,align_of_dimension,size_of_dimension)
- field(area,4)
- end_struct(box)
- local_var
- var(result,4)
- var(first,align_of_box,size_of_box)
- var(second,align_of_box,size_of_box)
- fma: .asciz "Initial box values:\n"
- fmb: .asciz "Changed box values:\n"
- fmc: .asciz "first"
- fmd: .asciz "second"
- string: .asciz "Box %s origin = (%d,%d) width = %d height = %d"
- area: .asciz " area = %d\n"
- begin_main
- add %fp, first, %o0
- st %o0, [%sp + struct_s]
- call newBox
- nop
- add %fp, second, %o0
- st %o0, [%sp + struct_s]
- call newBox
- nop
- set fma, %o0
- call printf
- nop
- set fmc, %o0
- add %fp, first, %o1
- st %o1, [%sp+struct_s]
- call printBox
- nop
- set fmd, %o0
- add %fp, second, %o1
- st %o1, [%sp+struct_s]
- call printBox
- nop
- add %fp, first, %o0
- add %fp, second, %o1
- call equal
- nop
- ld [%sp+result], %l0
- cmp %l0, TRUE
- bne next
- nop
- add %fp, first, %o0
- mov -5, %o1
- mov 7, %o2
- call move
- nop
- add %fp, second, %o0
- mov 3, %o1
- call expand
- nop
- next:
- set fmb, %o0
- call printf
- nop
- set fmc, %o0
- add %fp, first, %o1
- st %o1, [%sp+struct_s]
- call printBox
- nop
- set fmd, %o0
- add %fp, second, %o1
- st %o1, [%sp+struct_s]
- call printBox
- nop
- end_main
- newBox: save %sp, (-92 + last_sym) & -8, %sp
- ld [%fp+struct_s], %o0
- st %g0, [%o0+box_origin+point_x]
- st %g0, [%o0+box_origin+point_y]
- mov 1, %o1
- st %o1, [%o0+box_size+dimension_width]
- st %o1, [%o0+box_size+dimension_height]
- st %o1, [%o0+box_area]
- ret
- restore
- move: save %sp, (-92 + last_sym) & -8, %sp
- ld [%i0+box_origin+point_x], %l0
- ld [%i0+box_origin+point_y], %l1
- add %l0, %i1, %l0
- add %l1, %i2, %l1
- st %l0, [%i0+box_origin+point_x]
- st %l1, [%i0+box_origin+point_y]
- ret
- restore
- expand: save %sp, (-92+last_sym) & -8, %sp
- ld [%i0+box_size+dimension_width], %l0
- ld [%i0+box_size+dimension_height], %l1
- smul %l0, %i1, %l0
- smul %l1, %i1, %l1
- smul %l0, %l1, %l2
- st %l0, [%i0+box_size+dimension_width]
- st %l1, [%i0+box_size+dimension_height]
- st %l2, [%i0+box_area]
- ret
- restore
- printBox: save %sp, (-92+last_sym) & -8, %sp
- set string, %o0
- mov %i0, %o1
- ld [%fp+struct_s], %l0
- ld [%l0+box_origin+point_x], %o2
- ld [%l0+box_origin+point_y], %o3
- ld [%l0+box_size+dimension_width], %o4
- ld [%l0+box_size+dimension_height], %o5
- call printf
- nop
- set area, %o0
- ld [%l0+box_area], %o1
- call printf
- nop
- ret
- restore
- equal: save %sp, (-92+last_sym) & -8, %sp
- ld [%fp+result], %l2
- mov FALSE, %l2
- st %l2, [%fp+result]
- ld [%i0+box_origin+point_x], %l0
- ld [%i1+box_origin+point_x], %l1
- cmp %l0, %l1
- bne return
- nop
- ld [%i0+box_origin+point_y], %l0
- ld [%i1+box_origin+point_y], %l1
- cmp %l0, %l1
- bne return
- nop
- ld [%i0+box_size+dimension_width], %l0
- ld [%i1+box_size+dimension_width], %l1
- cmp %l0, %l1
- bne return
- nop
- ld [%i0+box_size+dimension_height], %l0
- ld [%i1+box_size+dimension_height], %l1
- cmp %l0, %l1
- bne return
- nop
- ld [%fp+result], %l2
- mov TRUE, %l2
- st %l2, [%fp+result]
- return: ret
- restore
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement