Skip to content

Instantly share code, notes, and snippets.

@kmahyyg
Last active November 20, 2018 13:28
Show Gist options
  • Save kmahyyg/ce0d0e3079363f7be5d91f7ace0d9c0d to your computer and use it in GitHub Desktop.
Save kmahyyg/ce0d0e3079363f7be5d91f7ace0d9c0d to your computer and use it in GitHub Desktop.
ASM-EXP4
;https://www.kmahyyg.xyz/2018/ASM-exp-report2/ For more details.
mov ax,0xb800 ;screen buffer
mov es,ax
; show string "201x1xx0xxx Yxxx xx xxxxx"
; 0x07 == bell (in ascii), saved in parital addr
; 0x07 saved in odd addr, flash, char options
mov byte [es:0x00],'2'
mov byte [es:0x01],0x05
mov byte [es:0x02],'0'
mov byte [es:0x03],0x05
mov byte [es:0x04],'1'
mov byte [es:0x05],0x05
mov byte [es:0x06],'x'
mov byte [es:0x07],0x05
mov byte [es:0x08],'1'
mov byte [es:0x09],0x05
mov byte [es:0x0a],'x'
mov byte [es:0x0b],0x05
mov byte [es:0x0c],'x'
mov byte [es:0x0d],0x05
mov byte [es:0x0e],'0'
mov byte [es:0x0f],0x05
mov byte [es:0x10],'x'
mov byte [es:0x11],0x05
mov byte [es:0x12],'x'
mov byte [es:0x13],0x05
mov byte [es:0x14],'x'
mov byte [es:0x15],0x05
mov byte [es:0x16],' '
mov byte [es:0x17],0x05
mov byte [es:0x18],'Y'
mov byte [es:0x19],0x05
mov byte [es:0x1a],'x'
mov byte [es:0x1b],0x05
mov byte [es:0x1c],'x'
mov byte [es:0x1d],0x05
mov byte [es:0x1e],'x'
mov byte [es:0x1f],0x05
mov byte [es:0x20],' '
mov byte [es:0x21],0x05
mov byte [es:0x22],'x'
mov byte [es:0x23],0x05
mov byte [es:0x24],'x'
mov byte [es:0x25],0x05
mov byte [es:0x26],' '
mov byte [es:0x27],0x05
mov byte [es:0x28],'x'
mov byte [es:0x29],0x05
mov byte [es:0x2A],'x'
mov byte [es:0x2B],0x05
mov byte [es:0x2C],'x'
mov byte [es:0x2D],0x05
mov byte [es:0x2E],'x'
mov byte [es:0x2F],0x05
mov byte [es:0x30],'x'
mov byte [es:0x31],0x05
mov ax,number ;get the base addr of number seg
mov bx,10
;get the base addr of datasg
mov cx,cs
mov ds,cx
;calc the 10^0
mov dx,0
div bx
; alfter bios exit with code 0, computer will jump to 0x7c00
mov [0x7c00+number+0x00],dl ;save the 10^0
;calc the 10^1
xor dx,dx
div bx
mov [0x7c00+number+0x01],dl
xor dx,dx
div bx
mov [0x7c00+number+0x02],dl
xor dx,dx
div bx
mov [0x7c00+number+0x03],dl
xor dx,dx
div bx
mov [0x7c00+number+0x04],dl
mov cx,0xb850
mov es,cx
;show the offset addr in dec
mov al,[0x7c00+number+0x04]
add al,0x30
mov [es:0x1a],al
mov byte [es:0x1b],0x04
mov al,[0x7c00+number+0x03]
add al,0x30
mov [es:0x1c],al
mov byte [es:0x1d],0x04
mov al,[0x7c00+number+0x02]
add al,0x30
mov [es:0x1e],al
mov byte [es:0x1f],0x04
mov al,[0x7c00+number+0x01]
add al,0x30
mov [es:0x20],al
mov byte [es:0x21],0x04
mov al,[0x7c00+number+0x00]
add al,0x30
mov [es:0x22],al
mov byte [es:0x23],0x04
mov byte [es:0x24],'D'
mov byte [es:0x25],0x07
infi: jmp near infi ; infinity loop here
number db 0,0,0,0,0 ; numbers saved in order to be shown next
times 54 db 0 ; padding the remainder with 0
; times <remainder> db 0
db 0x55,0xaa ; set bootable flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment