|
@@ -0,0 +1,90 @@
|
|
|
|
|
+SYS_EXIT equ 1
|
|
|
|
|
+SYS_READ equ 3
|
|
|
|
|
+SYS_WRITE equ 4
|
|
|
|
|
+STDIN equ 0
|
|
|
|
|
+STDOUT equ 1
|
|
|
|
|
+SYS_IOCTL equ 54
|
|
|
|
|
+
|
|
|
|
|
+section .bss
|
|
|
|
|
+ sz RESB 4 ; 4 byte for window size
|
|
|
|
|
+ num resb 4 ;4 byte for ascii numbers
|
|
|
|
|
+
|
|
|
|
|
+section .data
|
|
|
|
|
+ ha db 0 ;hundreds
|
|
|
|
|
+ ta db 0 ;tens
|
|
|
|
|
+
|
|
|
|
|
+section .text
|
|
|
|
|
+ global _start
|
|
|
|
|
+
|
|
|
|
|
+_start:
|
|
|
|
|
+
|
|
|
|
|
+ ; print rows
|
|
|
|
|
+
|
|
|
|
|
+ mov ecx, '7' ;rows in ecx
|
|
|
|
|
+
|
|
|
|
|
+hundreds:
|
|
|
|
|
+ mov ebx, 100
|
|
|
|
|
+ cmp ecx, ebx ;check if above 100
|
|
|
|
|
+ js bla
|
|
|
|
|
+ jae inchundred ;jump to increment hundreds if needed
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+bla:
|
|
|
|
|
+ mov eax,[ha] ;hundred count to eax
|
|
|
|
|
+ add eax, '0' ;convert to ascii
|
|
|
|
|
+ mov [num+0], eax ;move to first byte of num string
|
|
|
|
|
+
|
|
|
|
|
+tens:
|
|
|
|
|
+ cmp ecx, 0xa ;check if above 10
|
|
|
|
|
+ jge inctens ;jump to increment tens if needed
|
|
|
|
|
+
|
|
|
|
|
+ mov eax,[ta]
|
|
|
|
|
+ add eax, '0'
|
|
|
|
|
+ mov [num+1], eax
|
|
|
|
|
+
|
|
|
|
|
+ mov eax, ecx
|
|
|
|
|
+ add eax, '0'
|
|
|
|
|
+ mov [num+2], eax
|
|
|
|
|
+ mov [num+3], byte 0xa ;linebreak
|
|
|
|
|
+
|
|
|
|
|
+ mov eax, SYS_WRITE
|
|
|
|
|
+ mov ebx, STDOUT
|
|
|
|
|
+ mov ecx, num
|
|
|
|
|
+ mov edx, 4
|
|
|
|
|
+ int 0x80
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ ;print hundreds
|
|
|
|
|
+ ;mov eax, [ha]
|
|
|
|
|
+ ;add eax, '0'
|
|
|
|
|
+ ;mov[ha], eax
|
|
|
|
|
+
|
|
|
|
|
+ ;mov eax, SYS_WRITE
|
|
|
|
|
+ ;mov ebx, STDOUT
|
|
|
|
|
+ ;mov ecx, ha
|
|
|
|
|
+ ;mov edx, 1
|
|
|
|
|
+ ;int 0x80
|
|
|
|
|
+
|
|
|
|
|
+ ; print cols
|
|
|
|
|
+
|
|
|
|
|
+ ;mov eax, SYS_WRITE
|
|
|
|
|
+ ;mov ebx, STDOUT
|
|
|
|
|
+ ;mov ecx, sz+2
|
|
|
|
|
+ ;mov edx, 3
|
|
|
|
|
+ ;int 0x80
|
|
|
|
|
+
|
|
|
|
|
+exit:
|
|
|
|
|
+ ;exit
|
|
|
|
|
+ mov eax, 1
|
|
|
|
|
+ mov ebx, 0
|
|
|
|
|
+ int 0x80
|
|
|
|
|
+
|
|
|
|
|
+inchundred:
|
|
|
|
|
+ inc byte [ha] ;increment hundreds
|
|
|
|
|
+ sub ecx, 0x64
|
|
|
|
|
+ jmp hundreds
|
|
|
|
|
+
|
|
|
|
|
+inctens:
|
|
|
|
|
+ inc byte [ta] ;increment tens
|
|
|
|
|
+ sub ecx, 0xa
|
|
|
|
|
+ jmp tens
|