Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .code16
- .global _start
- .equ STACK_SEGMENT, 0x7C00
- .equ ORG_SEGMENT, 0x0
- .text
- _start:
- cli
- jmp $ORG_SEGMENT, $(asmain)
- asmain:
- xor %ax, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %ss
- mov $STACK_SEGMENT, %esp
- mov $0xDEAD, %ax
- call printRegister
- call putSeparator
- mov $0xDEAD, %ax
- call printRegister
- call putSeparator
- mov $0xDEAD, %ax
- call printRegister
- call putSeparator
- mov $0xDEAD, %ax
- call printRegister
- call putSeparator
- stop: jmp stop
- printChar:
- mov $0xE, %ah # interrupt service
- mov $0x3, %bh # BH = page number = 0 ; BL = 3 = Cyan (ignored)
- int $0x10
- ret
- putSeparator:
- mov $'_', %al
- call printChar
- ret
- printRegister:
- test %ax, %ax # test for 0, that would
- jne .go
- mov $'0', %al
- call printChar
- ret
- .go:
- mov $10, %bx
- xor %cx, %cx # number of elements pushed.
- xor %dx, %dx # high part of dividend
- .loop:
- div %bx # result = %AX ; remaineder = %DX
- # we're not done yet:
- # Increment n. of elements
- add $1, %cx # elements to show
- add $0x30, %dx # convert to ASCII
- push %dx
- test %ax, %ax # should we continue?
- je .show
- # Prepare %AX for next divs.
- xor %dx, %dx
- jmp .loop
- .show:
- pop %dx
- mov %dl, %al # load character -- already printable
- call printChar
- sub $1, %cx
- test %cx, %cx
- jnz .show
- ret
- .space 510 - (. - _start)
- .word 0xaa55
Advertisement
Add Comment
Please, Sign In to add comment