gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control systemdiff --git a/samples-with-macros/gcd-predef.asm b/samples-with-macros/gcd-predef.asm
--- /dev/null
@@ -0,0 +1,98 @@
+.model small\r
+data segment\r
+ strNZD db " "\r
+data ends\r
+;#macro-commands-start\r
+; print a string on screen\r
+print_str macro s\r
+ push ax\r
+ push dx \r
+ mov dx, offset s\r
+ mov ah, 09\r
+ int 21h\r
+ pop dx\r
+ pop ax\r
+endm\r
+\r
+\r
+; write a single char\r
+print_char macro c\r
+ push ax \r
+ push dx\r
+ mov ah, 02\r
+ mov dl, c\r
+ int 21h\r
+ pop dx\r
+ pop ax\r
+endm\r
+\r
+; finish the execution\r
+end_execution macro\r
+ mov ax, 4c02h\r
+ int 21h\r
+endm \r
+\r
+; Konvertovanje broja u string\r
+inttostr macro num1 str1\r
+ push ax\r
+ push bx\r
+ push cx\r
+ push dx\r
+ push si\r
+ mov ax, num1\r
+ mov dl, '$'\r
+ push dx\r
+ mov si, 10\r
+petlja2:\r
+ mov dx, 0\r
+ div si\r
+ add dx, 48\r
+ push dx\r
+ cmp ax, 0\r
+ jne petlja2\r
+ \r
+ mov bx, offset str1\r
+petlja2a: \r
+ pop dx\r
+ mov [bx], dl\r
+ inc bx\r
+ cmp dl, '$'\r
+ jne petlja2a\r
+ pop si \r
+ pop dx\r
+ pop cx\r
+ pop bx\r
+ pop ax \r
+endm\r
+\r
+print_num macro num\r
+ inttostr num,strNZD\r
+ print_str strNZD\r
+endm\r
+;#macro-commands-end\r
+\r
+.code \r
+\r
+start:\r
+ mov ax,12\r
+ mov bx,8\r
+\r
+compare: \r
+ cmp ax,bx\r
+ je exit ;exit since they're equal\r
+ ja greater\r
+ sub bx,ax\r
+ jmp compare\r
+\r
+greater:\r
+ sub ax,bx\r
+ jmp compare\r
+\r
+exit:\r
+;exit out of the program\r
+ print_num ax\r
+; print out a result\r
+ end_execution\r
+\r
+.stack\r
+end start\r