Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BITS 32
- section .data
- Spaces: db 32,32,32,32
- section .bss
- fahr: resd 1
- cels: resd 1
- current: resd 1
- upper: resd 1
- step: resd 1
- print: resd 1
- ncels: resd 1
- nfahr: resd 1
- section .text
- global _start
- _start:
- Initalize:
- mov eax,-100
- mov [fahr],eax
- mov [current],eax
- mov eax,20
- mov [step],eax
- mov eax,200
- mov [upper],eax
- PrimaryLoop:
- mov eax,0
- mov [ncels],eax
- mov [nfahr],eax
- mov eax,[current]
- mov [fahr],eax
- mov eax,[fahr]
- mov ebx,[upper]
- cmp eax,ebx
- jg Terminate
- DoMath:
- mov eax,[fahr]
- mov ebx,32
- sub eax,ebx
- mov ebx,5
- imul eax,ebx
- mov ecx,9
- mov edx,0
- cdq
- idiv ecx
- mov [cels],eax
- InsertStackMarker:
- mov eax,10000
- push eax
- CheckIfCelsIsNegative:
- mov eax,[cels]
- mov ebx,0
- cmp eax,ebx
- jl CelsIsNegative
- jmp PushCelsDigitsToStack
- CelsIsNegative:
- mov eax,1
- mov [ncels],eax
- mov eax,[cels]
- mov ebx,-1
- imul eax,ebx
- mov [cels],eax
- PushCelsDigitsToStack:
- mov eax,[cels]
- mov ebx,0
- cmp eax,ebx
- je GotAZero
- mov ecx,10
- mov edx,0
- cdq
- idiv ecx
- push edx
- mov [cels],eax
- jmp PushCelsDigitsToStack
- GotAZero:
- pop ebx
- cmp eax,ebx
- je JustAZero
- push ebx
- mov eax,10000
- cmp eax,ebx
- je ActualZero
- jmp DecideSign
- ActualZero:
- mov eax,0
- push eax
- jmp PushCelsDigitsToStack
- JustAZero:
- mov eax,0
- push eax
- DecideSign:
- mov eax,[ncels]
- mov ebx,1
- cmp eax,ebx
- je InsertSign
- jmp InsertAnotherStackMarker
- InsertSign:
- mov eax,45
- mov ebx,30h
- sub eax,ebx
- push eax
- InsertAnotherStackMarker:
- mov eax,10000
- push eax
- CheckIfFahrIsNegative:
- mov eax,[fahr]
- mov ebx,0
- cmp eax,ebx
- jl FahrIsNegative
- jmp PushFahrDigitsToStack
- FahrIsNegative:
- mov eax,1
- mov [nfahr],eax
- mov eax,[fahr]
- mov ebx,-1
- imul eax,ebx
- mov [cels],eax
- PushFahrDigitsToStack:
- mov eax,[fahr]
- mov ebx,0
- cmp eax,ebx
- je GotADifferentZero
- mov ecx,10
- mov edx,0
- cdq
- idiv ecx
- push edx
- mov [fahr],eax
- jmp PushFahrDigitsToStack
- ;;;;Something feels really wrong about GotADifferentZero...
- GotADifferentZero:
- pop ebx
- cmp eax,ebx
- je JustADifferentZero
- push ebx
- mov eax,10000
- cmp eax,ebx
- je AnotherActualZero
- jmp DecideAnotherSign
- AnotherActualZero:
- mov eax,0
- push eax
- jmp PushFahrDigitsToStack
- JustADifferentZero:
- mov eax,0
- push eax
- DecideAnotherSign:
- mov eax,[nfahr]
- mov ebx,1
- cmp eax,ebx
- je InsertAnotherSign
- jmp PrintFahrFromStack
- InsertAnotherSign:
- mov eax,45
- mov ebx,30h
- sub eax,ebx
- push eax
- PrintFahrFromStack:
- mov eax,10000
- pop ebx
- cmp eax,ebx
- je PrintWhitespace
- mov eax,30h
- add eax,ebx
- mov [print],eax
- mov eax,4
- mov ebx,1
- mov ecx,print
- mov edx,1
- int 80h
- jmp PrintFahrFromStack
- PrintWhitespace:
- mov eax,4
- mov ebx,1
- mov ecx,Spaces
- mov edx,4
- int 80h
- PrintCelsFromStack:
- mov eax,10000
- pop ebx
- cmp eax,ebx
- je IncrementFahr
- mov eax,30h
- add eax,ebx
- mov [print],eax
- mov eax,4
- mov ebx,1
- mov ecx,print
- mov edx,1
- int 80h
- jmp PrintCelsFromStack
- IncrementFahr:
- mov eax,[current]
- mov ebx,[step]
- add eax,ebx
- mov [fahr],eax
- mov [current],eax
- mov eax,10
- mov [print],eax
- mov eax,4
- mov ebx,1
- mov ecx,print
- mov edx,1
- int 80h
- jmp PrimaryLoop
- Terminate:
- mov eax,1
- mov ebx,0
- int 80h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement